From c55646968f123bd33cd6c51208916568459bed14 Mon Sep 17 00:00:00 2001 From: h2zero <32826625+h2zero@users.noreply.github.com> Date: Mon, 5 Jul 2021 18:41:57 -0600 Subject: [PATCH] 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. --- main/main.ino | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/main/main.ino b/main/main.ino index 2740945..1924ed6 100644 --- a/main/main.ino +++ b/main/main.ino @@ -186,6 +186,8 @@ static String mqtt_cert = ""; # include # include # include +# include +# include # 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 }