Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow automatic config portal to be disabled #575

Merged
merged 1 commit into from
Mar 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion WiFiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
}
return true;
}

// possibly skip the config portal
if (!_enableConfigPortal) {
return false;
}

// not connected start configportal
return startConfigPortal(apName, apPassword);
}
Expand Down Expand Up @@ -1931,6 +1937,19 @@ void WiFiManager::setScanDispPerc(boolean enabled){
_scanDispOptions = enabled;
}

/**
* toggle configportal if autoconnect failed
* if enabled, then the configportal will be activated on autoconnect failure
* @since $dev
* @access public
* @param boolean enabled [true]
*/
void WiFiManager::setEnableConfigPortal(boolean enable)
{
_enableConfigPortal = enable;
}


/**
* set the hostname (dhcp client id)
* @since $dev
Expand Down Expand Up @@ -2313,4 +2332,4 @@ void WiFiManager::WiFi_autoReconnect(){
WiFi.onEvent(WiFiEvent);
}
#endif
}
}
3 changes: 3 additions & 0 deletions WiFiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class WiFiManager
void setWiFiAutoReconnect(boolean enabled);
// if true, wifiscan will show percentage instead of quality icons, until we have better templating
void setScanDispPerc(boolean enabled);
// if true (default) then start the config portal from autoConnect if connection failed
void setEnableConfigPortal(boolean enable);
// set a custom hostname, sets sta and ap dhcp client id for esp32, and sta for esp8266
bool setHostname(const char * hostname);
// show erase wifi onfig button on info page, true
Expand Down Expand Up @@ -292,6 +294,7 @@ class WiFiManager
boolean _scanDispOptions = false; // show percentage in scans not icons
boolean _paramsInWifi = true; // show custom parameters on wifi page
boolean _showInfoErase = true; // info page erase button
boolean _enableConfigPortal = true; // use config portal if autoconnect failed
const char * _hostname = "";

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