[SYS] Add WiFi reconnect watchdog to self-heal from wedged WiFi stack (#2319)
When the network drops at runtime and the WiFi stack is wedged (e.g. the ESP32 driver getting stuck after a long uptime, see #2276), the main loop kept calling wifi_reconnect_bypass() forever with no recovery: the device stayed stale until a manual reboot. The reboot watchdog only existed in the ESPWifiManualSetup path, which the default WiFiManager build doesn't compile. Count consecutive reconnection failures in the runtime loop and ESPRestart(2) once they exceed maxRetryWatchDog, mirroring the existing manual-setup watchdog. Gated behind the new WifiReconnectWatchDog flag (default on) so environments where an unexpected reboot is undesirable can opt out; disabled for theengs-plug to avoid interrupting the relay state. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
cf27d0e3e7
commit
4d945851ce
3 files changed
+16
No files matched your search
@@ -2594,6 +2594,13 @@ void loop() {
|
||||
THEENGS_LOG_WARNING(F("Network disconnected" CR));
|
||||
gatewayState = GatewayState::NTWK_DISCONNECTED;
|
||||
if (!wifi_reconnect_bypass()) {
|
||||
failure_number_ntwk++;
|
||||
THEENGS_LOG_WARNING(F("failure_number_ntwk: %d" CR), failure_number_ntwk);
|
||||
// Self-heal from a wedged WiFi stack: if reconnection keeps failing, restart the ESP.
|
||||
// Disabled on environments where an unexpected reboot is undesirable (e.g. a smart plug).
|
||||
if (WifiReconnectWatchDog && failure_number_ntwk > maxRetryWatchDog) {
|
||||
ESPRestart(2);
|
||||
}
|
||||
sleep();
|
||||
} else {
|
||||
gatewayState = GatewayState::NTWK_CONNECTED;
|
||||
|
||||
Reference in new issue
Block a user