mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-13 14:51:21 +10:00
ability to disable captiveportal
Sometimes the redirect to captive portal is unwanted or a nuisance, eg wehn using as a webserver etc.
This commit is contained in:
+7
-1
@@ -536,7 +536,7 @@ void WiFiManager::handleWifi(boolean scan) {
|
||||
|
||||
String WiFiManager::getScanItemOut(){
|
||||
String page;
|
||||
|
||||
|
||||
int n = WiFi.scanNetworks();
|
||||
DEBUG_WM(F("Scan done"));
|
||||
if (n == 0) {
|
||||
@@ -987,6 +987,9 @@ void WiFiManager::handleNotFound() {
|
||||
*/
|
||||
boolean WiFiManager::captivePortal() {
|
||||
DEBUG_WM(server->hostHeader());
|
||||
|
||||
if(!_enableCaptivePortal) return true; // skip redirections
|
||||
|
||||
if (!isIp(server->hostHeader())) {
|
||||
DEBUG_WM(F("Request redirected to captive portal"));
|
||||
server->sendHeader("Location", String("http://") + toStringIp(server->client().localIP()), true);
|
||||
@@ -1034,6 +1037,9 @@ void WiFiManager::setShowStaticFields(boolean alwaysShow){
|
||||
_sta_show_static_fields = alwaysShow;
|
||||
}
|
||||
|
||||
void WiFiManager::setCaptivePortalEnable(boolean enabled){
|
||||
_enableCaptivePortal = enabled;
|
||||
}
|
||||
|
||||
// HELPERS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user