mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
supports stopConfigPortal if blocking , flag abort
This commit is contained in:
+19
-7
@@ -408,7 +408,7 @@ void WiFiManager::stopWebPortal() {
|
||||
if(!configPortalActive && !webPortalActive) return;
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("Stopping Web Portal"));
|
||||
webPortalActive = false;
|
||||
stopConfigPortal();
|
||||
shutdownConfigPortal();
|
||||
}
|
||||
|
||||
boolean WiFiManager::configPortalHasTimeout(){
|
||||
@@ -550,7 +550,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
|
||||
// if timed out or abort, break
|
||||
if(configPortalHasTimeout() || abort){
|
||||
DEBUG_WM(DEBUG_DEV,F("configportal abort"));
|
||||
stopConfigPortal();
|
||||
shutdownConfigPortal();
|
||||
result = abort ? portalAbortResult : portalTimeoutResult; // false, false
|
||||
break;
|
||||
}
|
||||
@@ -611,7 +611,7 @@ uint8_t WiFiManager::processConfigPortal(){
|
||||
if ( _savewificallback != NULL) {
|
||||
_savewificallback();
|
||||
}
|
||||
stopConfigPortal();
|
||||
shutdownConfigPortal();
|
||||
return WL_CONNECTED; // CONNECT SUCCESS
|
||||
}
|
||||
DEBUG_WM(DEBUG_ERROR,F("[ERROR] Connect to new AP Failed"));
|
||||
@@ -624,7 +624,7 @@ uint8_t WiFiManager::processConfigPortal(){
|
||||
if ( _savewificallback != NULL) {
|
||||
_savewificallback();
|
||||
}
|
||||
stopConfigPortal();
|
||||
shutdownConfigPortal();
|
||||
return WL_CONNECT_FAILED; // CONNECT FAIL
|
||||
}
|
||||
else{
|
||||
@@ -642,11 +642,11 @@ uint8_t WiFiManager::processConfigPortal(){
|
||||
}
|
||||
|
||||
/**
|
||||
* [stopConfigPortal description]
|
||||
* [shutdownConfigPortal description]
|
||||
* @access public
|
||||
* @return {[type]} [description]
|
||||
* @return bool success (softapdisconnect)
|
||||
*/
|
||||
boolean WiFiManager::stopConfigPortal(){
|
||||
bool WiFiManager::shutdownConfigPortal(){
|
||||
if(webPortalActive) return false;
|
||||
|
||||
//DNS handler
|
||||
@@ -1831,6 +1831,18 @@ void WiFiManager::reportStatus(String &page){
|
||||
* reset wifi settings, clean stored ap password
|
||||
*/
|
||||
|
||||
/**
|
||||
* [stopConfigPortal description]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
bool WiFiManager::stopConfigPortal(){
|
||||
if(_configPortalIsBlocking){
|
||||
abort = true;
|
||||
return true;
|
||||
}
|
||||
return shutdownConfigPortal();
|
||||
}
|
||||
|
||||
/**
|
||||
* disconnect
|
||||
* @access public
|
||||
|
||||
+3
-2
@@ -151,8 +151,8 @@ class WiFiManager
|
||||
boolean startConfigPortal(); // auto generates apname
|
||||
boolean startConfigPortal(char const *apName, char const *apPassword = NULL);
|
||||
|
||||
//manually stop the config portal if started manually
|
||||
boolean stopConfigPortal();
|
||||
//manually stop the config portal if started manually, stop immediatly if non blocking, flag abort if blocking
|
||||
bool stopConfigPortal();
|
||||
|
||||
//manually start the web portal, autoconnect does this automatically on connect failure
|
||||
void startWebPortal();
|
||||
@@ -367,6 +367,7 @@ class WiFiManager
|
||||
void _end();
|
||||
|
||||
void setupConfigPortal();
|
||||
bool shutdownConfigPortal();
|
||||
|
||||
#ifdef NO_EXTRA_4K_HEAP
|
||||
boolean _tryWPS = false; // try WPS on save failure, unsupported
|
||||
|
||||
@@ -28,6 +28,7 @@ void configModeCallback (WiFiManager *myWiFiManager) {
|
||||
|
||||
void saveParamCallback(){
|
||||
Serial.println("[CALLBACK] saveParamCallback fired");
|
||||
// wm.stopConfigPortal();
|
||||
}
|
||||
|
||||
void bindServerCallback(){
|
||||
@@ -93,7 +94,7 @@ void setup() {
|
||||
// wm.setMenu(menu,9); // custom menu array must provide length
|
||||
|
||||
std::vector<const char *> menu = {"wifi","wifinoscan","info","param","close","sep","erase","restart","exit"};
|
||||
// wm.setMenu(menu); // custom menu, pass vector
|
||||
wm.setMenu(menu); // custom menu, pass vector
|
||||
|
||||
// set static sta ip
|
||||
// wm.setSTAStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
|
||||
|
||||
Reference in New Issue
Block a user