Skip to content

Commit 68d1119

Browse files
committed
Add enableCaptivePortal setting. Set to on as default.
1 parent 4c18e36 commit 68d1119

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

Firmware/RTK_Surveyor/Form.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ bool startWebServer(bool startWiFi = true, int httpPort = 80)
104104
break;
105105
}
106106

107+
if(settings.enableCaptivePortal == true)
108+
webserver->addHandler(new CaptiveRequestHandler()).setFilter(ON_AP_FILTER); // only when requested from AP
109+
107110
websocket->onEvent(onWsEvent);
108-
webserver->addHandler(new CaptiveRequestHandler()).setFilter(ON_AP_FILTER); // only when requested from AP
109111
webserver->addHandler(websocket);
110112

111113
// * index.html (not gz'd)

Firmware/RTK_Surveyor/NVM.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ void recordSystemSettingsToFile(File *settingsFile)
445445
settingsFile->printf("%s=%d\r\n", "enableAutoFirmwareUpdate", settings.enableAutoFirmwareUpdate);
446446

447447
settingsFile->printf("%s=%d\r\n", "debugLBand", settings.debugLBand);
448+
settingsFile->printf("%s=%d\r\n", "enableCaptivePortal", settings.enableCaptivePortal);
448449

449450
//Add new settings above <------------------------------------------------------------>
450451
}
@@ -1369,6 +1370,10 @@ bool parseLine(char *str, Settings *settings)
13691370

13701371
else if (strcmp(settingName, "debugLBand") == 0)
13711372
settings->debugLBand = d;
1373+
else if (strcmp(settingName, "enableCaptivePortal") == 0)
1374+
settings->enableCaptivePortal = d;
1375+
1376+
13721377

13731378
//Add new settings above
13741379
//<------------------------------------------------------------>

Firmware/RTK_Surveyor/WiFi.ino

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ void menuWiFi()
8686
systemPrint("a) Configure device via WiFi Access Point or connect to WiFi: ");
8787
systemPrintf("%s\r\n", settings.wifiConfigOverAP ? "AP" : "WiFi");
8888

89+
systemPrint("m) Captive Portal: ");
90+
systemPrintf("%s\r\n", settings.enableCaptivePortal ? "Enabled" : "Disabled");
91+
8992
systemPrint("m) MDNS: ");
9093
systemPrintf("%s\r\n", settings.mdnsEnable ? "Enabled" : "Disabled");
9194

@@ -115,7 +118,10 @@ void menuWiFi()
115118
settings.wifiConfigOverAP ^= 1;
116119
restartWiFi = true;
117120
}
118-
121+
else if (incoming == 'c')
122+
{
123+
settings.enableCaptivePortal ^= 1;
124+
}
119125
else if (incoming == 'm')
120126
{
121127
settings.mdnsEnable ^= 1;
@@ -371,7 +377,7 @@ void wifiUpdate()
371377
}
372378

373379
// Process DNS when we are in AP mode for captive portal
374-
if (WiFi.getMode() == WIFI_AP)
380+
if (WiFi.getMode() == WIFI_AP && settings.enableCaptivePortal)
375381
{
376382
dnsServer.processNextRequest();
377383
}
@@ -416,7 +422,7 @@ void wifiStop()
416422
MDNS.end();
417423

418424
// Stop the DNS server if we were using the captive portal
419-
if (WiFi.getMode() == WIFI_AP)
425+
if (WiFi.getMode() == WIFI_AP && settings.enableCaptivePortal)
420426
dnsServer.stop();
421427

422428
// Stop the other network clients and then WiFi

Firmware/RTK_Surveyor/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,7 @@ typedef struct
10701070
uint32_t autoFirmwareCheckMinutes = 24 * 60;
10711071

10721072
bool debugLBand = false;
1073+
bool enableCaptivePortal = true;
10731074

10741075
//Add new settings above <------------------------------------------------------------>
10751076

0 commit comments

Comments
 (0)