[SYS] Fix erase function for ESP8266 (#2101)

And remove restart parameter as it is not used (the ESP always restart after erase for our use cases)

Co-authored-by: Florian <1technophile@users.noreply.github.com>
This commit is contained in:
FlorianandFlorian authored and GitHub committed 2024-11-10 08:23:53 -06:00
1 parent e2641f49e7
commit 742945906d
3 files changed
+9 -13

No files matched your search

+1 -1
View File
@@ -73,7 +73,7 @@ void MeasureGPIOInput() {
}
# endif
Log.notice(F("Erasing ESP Config, restarting" CR));
erase(true);
eraseConfig();
}
} else {
resetTime = 0;
+2 -2
View File
@@ -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();
}
+6 -10
View File
@@ -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;
}