Skip to content

Add compile-time WiFi hard-off mode (WLED_FORCE_WIFI_OFF)#1

Merged
Stargazer2026 merged 2 commits intomainfrom
codex/check-wled-firmware-wlan-behavior-with-lan
Feb 23, 2026
Merged

Add compile-time WiFi hard-off mode (WLED_FORCE_WIFI_OFF)#1
Stargazer2026 merged 2 commits intomainfrom
codex/check-wled-firmware-wlan-behavior-with-lan

Conversation

@Stargazer2026
Copy link
Owner

@Stargazer2026 Stargazer2026 commented Feb 23, 2026

Motivation

  • Provide a compile-time "flight mode" option to completely disable the WiFi radio (WIFI_OFF) so builds for Ethernet-only or radio-restricted environments do not start STA or AP interfaces.
  • This saves 5kb for the resulting firmware.bin binary.

Description

  • Add a commented compile-time flag WLED_FORCE_WIFI_OFF to wled.h and document it in my_config_sample.h so users can enable it from my_config.h or build flags.
  • In wled.cpp, change startup networking to call WiFi.mode(WIFI_OFF) when WLED_FORCE_WIFI_OFF is defined instead of starting STA scanning and findWiFi(true).
  • Short-circuit initAP() to immediately return when WLED_FORCE_WIFI_OFF is defined so no softAP is created.
  • Make initConnection() early-exit when WLED_FORCE_WIFI_OFF is defined after calling WiFi.disconnect(true) and forcing WiFi.mode(WIFI_OFF), and add debug prints to indicate the forced-off state.

Testing

  • Ran automated file-modification checks (pattern replacements and nl/rg inspections) to verify the flag and conditional blocks were inserted into wled.h, my_config_sample.h, and wled.cpp, and those checks succeeded.
  • Build succeeded

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8eb607d7f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +685 to +689
#ifdef WLED_FORCE_WIFI_OFF
DEBUG_PRINTLN(F("WLED_FORCE_WIFI_OFF active. Skipping WiFi/AP init."));
WiFi.disconnect(true);
WiFi.mode(WIFI_OFF);
return;

Choose a reason for hiding this comment

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

P1 Badge Initialize reconnect state before WiFi-off early return

When WLED_FORCE_WIFI_OFF is enabled, initConnection() returns in this block before lastReconnectAttempt is set (currently done later in the function). handleConnection() gates its first path on lastReconnectAttempt == 0, so this creates a perpetual "initial connect" loop that returns early on every iteration, repeatedly resetting interfacesInited and preventing initInterfaces() (and therefore server.begin()) from running in Ethernet-only deployments. This makes the new hard-off mode effectively break network availability instead of only disabling WiFi radio usage.

Useful? React with 👍 / 👎.

@Stargazer2026 Stargazer2026 force-pushed the codex/check-wled-firmware-wlan-behavior-with-lan branch from 09339c8 to e3af1ad Compare February 23, 2026 17:08
@Stargazer2026 Stargazer2026 merged commit 83f45cd into main Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant