From 3c39908720ef2527b1898e6a3e89fd0175da78cb Mon Sep 17 00:00:00 2001 From: agessaman Date: Sat, 19 Sep 2026 10:53:39 -0700 Subject: [PATCH] fix(webconfig): read the LAN address after pinning the route startLanMode() took the caller's IP, read before the route lock. A Wi-Fi/Ethernet switch in between left WebConfig locked to the new link while advertising the old link's address. It now reads the selected link's address after lockSwitching(), as startOTAUpdate() already does. --- examples/simple_repeater/MyMesh.cpp | 3 +-- examples/simple_room_server/MyMesh.cpp | 3 +-- src/helpers/esp32/WebConfigServer.cpp | 4 +++- src/helpers/esp32/WebConfigServer.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/simple_repeater/MyMesh.cpp b/examples/simple_repeater/MyMesh.cpp index 29518694..ff70df6f 100644 --- a/examples/simple_repeater/MyMesh.cpp +++ b/examples/simple_repeater/MyMesh.cpp @@ -1512,8 +1512,7 @@ bool MyMesh::startWebConfig(bool force_ap, char* reply) { } _webconfig->startSetupMode(reply); } else if (activeNetworkLink().isConnected()) { - _webconfig->startLanMode(activeNetworkLink().localIP(), - !mqttNetworkSetupComplete(_cli.getObserverPrefs()), reply); + _webconfig->startLanMode(!mqttNetworkSetupComplete(_cli.getObserverPrefs()), reply); } else if (!mqttNetworkSetupComplete(_cli.getObserverPrefs())) { _webconfig->startSetupMode(reply); } else { diff --git a/examples/simple_room_server/MyMesh.cpp b/examples/simple_room_server/MyMesh.cpp index f5b41860..35bbd632 100644 --- a/examples/simple_room_server/MyMesh.cpp +++ b/examples/simple_room_server/MyMesh.cpp @@ -1314,8 +1314,7 @@ bool MyMesh::startWebConfig(bool force_ap, char* reply) { } _webconfig->startSetupMode(reply); } else if (activeNetworkLink().isConnected()) { - _webconfig->startLanMode(activeNetworkLink().localIP(), - !mqttNetworkSetupComplete(_cli.getObserverPrefs()), reply); + _webconfig->startLanMode(!mqttNetworkSetupComplete(_cli.getObserverPrefs()), reply); } else if (!mqttNetworkSetupComplete(_cli.getObserverPrefs())) { _webconfig->startSetupMode(reply); } else { diff --git a/src/helpers/esp32/WebConfigServer.cpp b/src/helpers/esp32/WebConfigServer.cpp index 510d9b75..bb9bdc36 100644 --- a/src/helpers/esp32/WebConfigServer.cpp +++ b/src/helpers/esp32/WebConfigServer.cpp @@ -301,7 +301,7 @@ bool WebConfigServer::startSetupMode(char reply[]) { return true; } -bool WebConfigServer::startLanMode(IPAddress ip, bool initial_setup, char reply[]) { +bool WebConfigServer::startLanMode(bool initial_setup, char reply[]) { if (_mode != MODE_OFF || _stopping) { strcpy(reply, "Err: webconfig busy"); return false; @@ -313,6 +313,8 @@ bool WebConfigServer::startLanMode(IPAddress ip, bool initial_setup, char reply[ } activeNetworkLink().lockSwitching(); _network_locked = true; + // Read the address only once the route is pinned, so it names the locked link. + const IPAddress ip = activeNetworkLink().localIP(); if (!activeNetworkLink().isConnected() || ip == IPAddress()) { activeNetworkLink().unlockSwitching(); _network_locked = false; diff --git a/src/helpers/esp32/WebConfigServer.h b/src/helpers/esp32/WebConfigServer.h index b19ca810..16ff47ba 100644 --- a/src/helpers/esp32/WebConfigServer.h +++ b/src/helpers/esp32/WebConfigServer.h @@ -84,7 +84,7 @@ public: static bool isRebootPending(); bool startSetupMode(char reply[]); // open SoftAP + DNS captive portal - bool startLanMode(IPAddress ip, bool initial_setup, char reply[]); + bool startLanMode(bool initial_setup, char reply[]); // bind to the selected network void requestStop(); // stop listening and detach this session void tick(uint32_t now); // call every loop iteration