From 8d7da2fd8b05ca59bd3638854f5138675652786c Mon Sep 17 00:00:00 2001 From: Shawn A Date: Wed, 27 Jun 2018 16:19:12 -0500 Subject: [PATCH] FIx esp32 updates Webserver now builtin to esp32 lib, esp32 persistent still not implemented properly, fixes erase again, fixes save again --- README.md | 3 +-- WiFiManager.cpp | 10 +++++++++- WiFiManager.h | 3 +-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 717a292..55469f8 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,11 @@ First attempt at a library. Lots more changes and fixes to do. Contributions are [https://github.com/esp8266/Arduino](https://github.com/esp8266/Arduino) -**This works with the ESP32 Arduino platform with staging , with caveats below** +**This works with the ESP32 Arduino platform with staging** [https://github.com/espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) ### Known Issues -* :exclamation: ESP32 must be patched with webserver library, see [https://github.com/tzapu/WiFiManager/issues/513](https://github.com/tzapu/WiFiManager/issues/513) * Documentation needs to be updated, see [https://github.com/tzapu/WiFiManager/issues/500](https://github.com/tzapu/WiFiManager/issues/500) ## Contents diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 9cfff5b..049e695 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -165,6 +165,7 @@ WiFiManager::~WiFiManager() { if (_params != NULL){ DEBUG_WM(DEBUG_DEV,F("freeing allocated params!")); free(_params); + _params = NULL; } DEBUG_WM(DEBUG_DEV,F("unloading")); @@ -173,7 +174,10 @@ WiFiManager::~WiFiManager() { void WiFiManager::_begin(){ if(_hasBegun) return; _usermode = WiFi.getMode(); + + #ifndef ESP32 WiFi.persistent(false); // disable persistent so scannetworks and mode switching do not cause overwrites + #endif } void WiFiManager::_end(){ @@ -206,6 +210,10 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { return false; } + #ifdef ESP32 + if(esp32persistent) WiFi.persistent(false); // disable persistent for esp32 after esp_wifi_start or else saves wont work + #endif + _usermode = WIFI_STA; // no getter for autoreconnectpolicy before this @@ -2362,7 +2370,7 @@ bool WiFiManager::WiFi_eraseConfig() { bool ret; WiFi.mode(WIFI_AP_STA); // cannot erase if not in STA mode ! WiFi.persistent(true); - ret = WiFi.disconnect(true); + ret = WiFi.disconnect(true,true); WiFi.persistent(false); return ret; #endif diff --git a/WiFiManager.h b/WiFiManager.h index 3a49b98..9013b53 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -48,12 +48,11 @@ #define WM_WIFIOPEN WIFI_AUTH_OPEN #ifndef WEBSERVER_H - #warning "WEBSERVER not implemented in espressif/esp32, see readme notes" #ifdef WM_WEBSERVERSHIM #include #else #include - // Forthcoming official + // Forthcoming official ? // https://github.com/esp8266/ESPWebServer #endif #endif