Skip to content

Commit

Permalink
#528 WL_DISCONNECTED support for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tablatronix committed Feb 20, 2018
1 parent 3d70741 commit 39f20a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
19 changes: 12 additions & 7 deletions WiFiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
*/

#include "WiFiManager.h"

#ifdef ESP32
uint8_t WiFiManager::_lastconxresulttmp = WL_IDLE_STATUS;
#endif

/**
* --------------------------------------------------------------------------------
Expand Down Expand Up @@ -217,7 +220,6 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
}
return true;
}

// not connected start configportal
return startConfigPortal(apName, apPassword);
}
Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions WiFiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 39f20a6

Please sign in to comment.