Skip to content

Conversation

@blazoncek
Copy link
Contributor

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
Contributor 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
Member

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
Contributor 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
Member

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
Contributor 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
Contributor 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
Contributor 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
@blazoncek
Copy link
Contributor Author

Are there any objections to this PR? It is an "opt-in" feature for those that self-compile and does not affect regular official builds.
If no, I would merge it.

@blazoncek blazoncek merged commit b908384 into wled:main Mar 8, 2025
20 checks passed
@blazoncek blazoncek deleted the compile-pin branch March 8, 2025 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants