diff --git a/WiFiManager.cpp b/WiFiManager.cpp index f7c34d0..f53e389 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -332,11 +332,6 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { return true; // connected success } - // possibly skip the config portal - if (!_enableConfigPortal) { - return false; // not connected and not cp - } - #ifdef WM_DEBUG_LEVEL DEBUG_WM(F("AutoConnect: FAILED")); #endif @@ -347,6 +342,15 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { #endif } + // possibly skip the config portal + if (!_enableConfigPortal) { + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_VERBOSE,F("enableConfigPortal: FALSE, skipping ")); + #endif + + return false; // not connected and not cp + } + // not connected start configportal bool res = startConfigPortal(apName, apPassword); return res; diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index 68a4aa8..bc2d562 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -191,7 +191,10 @@ void setup() { //if it does not connect it starts an access point with the specified name //here "AutoConnectAP" //and goes into a blocking loop awaiting configuration - + + // use autoconnect, but prevent configportal from auto starting + wm.setEnableConfigPortal(false); + wifiInfo(); if(!wm.autoConnect("WM_AutoConnectAP","12345678")) {