From 39f20a6adcbcc55c4674182bd7ad2b0f6522e7c9 Mon Sep 17 00:00:00 2001 From: Shawn A Date: Tue, 20 Feb 2018 11:13:46 -0600 Subject: [PATCH] #528 WL_DISCONNECTED support for testing --- WiFiManager.cpp | 19 ++++++++++++------- WiFiManager.h | 7 +++++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 1ffba8c..d3179a9 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -11,7 +11,10 @@ */ #include "WiFiManager.h" + +#ifdef ESP32 uint8_t WiFiManager::_lastconxresulttmp = WL_IDLE_STATUS; +#endif /** * -------------------------------------------------------------------------------- @@ -217,7 +220,6 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { } return true; } - // not connected start configportal return startConfigPortal(apName, apPassword); } @@ -577,19 +579,22 @@ uint8_t WiFiManager::connectWifi(String ssid, String pass) { if(connRes != WL_SCAN_COMPLETED){ _lastconxresult = connRes; // hack in wrong password detection - if(_lastconxresult == WL_CONNECT_FAILED){ - #ifdef ESP8266 + #ifdef ESP8266 + if(_lastconxresult == WL_CONNECT_FAILED){ if(wifi_station_get_connect_status() == STATION_WRONG_PASSWORD){ _lastconxresult = WL_STATION_WRONG_PASSWORD; } - #elif defined(ESP32) - // DEBUG_WM("lastconxresulttmp:",getWLStatusString(_lastconxresulttmp)); + } + #elif defined(ESP32) + // if(_lastconxresult == WL_CONNECT_FAILED){ + if(_lastconxresult == WL_CONNECT_FAILED || _lastconxresult == WL_DISCONNECTED){ + DEBUG_WM("lastconxresulttmp:",getWLStatusString(_lastconxresulttmp)); if(_lastconxresulttmp != WL_IDLE_STATUS){ _lastconxresult = _lastconxresulttmp; _lastconxresulttmp = WL_IDLE_STATUS; } + } #endif - } DEBUG_WM("lastconxresult:",getWLStatusString(_lastconxresult)); } @@ -1955,8 +1960,8 @@ void WiFiManager::WiFiEvent(WiFiEvent_t event,system_event_info_t info){ // WiFiManager _WiFiManager; // Serial.print("WM: EVENT: ");Serial.println(event); if(event == SYSTEM_EVENT_STA_DISCONNECTED){ + Serial.print("WM: EVENT: WIFI_REASON: ");Serial.println(info.disconnected.reason); if(info.disconnected.reason == WIFI_REASON_AUTH_EXPIRE || info.disconnected.reason == WIFI_REASON_AUTH_FAIL){ - Serial.print("WM: EVENT: WIFI_REASON: ");Serial.println(info.disconnected.reason); _lastconxresulttmp = 7; return; } diff --git a/WiFiManager.h b/WiFiManager.h index fdb7ddd..4a5e239 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -209,14 +209,17 @@ class WiFiManager // options flags unsigned long _configPortalTimeout = 0; // ms close config portal loop if set (depending on _cp/webClientCheck options) - unsigned long _connectTimeout = 10000; // ms stop trying to connect to ap if set + unsigned long _connectTimeout = 0; // ms stop trying to connect to ap if set unsigned long _configPortalStart = 0; // ms config portal start time (updated for timeouts) unsigned long _webPortalAccessed = 0; // ms last web access time WiFiMode_t _usermode = WIFI_OFF; String _wifissidprefix = FPSTR(S_ssidpre); // auto apname prefix prefix+chipid uint8_t _lastconxresult = WL_IDLE_STATUS; - static uint8_t _lastconxresulttmp; + #ifdef ESP32 + static uint8_t _lastconxresulttmp; // tmp var for esp32 callback + #endif + #ifndef WL_STATION_WRONG_PASSWORD uint8_t WL_STATION_WRONG_PASSWORD = 7; #endif