diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 1c9d0d4..46fa7d7 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1545,6 +1545,17 @@ void WiFiManager::reboot(){ */ bool WiFiManager::erase(){ DEBUG_WM("Erasing"); + + #if defined(WM_ERASE_NVS) + DEBUG_WM("Erasing NVS"); + int err; + err=nvs_flash_init(); + DEBUG_WM("nvs_flash_init: ",err ? err : "Success"); + err=nvs_flash_erase(); + DEBUG_WM("nvs_flash_erase: ", ? err : "Success"); + return; + #endif + return WiFi_eraseConfig(); } @@ -2119,4 +2130,4 @@ void WiFiManager::WiFi_autoReconnect(){ WiFi.onEvent(WiFiEvent); } #endif -} \ No newline at end of file +} diff --git a/WiFiManager.h b/WiFiManager.h index c723e5e..e40d6c7 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -16,6 +16,7 @@ #define WM_WEBSERVERSHIM // use webserver shim lib // #define WM_MDNS // use MDNS // #define WM_FIXERASECONFIG // use erase flash fix +// #define WM_ERASE_NVS // esp32 erase() will erase NVS #ifdef ESP8266 @@ -51,6 +52,11 @@ #endif #endif + #ifdef WM_ERASE_NVS + #include + #include + #endif + #ifdef WM_MDNS #include #endif