diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 85b9dec..f3f196c 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -170,6 +170,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { if (WiFi.status() == WL_CONNECTED || connectWifi("", "") == WL_CONNECTED) { //connected DEBUG_WM(F("IP Address:"),WiFi.localIP()); + _lastconxresult = WL_CONNECTED; return true; } // not connected start configportal @@ -492,6 +493,7 @@ int WiFiManager::connectWifi(String ssid, String pass) { connRes = waitForConnectResult(); } + _lastconxresult = connRes; return connRes; } @@ -1429,6 +1431,10 @@ void WiFiManager::setScanDispPerc(boolean enabled){ _scanDispOptions = true; } +uint8_t WiFiManager::getLastConxResult(){ + return _lastconxresult; +} + // HELPERS template diff --git a/WiFiManager.h b/WiFiManager.h index 9a9ce8c..7dd3f83 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -173,6 +173,10 @@ class WiFiManager void debugSoftAPConfig(); // debug output platform info and versioning void debugPlatformInfo(); + // get last connection result, includes autoconnect and wifisave + uint8_t getLastConxResult(); + // get a status as string + String getWLStatusString(uint8_t status); private: std::unique_ptr dnsServer; @@ -204,8 +208,8 @@ class WiFiManager unsigned long _configPortalStart = 0; // config portal start time (updated for timeouts) unsigned long _webPortalAccessed = 0; // last web access time WiFiMode_t _usermode = WIFI_OFF; - - String _wifissidprefix = FPSTR(S_ssidpre); // auto apname prefix prefix+chipid + String _wifissidprefix = FPSTR(S_ssidpre); // auto apname prefix prefix+chipid + uint8_t _lastconxresult = WL_IDLE_STATUS; // option parameters int _minimumQuality = -1; // filter wifiscan ap by this rssi @@ -272,7 +276,6 @@ class WiFiManager String getHTTPHead(String title); //helpers - String getWLStatusString(uint8_t status); int getRSSIasQuality(int RSSI); boolean isIp(String str); String toStringIp(IPAddress ip); @@ -299,7 +302,7 @@ class WiFiManager // debugging boolean _debug = true; - uint8_t _debugLevel = 2; + uint8_t _debugLevel = 1; Stream& _debugPort; // debug output stream ref template void DEBUG_WM(Generic text); diff --git a/strings_en.h b/strings_en.h index 69bf2f1..968bfff 100644 --- a/strings_en.h +++ b/strings_en.h @@ -225,11 +225,11 @@ const char HTTP_HEAD_CT2[] PROGMEM = "text/plain"; const char * const WIFI_STA_STATUS[] PROGMEM { - "WL_IDLE_STATUS", - "WL_NO_SSID_AVAIL", + "WL_IDLE_STATUS", // STATION_IDLE + "WL_NO_SSID_AVAIL", // STATION_NO_AP_FOUND "WL_SCAN_COMPLETED", - "WL_CONNECTED", - "WL_CONNECT_FAILED", + "WL_CONNECTED", // STATION_GOT_IP + "WL_CONNECT_FAILED",// STATION_CONNECT_FAIL, STATION_WRONG_PASSWORD(NI) "WL_CONNECTION_LOST", "WL_DISCONNECTED" };