Skip to content

Commit 3ae0b40

Browse files
authored
Merge pull request #575 from liebman/allow_disable_portal
allow automatic config portal to be disabled
2 parents c9a7112 + 7495fe2 commit 3ae0b40

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

WiFiManager.cpp

+20-1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
259259
}
260260
return true;
261261
}
262+
263+
// possibly skip the config portal
264+
if (!_enableConfigPortal) {
265+
return false;
266+
}
267+
262268
// not connected start configportal
263269
return startConfigPortal(apName, apPassword);
264270
}
@@ -1931,6 +1937,19 @@ void WiFiManager::setScanDispPerc(boolean enabled){
19311937
_scanDispOptions = enabled;
19321938
}
19331939

1940+
/**
1941+
* toggle configportal if autoconnect failed
1942+
* if enabled, then the configportal will be activated on autoconnect failure
1943+
* @since $dev
1944+
* @access public
1945+
* @param boolean enabled [true]
1946+
*/
1947+
void WiFiManager::setEnableConfigPortal(boolean enable)
1948+
{
1949+
_enableConfigPortal = enable;
1950+
}
1951+
1952+
19341953
/**
19351954
* set the hostname (dhcp client id)
19361955
* @since $dev
@@ -2313,4 +2332,4 @@ void WiFiManager::WiFi_autoReconnect(){
23132332
WiFi.onEvent(WiFiEvent);
23142333
}
23152334
#endif
2316-
}
2335+
}

WiFiManager.h

+3
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ class WiFiManager
204204
void setWiFiAutoReconnect(boolean enabled);
205205
// if true, wifiscan will show percentage instead of quality icons, until we have better templating
206206
void setScanDispPerc(boolean enabled);
207+
// if true (default) then start the config portal from autoConnect if connection failed
208+
void setEnableConfigPortal(boolean enable);
207209
// set a custom hostname, sets sta and ap dhcp client id for esp32, and sta for esp8266
208210
bool setHostname(const char * hostname);
209211
// show erase wifi onfig button on info page, true
@@ -292,6 +294,7 @@ class WiFiManager
292294
boolean _scanDispOptions = false; // show percentage in scans not icons
293295
boolean _paramsInWifi = true; // show custom parameters on wifi page
294296
boolean _showInfoErase = true; // info page erase button
297+
boolean _enableConfigPortal = true; // use config portal if autoconnect failed
295298
const char * _hostname = "";
296299

297300
const char* _customHeadElement = ""; // store custom head element html from user

0 commit comments

Comments
 (0)