From 9169bb0cb1ee3844a3381302892edb0adc6bb16a Mon Sep 17 00:00:00 2001 From: "Adrian A. Baumann" Date: Sat, 27 Jun 2026 01:25:31 +0200 Subject: [PATCH] Clear reset counter after power-on delay to prevent false factory reset --- src/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 4c7dd0d..6e23cb7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -725,6 +725,13 @@ void setup() { attachMeters(); applyMeters(); + // Reset-counter settle window: if the device stays powered past this point it + // wasn't a rapid power-cycle, so clear the counter here — before the (possibly + // indefinitely blocking) WiFi portal — so a stuck/offline boot can't slowly + // accumulate into a false factory reset. + delay(3000); + LittleFS.remove("/reset_count"); + Serial.println("[WIFI] starting WiFiManager"); WiFiManager wm; wm.setTitle("M1730"); @@ -747,7 +754,6 @@ void setup() { startMDNS(); mqttReconnectAt = 0; - LittleFS.remove("/reset_count"); Serial.printf("[BOOT] ready at http://%s.local or http://%s\n", hostname, WiFi.localIP().toString().c_str()); }