Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile time lock PIN definition #4307

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

blazoncek
Copy link
Collaborator

Adds ability to define default settings PIN at compile time (instead of no PIN defined).

Requested by a friend.

@w00000dy
Copy link
Contributor

How do I set this?

I tried build_flags =... -D WLED_PIN=1234 and -D WLED_PIN="1234". Both did not work.

@blazoncek
Copy link
Collaborator Author

Either: -D WLED_PIN=\"1234\" or -D WLED_PIN='"1234"' as used elsewhere.

Copy link
Contributor

@w00000dy w00000dy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things I noticed:

  • This only works if you have a fresh installation (erased flash).
  • On the first boot it does not ask for the pin. Only after the 2nd boot does it ask for the pin.

WLED_GLOBAL bool wifiLock _INIT(false); // prevents access to WiFi settings when OTA lock is enabled
WLED_GLOBAL bool aOtaEnabled _INIT(true); // ArduinoOTA allows easy updates directly from the IDE. Careful, it does not auto-disable when OTA lock is on
WLED_GLOBAL char settingsPIN[5] _INIT(""); // PIN for settings pages
WLED_GLOBAL bool otaLock _INIT(false); // prevents OTA firmware updates without password. ALWAYS enable if system exposed to any public networks
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert unrelated whitespace changes please

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to keep comments aligned. Personal preference.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine for when making changes, not for unrelated code

It's bad practice to apply formatting changes to code not related to the PR, it creates harder to review PRs and breaks the history of each line making debugging issues harder as git blame will make it appear the code has changed more recently that it has and with incorrect description

@blazoncek
Copy link
Collaborator Author

This only works if you have a fresh installation (erased flash).

Yes, that is expected. The code does not modify existing configuration.

On the first boot it does not ask for the pin. Only after the 2nd boot does it ask for the pin.

Then a check where a bug is is in order. Though that may be good as it will allow to set WiFi credentials (unfortunately that will be available only once).

@blazoncek
Copy link
Collaborator Author

There's one more thing that needs to be done: allow WiFi settings to be available until WiFi is configured.

@w00000dy
Copy link
Contributor

I would prefer that the WiFi settings be locked when I set a pin (as they are now). I think this would be the expected behavior when I set a pin.
So if I run a device in AP-only mode, I can prevent anyone from changing that.

@blazoncek
Copy link
Collaborator Author

allow WiFi settings to be available until WiFi is configured.

I specifically mentioned "configured" WiFi. Even if you run it unconnected in AP mode.
You still have the option to lock OTA (and WiFi configuration) from settings.

@blazoncek blazoncek marked this pull request as draft November 25, 2024 21:12
@blazoncek blazoncek changed the title Compile time PIN definition Compile time lock PIN definition Dec 10, 2024
@blazoncek blazoncek marked this pull request as ready for review December 10, 2024 09:23
@netmindz netmindz changed the base branch from 0_15 to main December 16, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants