[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:
1 parent
e2641f49e7
commit
742945906d
3 files changed
+9
-13
No files matched your search
@@ -73,7 +73,7 @@ void MeasureGPIOInput() {
|
|||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
Log.notice(F("Erasing ESP Config, restarting" CR));
|
Log.notice(F("Erasing ESP Config, restarting" CR));
|
||||||
erase(true);
|
eraseConfig();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resetTime = 0;
|
resetTime = 0;
|
||||||
|
|||||||
+2
-2
@@ -46,7 +46,7 @@ QueueHandle_t webUIQueue;
|
|||||||
WebServer server(80);
|
WebServer server(80);
|
||||||
|
|
||||||
/*------------------- External functions ----------------------*/
|
/*------------------- External functions ----------------------*/
|
||||||
extern void erase(bool restart);
|
extern void eraseConfig();
|
||||||
extern unsigned long uptime();
|
extern unsigned long uptime();
|
||||||
|
|
||||||
/*------------------- Web Console Globals ----------------------*/
|
/*------------------- Web Console Globals ----------------------*/
|
||||||
@@ -1237,7 +1237,7 @@ void handleRT() {
|
|||||||
response += String(buffer);
|
response += String(buffer);
|
||||||
server.send(200, "text/html", response);
|
server.send(200, "text/html", response);
|
||||||
|
|
||||||
erase(true);
|
eraseConfig();
|
||||||
} else {
|
} else {
|
||||||
handleCN();
|
handleCN();
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-10
@@ -1901,7 +1901,7 @@ void blockingWaitForReset() {
|
|||||||
Log.trace(F("mounted file system" CR));
|
Log.trace(F("mounted file system" CR));
|
||||||
if (SPIFFS.exists("/config.json")) {
|
if (SPIFFS.exists("/config.json")) {
|
||||||
Log.notice(F("Erasing ESP Config, restarting" CR));
|
Log.notice(F("Erasing ESP Config, restarting" CR));
|
||||||
erase(true);
|
eraseConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay(30000);
|
delay(30000);
|
||||||
@@ -2742,9 +2742,9 @@ float intTemperatureRead() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Erase flash and restart the ESP
|
Erase config and restart the ESP
|
||||||
*/
|
*/
|
||||||
void erase(bool restart) {
|
void eraseConfig() {
|
||||||
#ifdef SecondaryModule
|
#ifdef SecondaryModule
|
||||||
// Erase the secondary module config
|
// Erase the secondary module config
|
||||||
String eraseCmdStr = "{\"cmd\":\"" + String(eraseCmd) + "\"}";
|
String eraseCmdStr = "{\"cmd\":\"" + String(eraseCmd) + "\"}";
|
||||||
@@ -2756,15 +2756,11 @@ void erase(bool restart) {
|
|||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
WiFi.disconnect(true);
|
WiFi.disconnect(true);
|
||||||
# ifndef ESPWifiManualSetup
|
ESP.eraseConfig();
|
||||||
wifiManager.resetSettings();
|
|
||||||
# endif
|
|
||||||
delay(5000);
|
|
||||||
#else
|
#else
|
||||||
nvs_flash_erase();
|
nvs_flash_erase();
|
||||||
#endif
|
#endif
|
||||||
if (restart)
|
ESPRestart(0);
|
||||||
ESPRestart(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String stateMeasures() {
|
String stateMeasures() {
|
||||||
@@ -3354,7 +3350,7 @@ void XtoSYS(const char* topicOri, JsonObject& SYSdata) { // json object decoding
|
|||||||
if (strstr(cmd, restartCmd) != NULL) { //restart
|
if (strstr(cmd, restartCmd) != NULL) { //restart
|
||||||
ESPRestart(5);
|
ESPRestart(5);
|
||||||
} else if (strstr(cmd, eraseCmd) != NULL) { //erase and restart
|
} else if (strstr(cmd, eraseCmd) != NULL) { //erase and restart
|
||||||
erase(true);
|
eraseConfig();
|
||||||
} else if (strstr(cmd, statusCmd) != NULL) {
|
} else if (strstr(cmd, statusCmd) != NULL) {
|
||||||
publishState = true;
|
publishState = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user