From eb34daf9bfafa403341b15a8769d297de302d79c Mon Sep 17 00:00:00 2001 From: Florian <1technophile@users.noreply.github.com> Date: Fri, 8 Nov 2024 16:18:07 -0600 Subject: [PATCH] [SYS] Fix erase function for ESP8266 And remove restart parameter as it is not used (the ESP always restart after erase for our use cases) --- main/ZsensorGPIOInput.ino | 2 +- main/ZwebUI.ino | 4 ++-- main/main.ino | 16 ++++++---------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/main/ZsensorGPIOInput.ino b/main/ZsensorGPIOInput.ino index 46a91e2479..f2fd304b15 100644 --- a/main/ZsensorGPIOInput.ino +++ b/main/ZsensorGPIOInput.ino @@ -73,7 +73,7 @@ void MeasureGPIOInput() { } # endif Log.notice(F("Erasing ESP Config, restarting" CR)); - erase(true); + eraseConfig(); } } else { resetTime = 0; diff --git a/main/ZwebUI.ino b/main/ZwebUI.ino index b3d7c3780b..022e2f1a88 100644 --- a/main/ZwebUI.ino +++ b/main/ZwebUI.ino @@ -46,7 +46,7 @@ QueueHandle_t webUIQueue; WebServer server(80); /*------------------- External functions ----------------------*/ -extern void erase(bool restart); +extern void eraseConfig(); extern unsigned long uptime(); /*------------------- Web Console Globals ----------------------*/ @@ -1237,7 +1237,7 @@ void handleRT() { response += String(buffer); server.send(200, "text/html", response); - erase(true); + eraseConfig(); } else { handleCN(); } diff --git a/main/main.ino b/main/main.ino index 196c07d1b9..54bac16502 100644 --- a/main/main.ino +++ b/main/main.ino @@ -1901,7 +1901,7 @@ void blockingWaitForReset() { Log.trace(F("mounted file system" CR)); if (SPIFFS.exists("/config.json")) { Log.notice(F("Erasing ESP Config, restarting" CR)); - erase(true); + eraseConfig(); } } delay(30000); @@ -2742,9 +2742,9 @@ float intTemperatureRead() { #endif /* - Erase flash and restart the ESP + Erase config and restart the ESP */ -void erase(bool restart) { +void eraseConfig() { #ifdef SecondaryModule // Erase the secondary module config String eraseCmdStr = "{\"cmd\":\"" + String(eraseCmd) + "\"}"; @@ -2756,15 +2756,11 @@ void erase(bool restart) { #if defined(ESP8266) WiFi.disconnect(true); -# ifndef ESPWifiManualSetup - wifiManager.resetSettings(); -# endif - delay(5000); + ESP.eraseConfig(); #else nvs_flash_erase(); #endif - if (restart) - ESPRestart(0); + ESPRestart(0); } String stateMeasures() { @@ -3354,7 +3350,7 @@ void XtoSYS(const char* topicOri, JsonObject& SYSdata) { // json object decoding if (strstr(cmd, restartCmd) != NULL) { //restart ESPRestart(5); } else if (strstr(cmd, eraseCmd) != NULL) { //erase and restart - erase(true); + eraseConfig(); } else if (strstr(cmd, statusCmd) != NULL) { publishState = true; }