#528 WL_DISCONNECTED support for testing

This commit is contained in:
Shawn A
2018-02-20 11:13:46 -06:00
parent 3d7074166c
commit 39f20a6adc
2 changed files with 17 additions and 9 deletions
+12 -7
View File
@@ -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;
}
+5 -2
View File
@@ -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