reset configportal timeouts after ap disconnect

configportaltimeout now starts at configportalstart if no sta clients,
or after last client disconnects. Will never timeout if ap has sta
client! handle edge case in user code.
This commit is contained in:
Shawn A
2017-02-08 10:34:41 -06:00
parent 0ddb835072
commit c810633ee3
2 changed files with 11 additions and 5 deletions
+10 -5
View File
@@ -157,6 +157,14 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
return startConfigPortal(apName, apPassword);
}
boolean WiFiManager::configPortalHasTimeout(){
if(_configPortalTimeout == 0 || wifi_softap_get_station_num() > 0){
_configPortalStart = millis(); // kludge, bump configportal start time to skew timeouts
return false;
}
return (millis() > _configPortalStart + _configPortalTimeout);
}
boolean WiFiManager::startConfigPortal() {
String ssid = "ESP" + String(ESP.getChipId());
return startConfigPortal(ssid.c_str(), NULL);
@@ -180,11 +188,8 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
while(1){
// do timeout if configPortalTimeout set and ap does not have client
if(_configPortalTimeout!= 0
&& millis() > _configPortalStart + _configPortalTimeout
&& wifi_softap_get_station_num() == 0
) break;
// check if timeout
if(configPortalHasTimeout()) break;
//DNS
dnsServer->processNextRequest();
+1
View File
@@ -160,6 +160,7 @@ class WiFiManager
void handleNotFound();
void handle204();
boolean captivePortal();
boolean configPortalHasTimeout();
// DNS server
const byte DNS_PORT = 53;