testing non blocking portal

calling process in loop not fast enough results in corrupt webpages, not sure why.
This commit is contained in:
Shawn A
2017-08-27 00:11:04 -05:00
parent 0aecffc822
commit 47d9082e18
2 changed files with 16 additions and 0 deletions
+12
View File
@@ -209,6 +209,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
_apPassword = apPassword;
if(!validApPassword()) return false;
configPortalActive = true;
connect = false; // global
// init configportal
@@ -216,6 +217,8 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
uint8_t state;
bool result = false;
if(!_configPortalIsBlocking) return result;
// blocking loop waiting for config
while(1){
@@ -237,6 +240,14 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
return result;
}
boolean WiFiManager::process(){
if(configPortalActive){
uint8_t state = handleConfigPortal();
return state == WL_CONNECTED;
}
return false;
}
//using esp enums returns for now, should be fine
uint8_t WiFiManager::handleConfigPortal(){
//DNS handler
@@ -290,6 +301,7 @@ boolean WiFiManager::stopConfigPortal(){
bool ret = WiFi.softAPdisconnect(false);
if(!ret)DEBUG_WM(F("disconnect configportal error"));
wifimode(WIFI_STA); // set back to sta, @todo use preservation variable
configPortalActive = false;
return ret;
}
+4
View File
@@ -82,6 +82,7 @@ class WiFiManager
//if you want to always start the config portal, without trying to connect first
boolean startConfigPortal();
boolean startConfigPortal(char const *apName, char const *apPassword = NULL);
boolean process();
// get the AP name of the config portal, so it can be used in the callback
String getConfigPortalSSID();
@@ -148,11 +149,13 @@ class WiFiManager
IPAddress _sta_static_gw;
IPAddress _sta_static_sn;
// option parameters
int _paramsCount = 0;
int _minimumQuality = -1;
boolean _removeDuplicateAPs = true;
boolean _shouldBreakAfterConfig = false;
boolean _tryWPS = false;
boolean _configPortalIsBlocking = false;
const char* _customHeadElement = "";
@@ -188,6 +191,7 @@ class WiFiManager
boolean validApPassword();
boolean connect;
boolean configPortalActive = false;
boolean _debug = true;
void (*_apcallback)(WiFiManager*) = NULL;