Merge branch 'development' of https://github.com/tzapu/WiFiManager into development

This commit is contained in:
tablatronix
2018-03-05 20:12:49 -06:00
3 changed files with 40 additions and 4 deletions
-1
View File
@@ -17,7 +17,6 @@ First attempt at a library. Lots more changes and fixes to do. Contributions are
### 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)
* :exclamation: ESP32 espressif/dnsserver contains bugs that prevent captive portal from working, 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
+31 -3
View File
@@ -591,7 +591,7 @@ uint8_t WiFiManager::connectWifi(String ssid, String pass) {
} else {
// connect using saved ssid if there is one
if (WiFi_hasAutoConnect()) {
DEBUG_WM(F("Connecting to saved AP"));
DEBUG_WM(F("Connecting to saved AP:"),WiFi_SSID());
WiFi_enableSTA(true,storeSTAmode);
WiFi.begin();
} else {
@@ -1526,9 +1526,10 @@ void WiFiManager::reportStatus(String &page){
*/
bool WiFiManager::disconnect(){
if(WiFi.status() != WL_CONNECTED){
DEBUG_WM("Disconnect: Not connected");
DEBUG_WM("Disconnecting: Not connected");
return false;
}
DEBUG_WM("Disconnecting");
return WiFi_Disconnect();
}
@@ -1537,9 +1538,36 @@ bool WiFiManager::disconnect(){
* @access public
*/
void WiFiManager::reboot(){
DEBUG_WM("Restarting");
ESP.restart();
}
/**
* reboot the device
* @access public
*/
bool WiFiManager::erase(){
return erase(false);
}
bool WiFiManager::erase(bool opt){
DEBUG_WM("Erasing");
#if defined(ESP32) && defined(WM_ERASE_NVS)
// if opt true, do nvs erase
if(opt){
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 ? err : "Success");
return err;
}
#endif
return WiFi_eraseConfig();
}
/**
* [resetSettings description]
@@ -2111,4 +2139,4 @@ void WiFiManager::WiFi_autoReconnect(){
WiFi.onEvent(WiFiEvent);
}
#endif
}
}
+9
View File
@@ -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
#ifdef ESP8266
@@ -51,6 +52,11 @@
#endif
#endif
#ifdef WM_ERASE_NVS
#include <nvs.h>
#include <nvs_flash.h>
#endif
#ifdef WM_MDNS
#include <ESPmDNS.h>
#endif
@@ -148,6 +154,9 @@ class WiFiManager
void reboot();
// disconnect wifi, without persistent saving or erasing
bool disconnect();
// erase esp
bool erase();
bool erase(bool opt);
//sets timeout before AP,webserver loop ends and exits even if there has been no setup.
//useful for devices that failed to connect at some point and got stuck in a webserver loop