From 810f144cffcc095e9778976e8aa030cb1ee89824 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Fri, 21 Jan 2022 16:14:11 -0600 Subject: [PATCH] keep portal open if connectonsave is false Not sure if this is a good idea or bad one.. probably better than closing it automatically. --- WiFiManager.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 379d548..0055424 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -811,8 +811,8 @@ uint8_t WiFiManager::processConfigPortal(){ if ( _savewificallback != NULL) { _savewificallback(); } - shutdownConfigPortal(); if(!_connectonsave) return WL_IDLE_STATUS; + shutdownConfigPortal(); return WL_CONNECTED; // CONNECT SUCCESS } #ifdef WM_DEBUG_LEVEL @@ -944,12 +944,16 @@ uint8_t WiFiManager::connectWifi(String ssid, String pass, bool connect) { // if ssid argument provided connect to that if (ssid != "") { wifiConnectNew(ssid,pass,connect); - if(_saveTimeout > 0){ - connRes = waitForConnectResult(_saveTimeout); // use default save timeout for saves to prevent bugs in esp->waitforconnectresult loop - } - else { - connRes = waitForConnectResult(0); - } + // @todo connect=false seems to disconnect sta in begin() so not sure if _connectonsave is useful at all + // skip wait if not connecting + // if(connect){ + if(_saveTimeout > 0){ + connRes = waitForConnectResult(_saveTimeout); // use default save timeout for saves to prevent bugs in esp->waitforconnectresult loop + } + else { + connRes = waitForConnectResult(0); + } + // } } else { // connect using saved ssid if there is one @@ -2053,13 +2057,13 @@ String WiFiManager::getInfoData(String id){ p.replace(FPSTR(T_1),WiFi.softAPgetHostname()); } #endif - #ifdef ESP8266 + // #ifdef ESP8266 #ifndef WM_NOSOFTAPSSID else if(id==F("apssid")){ p = FPSTR(HTTP_INFO_apssid); p.replace(FPSTR(T_1),htmlEntities(WiFi.softAPSSID())); } - #endif + // #endif #endif else if(id==F("apbssid")){ p = FPSTR(HTTP_INFO_apbssid);