Erase stored settings in NVS when triggered. (#1009)

This resolves #994 where the esp32 would still save the client information after a factory reset is performed.
This commit is contained in:
h2zero authored and GitHub committed 2021-07-05 19:41:57 -05:00
1 parent 3f13984f44
commit c55646968f
1 file changed
+4 -7
+4 -7
View File
@@ -186,6 +186,8 @@ static String mqtt_cert = "";
# include <ArduinoOTA.h>
# include <FS.h>
# include <SPIFFS.h>
# include <nvs.h>
# include <nvs_flash.h>
# ifdef ESP32_ETHERNET
# define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
@@ -985,19 +987,14 @@ void checkButton() {}
# endif
void eraseAndRestart() {
# if defined(ESP8266)
WiFi.disconnect(true);
# else
WiFi.disconnect(true, true);
# endif
Log.trace(F("Formatting requested, result: %d" CR), SPIFFS.format());
# if defined(ESP8266)
ESP.eraseConfig();
SPIFFS.format();
delay(5000);
ESP.reset();
# else
nvs_flash_erase();
ESP.restart();
# endif
}