Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tablatronix committed Jan 21, 2022
1 parent d0bdf7b commit 553ae00
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 11 additions & 4 deletions WiFiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,15 +705,16 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
DEBUG_WM(DEBUG_VERBOSE,F("Config Portal Running, non blocking/processing"));
if(_configPortalTimeout > 0) DEBUG_WM(DEBUG_VERBOSE,F("Portal Timeout In"),(String)(_configPortalTimeout/1000) + (String)F(" seconds"));
#endif
return result;
return result; // skip blocking loop
}

// enter blocking loop, waiting for config

#ifdef WM_DEBUG_LEVEL
DEBUG_WM(DEBUG_VERBOSE,F("Config Portal Running, blocking, waiting for clients..."));
if(_configPortalTimeout > 0) DEBUG_WM(DEBUG_VERBOSE,F("Portal Timeout In"),(String)(_configPortalTimeout/1000) + (String)F(" seconds"));
#endif

// blocking loop waiting for config
while(1){

// if timed out or abort, break
Expand All @@ -729,6 +730,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
state = processConfigPortal();

// status change, break
// @todo what is this for, should be moved inside the processor
if(state != WL_IDLE_STATUS){
result = (state == WL_CONNECTED); // true if connected
DEBUG_WM(DEBUG_DEV,F("configportal loop break"));
Expand Down Expand Up @@ -832,17 +834,22 @@ uint8_t WiFiManager::processConfigPortal(){
shutdownConfigPortal();
return WL_CONNECT_FAILED; // CONNECT FAIL
}
else{
else if(_configPortalIsBlocking){
// clear save strings
_ssid = "";
_pass = "";
// if connect fails, turn sta off to stabilize AP
WiFi_Disconnect();
WiFi_enableSTA(false);
#ifdef WM_DEBUG_LEVEL
DEBUG_WM(DEBUG_VERBOSE,F("Disabling STA"));
DEBUG_WM(DEBUG_VERBOSE,F("Processing - Disabling STA"));
#endif
}
else{
#ifdef WM_DEBUG_LEVEL
DEBUG_WM(DEBUG_VERBOSE,F("Portal is non blocking - remaining open"));
#endif
}
}

return WL_IDLE_STATUS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void setup() {
//wm.resetSettings();

wm.setConfigPortalBlocking(false);

wm.setConfigPortalTimeout(60);
//automatically connect using saved credentials if they exist
//If connection fails it starts an access point with the specified name
if(wm.autoConnect("AutoConnectAP")){
Expand All @@ -19,6 +19,9 @@ void setup() {
else {
Serial.println("Configportal running");
}

wm.startConfigPortal();
// wm.startWebPortal();
}

void loop() {
Expand Down

0 comments on commit 553ae00

Please sign in to comment.