Skip to content
Open
1 change: 1 addition & 0 deletions wled00/my_config_sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
#define CLIENT_PASS "Your_Password"
*/

//#define WLED_FORCE_WIFI_OFF // Hard disable WiFi radio (WIFI_OFF): no STA and no AP.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please remove the flag here, too (see my comment on wled.h)

//#define MAX_LEDS 1500 // Maximum total LEDs. More than 1500 might create a low memory situation on ESP8266.
//#define MDNS_NAME "wled" // mDNS hostname, ie: *.local
16 changes: 16 additions & 0 deletions wled00/wled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,13 @@ void WLED::setup()
WiFi.persistent(false); // on ES8266 using NVM for wifi config has no benefit of faster connection
#endif
WiFi.onEvent(WiFiEvent);
#ifdef WLED_FORCE_WIFI_OFF
DEBUG_PRINTLN(F("WLED_FORCE_WIFI_OFF: forcing WiFi OFF."));
WiFi.mode(WIFI_OFF);
#else
WiFi.mode(WIFI_STA); // enable scanning
findWiFi(true); // start scanning for available WiFi-s
#endif

// all GPIOs are allocated at this point
serialCanRX = !PinManager::isPinAllocated(hardwareRX); // Serial RX pin (GPIO 3 on ESP32 and ESP8266)
Expand Down Expand Up @@ -633,6 +638,10 @@ void WLED::beginStrip()

void WLED::initAP(bool resetAP)
{
#ifdef WLED_FORCE_WIFI_OFF
return;
#endif

if (apBehavior == AP_BEHAVIOR_BUTTON_ONLY && !resetAP)
return;

Expand Down Expand Up @@ -673,6 +682,13 @@ void WLED::initAP(bool resetAP)
void WLED::initConnection()
{
DEBUG_PRINTF_P(PSTR("initConnection() called @ %lus.\n"), millis()/1000);
#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;
#endif

#ifdef WLED_ENABLE_WEBSOCKETS
ws.onEvent(wsEvent);
#endif
Expand Down
1 change: 1 addition & 0 deletions wled00/wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#endif

// You can choose some of these features to disable:
//#define WLED_FORCE_WIFI_OFF // saves 5kb, hard-disable WiFi radio entirely (WIFI_OFF). AP/STA will not start.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Its better to not add the flag here. It will be too tempting for "cool lets try this" users to brick their boards.

For documentation, i'd prefer a PR in WLED-Docs and describe the new flag as an expert option.

//#define WLED_DISABLE_ALEXA // saves 11kb
//#define WLED_DISABLE_HUESYNC // saves 4kb
//#define WLED_DISABLE_INFRARED // saves 12kb, there is no pin left for this on ESP8266-01
Expand Down