Skip to content

Commit 2b51657

Browse files
committed
VS Code format/whitespace only change
1 parent 26f48d8 commit 2b51657

File tree

1 file changed

+52
-37
lines changed

1 file changed

+52
-37
lines changed

Firmware/RTK_Surveyor/Form.ino

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,47 @@ Form.ino
1111

1212
bool websocketConnected = false;
1313

14-
class CaptiveRequestHandler : public AsyncWebHandler {
15-
public:
16-
//https://en.wikipedia.org/wiki/Captive_portal
17-
String urls[5] = {"/hotspot-detect.html", "/library/test/success.html", "/generate_204", "/ncsi.txt", "/check_network_status.txt"};
18-
CaptiveRequestHandler() {}
19-
virtual ~CaptiveRequestHandler() {}
20-
21-
bool canHandle(AsyncWebServerRequest *request){
22-
for(int i = 0; i<5; i++){
23-
if(request->url().equals(urls[i]))
24-
return true;
14+
class CaptiveRequestHandler : public AsyncWebHandler
15+
{
16+
public:
17+
// https://en.wikipedia.org/wiki/Captive_portal
18+
String urls[5] = {"/hotspot-detect.html", "/library/test/success.html", "/generate_204", "/ncsi.txt",
19+
"/check_network_status.txt"};
20+
CaptiveRequestHandler()
21+
{
22+
}
23+
virtual ~CaptiveRequestHandler()
24+
{
2525
}
26-
return false;
27-
}
2826

29-
//Provide a custom small site for redirecting the user to the config site
30-
//HTTP redirect does not work and the relative links on the default config site do not work, because the phone is requesting a different server
31-
void handleRequest(AsyncWebServerRequest *request) {
32-
String logmessage = "Captive Portal Client:" + request->client()->remoteIP().toString() + " " + request->url();
33-
systemPrintln(logmessage);
34-
AsyncResponseStream *response = request->beginResponseStream("text/html");
35-
response->print("<!DOCTYPE html><html><head><title>RTK Config</title></head><body>");
36-
response->print("<div class='container'>");
37-
response->printf("<div align='center' class='col-sm-12'><img src='http://%s/src/rtk-setup.png' alt='SparkFun RTK WiFi Setup'></div>", WiFi.softAPIP().toString().c_str());
38-
response->printf("<div align='center'><h3>Configure your RTK receiver <a href='http://%s/'>here</a></h3></div>", WiFi.softAPIP().toString().c_str());
39-
response->print("</div></body></html>");
40-
request->send(response);
41-
}
27+
bool canHandle(AsyncWebServerRequest *request)
28+
{
29+
for (int i = 0; i < 5; i++)
30+
{
31+
if (request->url().equals(urls[i]))
32+
return true;
33+
}
34+
return false;
35+
}
36+
37+
// Provide a custom small site for redirecting the user to the config site
38+
// HTTP redirect does not work and the relative links on the default config site do not work, because the phone is
39+
// requesting a different server
40+
void handleRequest(AsyncWebServerRequest *request)
41+
{
42+
String logmessage = "Captive Portal Client:" + request->client()->remoteIP().toString() + " " + request->url();
43+
systemPrintln(logmessage);
44+
AsyncResponseStream *response = request->beginResponseStream("text/html");
45+
response->print("<!DOCTYPE html><html><head><title>RTK Config</title></head><body>");
46+
response->print("<div class='container'>");
47+
response->printf("<div align='center' class='col-sm-12'><img src='http://%s/src/rtk-setup.png' alt='SparkFun "
48+
"RTK WiFi Setup'></div>",
49+
WiFi.softAPIP().toString().c_str());
50+
response->printf("<div align='center'><h3>Configure your RTK receiver <a href='http://%s/'>here</a></h3></div>",
51+
WiFi.softAPIP().toString().c_str());
52+
response->print("</div></body></html>");
53+
request->send(response);
54+
}
4255
};
4356

4457
// Start webserver in AP mode
@@ -92,7 +105,7 @@ bool startWebServer(bool startWiFi = true, int httpPort = 80)
92105
}
93106

94107
websocket->onEvent(onWsEvent);
95-
webserver->addHandler(new CaptiveRequestHandler()).setFilter(ON_AP_FILTER);//only when requested from AP
108+
webserver->addHandler(new CaptiveRequestHandler()).setFilter(ON_AP_FILTER); // only when requested from AP
96109
webserver->addHandler(websocket);
97110

98111
// * index.html (not gz'd)
@@ -122,7 +135,8 @@ bool startWebServer(bool startWiFi = true, int httpPort = 80)
122135
handleUpload); // Run handleUpload function when any file is uploaded. Must be before server.on() calls.
123136

124137
webserver->on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
125-
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", index_html, sizeof(index_html));
138+
AsyncWebServerResponse *response =
139+
request->beginResponse_P(200, "text/html", index_html, sizeof(index_html));
126140
response->addHeader("Content-Encoding", "gzip");
127141
request->send(response);
128142
});
@@ -135,8 +149,8 @@ bool startWebServer(bool startWiFi = true, int httpPort = 80)
135149
});
136150

137151
webserver->on("/src/bootstrap.bundle.min.js", HTTP_GET, [](AsyncWebServerRequest *request) {
138-
AsyncWebServerResponse *response =
139-
request->beginResponse_P(200, "text/javascript", bootstrap_bundle_min_js, sizeof(bootstrap_bundle_min_js));
152+
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/javascript", bootstrap_bundle_min_js,
153+
sizeof(bootstrap_bundle_min_js));
140154
response->addHeader("Content-Encoding", "gzip");
141155
request->send(response);
142156
});
@@ -163,7 +177,8 @@ bool startWebServer(bool startWiFi = true, int httpPort = 80)
163177
});
164178

165179
webserver->on("/src/main.js", HTTP_GET, [](AsyncWebServerRequest *request) {
166-
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/javascript", main_js, sizeof(main_js));
180+
AsyncWebServerResponse *response =
181+
request->beginResponse_P(200, "text/javascript", main_js, sizeof(main_js));
167182
response->addHeader("Content-Encoding", "gzip");
168183
request->send(response);
169184
});
@@ -380,7 +395,7 @@ static void handleFileManager(AsyncWebServerRequest *request)
380395
{
381396
fileExists = SD_MMC.exists(slashFileName);
382397
}
383-
#endif // COMPILE_SD_MMC
398+
#endif // COMPILE_SD_MMC
384399

385400
if (fileExists == false)
386401
{
@@ -458,7 +473,7 @@ static void handleFileManager(AsyncWebServerRequest *request)
458473
#ifdef COMPILE_SD_MMC
459474
else
460475
SD_MMC.remove(slashFileName);
461-
#endif // COMPILE_SD_MMC
476+
#endif // COMPILE_SD_MMC
462477
request->send(200, "text/plain", "Deleted File: " + String(fileName));
463478
}
464479
else
@@ -762,7 +777,7 @@ void createSettingsString(char *newSettings)
762777
#ifdef COMPILE_L_BAND
763778
int daysRemaining = daysFromEpoch(settings.pointPerfectNextKeyStart + settings.pointPerfectNextKeyDuration + 1);
764779
snprintf(apDaysRemaining, sizeof(apDaysRemaining), "%d", daysRemaining);
765-
#endif // COMPILE_L_BAND
780+
#endif // COMPILE_L_BAND
766781
}
767782
else
768783
snprintf(apDaysRemaining, sizeof(apDaysRemaining), "No Keys");
@@ -1377,7 +1392,7 @@ void updateSettingWithValue(const char *settingName, const char *settingValueStr
13771392
requestChangeState(STATE_ROVER_NOT_STARTED); // If update failed, return to Rover mode.
13781393
}
13791394
else if (strcmp(settingName, "factoryDefaultReset") == 0)
1380-
factoryReset(false); //We do not have the sdSemaphore
1395+
factoryReset(false); // We do not have the sdSemaphore
13811396
else if (strcmp(settingName, "exitAndReset") == 0)
13821397
{
13831398
// Confirm receipt
@@ -1792,7 +1807,7 @@ void getFileList(String &returnText)
17921807

17931808
root.close();
17941809
}
1795-
#endif // COMPILE_SD_MMC
1810+
#endif // COMPILE_SD_MMC
17961811

17971812
xSemaphoreGive(sdCardSemaphore);
17981813
}
@@ -1914,4 +1929,4 @@ void handleUpload(AsyncWebServerRequest *request, String filename, size_t index,
19141929
}
19151930
}
19161931

1917-
#endif // COMPILE_AP
1932+
#endif // COMPILE_AP

0 commit comments

Comments
 (0)