adds option to keep cfgp open on wifi save

// if true (default) then stop the config portal from autoConnect when wifi is saved
    void          setDisableConfigPortal(boolean enable);

Name will change
This commit is contained in:
tablatronix
2022-04-08 20:44:08 -05:00
parent 590e212ddb
commit 7bffda3fe6
2 changed files with 20 additions and 5 deletions
+14 -3
View File
@@ -727,7 +727,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
if(!_configPortalIsBlocking){
#ifdef WM_DEBUG_LEVEL
DEBUG_WM(DEBUG_VERBOSE,F("Config Portal Running, non blocking/processing"));
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; // skip blocking loop
@@ -850,7 +850,7 @@ uint8_t WiFiManager::processConfigPortal(){
_savewificallback();
}
if(!_connectonsave) return WL_IDLE_STATUS;
shutdownConfigPortal();
if(_disableConfigPortal) shutdownConfigPortal();
return WL_CONNECTED; // CONNECT SUCCESS
}
#ifdef WM_DEBUG_LEVEL
@@ -869,7 +869,7 @@ uint8_t WiFiManager::processConfigPortal(){
#endif
_savewificallback();
}
shutdownConfigPortal();
if(_disableConfigPortal) shutdownConfigPortal();
return WL_CONNECT_FAILED; // CONNECT FAIL
}
else if(_configPortalIsBlocking){
@@ -2899,6 +2899,17 @@ void WiFiManager::setEnableConfigPortal(boolean enable)
_enableConfigPortal = enable;
}
/**
* toggle configportal if autoconnect failed
* if enabled, then the configportal will be de-activated on wifi save
* @since $dev
* @access public
* @param boolean enabled [true]
*/
void WiFiManager::setDisableConfigPortal(boolean enable)
{
_disableConfigPortal = enable;
}
/**
* set the hostname (dhcp client id)
+6 -2
View File
@@ -333,7 +333,10 @@ class WiFiManager
// if true (default) then start the config portal from autoConnect if connection failed
void setEnableConfigPortal(boolean enable);
// if true (default) then stop the config portal from autoConnect when wifi is saved
void setDisableConfigPortal(boolean enable);
// set a custom hostname, sets sta and ap dhcp client id for esp32, and sta for esp8266
bool setHostname(const char * hostname);
bool setHostname(String hostname);
@@ -512,7 +515,8 @@ class WiFiManager
boolean _showInfoErase = true; // info page erase button
boolean _showInfoUpdate = true; // info page update button
boolean _showBack = false; // show back button
boolean _enableConfigPortal = true; // use config portal if autoconnect failed
boolean _enableConfigPortal = true; // FOR autoconnect - start config portal if autoconnect failed
boolean _disableConfigPortal = true; // FOR autoconnect - stop config portal if cp wifi save
String _hostname = ""; // hostname for esp8266 for dhcp, and or MDNS
const char* _customHeadElement = ""; // store custom head element html from user isnide <head>