Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions platformio_override.sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,50 @@ build_flags = ${common.build_flags} ${esp8266.build_flags}
; -D HW_PIN_MISOSPI=9



# ------------------------------------------------------------------------------
# SLWF-09 example: build two variants side-by-side for binary size comparison
# ------------------------------------------------------------------------------
# Usage:
# 1) copy this file to platformio_override.ini
# 2) set [platformio] default_envs to one or both envs below, OR call pio with -e
# 3) build both and compare with: ./tools/compare_wifioff_size.sh slwf09_eth_wifi_on slwf09_eth_wifi_off

[env:slwf09_eth_wifi_on]
extends = env:esp32dev_16M
build_flags =
${env:esp32dev_16M.build_flags}
-D SERVERNAME="\"A1-SLWF-09\""
-D WLED_BRAND="\"A1-SLWF-09\""
-D MDNS_NAME="\"A1-SLWF-09\""
-D BTNPIN=39,34,36,38
-D BTNTYPE=BTN_TYPE_PUSH,BTN_TYPE_PUSH,BTN_TYPE_PUSH_ACT_HIGH,BTN_TYPE_PUSH
-D ABL_MILLIAMPS_DEFAULT=3000
-D DEFAULT_LED_PIN=4
-D DATA_PINS=4
-D DEFAULT_LED_EFFECT=157
-D DEFAULT_LED_COUNT=300
-D DEFAULT_LED_TYPE=TYPE_WS2812_RGB
-D RLYPIN=33
-D RLYMDE=0
-D WLED_USE_ETHERNET
-D WLED_ETH_DEFAULT=WLED_ETH_WT32_ETH01
-D UM_AUDIOREACTIVE_ENABLE
-D I2S_SDPIN=32
-D I2S_WSPIN=15
-D I2S_CKPIN=14
-D SR_SQUELCH=10
-D SR_GAIN=60
-D SR_DMTYPE=1
-D USERMOD_AUTO_SAVE
-D AUTOSAVE_AFTER_SEC=10
-D AUTOSAVE_PRESET_NUM=100
-D USERMOD_AUTO_SAVE_ON_BOOT=true

[env:slwf09_eth_wifi_off]
extends = env:slwf09_eth_wifi_on
build_flags = ${env:slwf09_eth_wifi_on.build_flags} -D WLED_FORCE_WIFI_OFF

# ------------------------------------------------------------------------------
# Optional: build flags for speed, instead of optimising for size.
# Example of usage: see [env:esp32S3_PSRAM_HUB75]
Expand Down
38 changes: 38 additions & 0 deletions tools/compare_wifioff_size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -euo pipefail

ENV_ON="${1:-slwf09_eth_wifi_on}"
ENV_OFF="${2:-slwf09_eth_wifi_off}"

echo "==> Building $ENV_ON"
pio run -e "$ENV_ON"
echo "==> Building $ENV_OFF"
pio run -e "$ENV_OFF"

BIN_ON=".pio/build/${ENV_ON}/firmware.bin"
BIN_OFF=".pio/build/${ENV_OFF}/firmware.bin"

if [[ ! -f "$BIN_ON" || ! -f "$BIN_OFF" ]]; then
echo "Binary missing. Expected:"
echo " $BIN_ON"
echo " $BIN_OFF"
exit 2
fi

SIZE_ON=$(stat -c '%s' "$BIN_ON")
SIZE_OFF=$(stat -c '%s' "$BIN_OFF")
DELTA=$((SIZE_OFF - SIZE_ON))

echo
echo "Firmware binaries:"
echo " WiFi ON : $BIN_ON"
echo " WiFi OFF: $BIN_OFF"
echo
echo "Sizes (bytes):"
printf ' %-10s %12d\n' "WiFi ON" "$SIZE_ON"
printf ' %-10s %12d\n' "WiFi OFF" "$SIZE_OFF"
printf ' %-10s %12d\n' "Delta" "$DELTA"
echo

echo "SHA256:"
sha256sum "$BIN_ON" "$BIN_OFF"
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.
//#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
17 changes: 17 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
Comment on lines +514 to +517
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve connection startup flow in WiFi-off setup path

The WLED_FORCE_WIFI_OFF branch skips the startup findWiFi(true) call, but handleConnection() still has an early guard that returns while wifiConfigured && multiWiFi.size() > 1 && WiFi.scanComplete() < 0. On devices with multiple saved SSIDs, scanComplete() can stay in the negative "no scan complete" state, so the loop keeps returning before initConnection()/interface initialization runs, causing startup networking services to stall even if Ethernet is present.

Useful? React with 👍 / 👎.

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,14 @@ 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."));
lastReconnectAttempt = millis();
WiFi.disconnect(true);
WiFi.mode(WIFI_OFF);
return;
Comment on lines +686 to +690
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Register websocket callbacks before WiFi-off early return

When WLED_FORCE_WIFI_OFF is enabled, initConnection() returns before reaching ws.onEvent(wsEvent), and this is the only websocket callback registration in the repo (wled00/wled.cpp). In that configuration (notably Ethernet-only builds with websockets enabled), websocket clients can connect but incoming websocket events are never handled, which breaks the live UI/control path that relies on wsEvent.

Useful? React with 👍 / 👎.

#endif

#ifdef WLED_ENABLE_WEBSOCKETS
ws.onEvent(wsEvent);
#endif
Expand Down
2 changes: 2 additions & 0 deletions wled00/wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

// You are required to disable over-the-air updates:
//#define WLED_DISABLE_OTA // saves 14kb
// hard-disable WiFi radio entirely (WIFI_OFF). AP/STA will not start.
//#define WLED_FORCE_WIFI_OFF
#ifdef WLED_ENABLE_AOTA
#if defined(WLED_DISABLE_OTA)
#warning WLED_DISABLE_OTA was defined but it will be ignored due to WLED_ENABLE_AOTA.
Expand Down