Skip to content

Commit 946d317

Browse files
committed
Change AP config to 'Exit and Reboot'. Catch JS error for unknown IDs..
1 parent f248daf commit 946d317

File tree

9 files changed

+112
-77
lines changed

9 files changed

+112
-77
lines changed

Firmware/RTK_Surveyor/AP-Config/index.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<body>
7272

7373
<div class="container" style="display:none; margin-top:20px;max-width:600px;" id="exitPage">
74-
<b>Done</b><br><br>RTK device is now in Rover mode.
74+
<b>Done</b><br><br>RTK device is now rebooting.
7575
</div>
7676

7777
<div class="container" style="margin-top:20px;max-width:600px;" id="mainPage">
@@ -864,7 +864,7 @@ <h2>
864864
<label class="form-check-label" for="enableNtripServer">Enable NTRIP Server</label>
865865
<input class="form-check-input" type="checkbox" value="" id="enableNtripServer">
866866
<span class="tt" data-bs-placement="right"
867-
title="Once a base station is outputting correction data it can be pushed to an NTRIP caster via local Wifi. Other devices can access the correction stream using an NTRIP client. Default: Disabled.">
867+
title="Use this NTRIP server to upload the base's correction data to a casting service. Other devices can then access the correction data using an NTRIP client. Default: Disabled.">
868868
<span class="icon-info-circle text-primary ms-2"></span>
869869
</span>
870870
</div>
@@ -905,20 +905,20 @@ <h2>
905905
</div>
906906

907907
<div class="form-group row">
908-
<label for="mountPoint" class="box-margin20 col-sm-3 col-5 col-form-label">Mount
908+
<label for="mountPointUpload" class="box-margin20 col-sm-3 col-5 col-form-label">Mount
909909
Point:</label>
910910
<div class="col-sm-8 col-6">
911-
<input type="text" class="form-control" id="mountPoint">
912-
<p id="mountPointError" class="inlineError"></p>
911+
<input type="text" class="form-control" id="mountPointUpload">
912+
<p id="mountPointUploadError" class="inlineError"></p>
913913
</div>
914914
</div>
915915

916916
<div class="form-group row">
917-
<label for="mountPointPW" class="box-margin20 col-sm-4 col-6 col-form-label">Mount Point
917+
<label for="mountPointUploadPW" class="box-margin20 col-sm-4 col-6 col-form-label">Mount Point
918918
PW:</label>
919919
<div class="col-sm-7 col-5">
920-
<input type="text" class="form-control" id="mountPointPW">
921-
<p id="mountPointPWError" class="inlineError"></p>
920+
<input type="text" class="form-control" id="mountPointUploadPW">
921+
<p id="mountPointUploadPWError" class="inlineError"></p>
922922
</div>
923923
</div>
924924
</div>
@@ -1160,8 +1160,7 @@ <h2>
11601160
<p id="saveBtnSuccess" class="inlineSuccess"></p>
11611161
</div>
11621162
<div align="center" class="col-sm-5 col-12">
1163-
<button type="button" id="exitBtn" class="btn btn-outline-secondary" onclick="exitConfig()">Exit to
1164-
Rover Mode <span class="icon-remove text-secondary ms-1"></span></button>
1163+
<button type="button" id="exitBtn" class="btn btn-outline-secondary" onclick="exitConfig()">Exit and Reset<span class="icon-remove text-secondary ms-1"></span></button>
11651164
<p id="exitBtnError" class="inlineSuccess"></p>
11661165
<p>&nbsp;</p>
11671166
</div>

Firmware/RTK_Surveyor/AP-Config/src/main.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,18 @@ function parseIncoming(msg) {
9797

9898
//Check boxes / radio buttons
9999
else if (val == "true") {
100-
ge(id).checked = true;
100+
try {
101+
ge(id).checked = true;
102+
} catch (error) {
103+
console.log("Issue with ID: " + id)
104+
}
101105
}
102106
else if (val == "false") {
103-
ge(id).checked = false;
107+
try {
108+
ge(id).checked = false;
109+
} catch (error) {
110+
console.log("Issue with ID: " + id)
111+
}
104112
}
105113

106114
//All regular input boxes and values
@@ -310,8 +318,8 @@ function validateFields() {
310318
checkElementString("wifiPW", 0, 30, "Must be 0 to 30 characters", "collapseBaseConfig");
311319
checkElementString("casterHost", 1, 30, "Must be 1 to 30 characters", "collapseBaseConfig");
312320
checkElementValue("casterPort", 1, 99999, "Must be 1 to 99999", "collapseBaseConfig");
313-
checkElementString("mountPoint", 1, 30, "Must be 1 to 30 characters", "collapseBaseConfig");
314-
checkElementString("mountPointPW", 1, 30, "Must be 1 to 30 characters", "collapseBaseConfig");
321+
checkElementString("mountPointUpload", 1, 30, "Must be 1 to 30 characters", "collapseBaseConfig");
322+
checkElementString("mountPointUploadPW", 1, 30, "Must be 1 to 30 characters", "collapseBaseConfig");
315323

316324
//System Config
317325
checkElementValue("maxLogTime_minutes", 1, 2880, "Must be 1 to 2880", "collapseSystemConfig");
@@ -617,17 +625,17 @@ document.addEventListener("DOMContentLoaded", (event) => {
617625
ge("wifiPW").disabled = false;
618626
ge("casterHost").disabled = false;
619627
ge("casterPort").disabled = false;
620-
ge("mountPoint").disabled = false;
621-
ge("mountPointPW").disabled = false;
628+
ge("mountPointUpload").disabled = false;
629+
ge("mountPointUploadPW").disabled = false;
622630
}
623631
else {
624632
//Disable NTRIP inputs
625633
ge("wifiSSID").disabled = true;
626634
ge("wifiPW").disabled = true;
627635
ge("casterHost").disabled = true;
628636
ge("casterPort").disabled = true;
629-
ge("mountPoint").disabled = true;
630-
ge("mountPointPW").disabled = true;
637+
ge("mountPointUpload").disabled = true;
638+
ge("mountPointUploadPW").disabled = true;
631639
}
632640
});
633641

Firmware/RTK_Surveyor/Form.ino

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@ void createSettingsString(char* settingsCSV)
306306
stringRecord(settingsCSV, "baseTypeFixed", settings.fixedBase);
307307
stringRecord(settingsCSV, "observationSeconds", settings.observationSeconds);
308308
stringRecord(settingsCSV, "observationPositionAccuracy", settings.observationPositionAccuracy, 2);
309-
stringRecord(settingsCSV, "fixedBaseCoordinateTypeECEF", settings.fixedBaseCoordinateType);
309+
stringRecord(settingsCSV, "fixedBaseCoordinateTypeECEF", !settings.fixedBaseCoordinateType); //COORD_TYPE_ECEF = 0
310310
stringRecord(settingsCSV, "fixedEcefX", settings.fixedEcefX, 3);
311311
stringRecord(settingsCSV, "fixedEcefY", settings.fixedEcefY, 3);
312312
stringRecord(settingsCSV, "fixedEcefZ", settings.fixedEcefZ, 3);
313-
stringRecord(settingsCSV, "fixedBaseCoordinateTypeGeo", !settings.fixedBaseCoordinateType);
313+
stringRecord(settingsCSV, "fixedBaseCoordinateTypeGeo", settings.fixedBaseCoordinateType);
314314
stringRecord(settingsCSV, "fixedLat", settings.fixedLat, 9);
315315
stringRecord(settingsCSV, "fixedLong", settings.fixedLong, 9);
316316
stringRecord(settingsCSV, "fixedAltitude", settings.fixedAltitude, 4);
@@ -321,9 +321,9 @@ void createSettingsString(char* settingsCSV)
321321
stringRecord(settingsCSV, "casterUser", settings.casterUser);
322322
stringRecord(settingsCSV, "casterUserPW", settings.casterUserPW);
323323
stringRecord(settingsCSV, "mountPointUpload", settings.mountPointUpload);
324-
stringRecord(settingsCSV, "mountPointPWUpload", settings.mountPointPWUpload);
324+
stringRecord(settingsCSV, "mountPointUploadPW", settings.mountPointUploadPW);
325325
stringRecord(settingsCSV, "mountPointDownload", settings.mountPointDownload);
326-
stringRecord(settingsCSV, "mountPointPWDownload", settings.mountPointPWDownload);
326+
stringRecord(settingsCSV, "mountPointDownloadPW", settings.mountPointDownloadPW);
327327
stringRecord(settingsCSV, "casterTransmitGGA", settings.casterTransmitGGA);
328328
stringRecord(settingsCSV, "wifiSSID", settings.wifiSSID);
329329
stringRecord(settingsCSV, "wifiPW", settings.wifiPW);
@@ -362,6 +362,13 @@ void createSettingsString(char* settingsCSV)
362362

363363
strcat(settingsCSV, "\0");
364364
Serial.printf("settingsCSV len: %d\n\r", strlen(settingsCSV));
365+
366+
//Upon AP load, Survey In is always checked.
367+
//Sometimes, (perhaps if fixed should be checked) fixed area is left enabled. Check main.js for correct disable of baseTypeFixed if fixedBase = false
368+
369+
370+
//Is baseTypeSurveyIn 1 or 0
371+
Serial.printf("settingsCSV: %s\n\r", settingsCSV);
365372
}
366373

367374
//Given a settingName, and string value, update a given setting
@@ -415,12 +422,12 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
415422
strcpy(settings.casterUserPW, settingValueStr);
416423
else if (strcmp(settingName, "mountPointUpload") == 0)
417424
strcpy(settings.mountPointUpload, settingValueStr);
418-
else if (strcmp(settingName, "mountPointPWUpload") == 0)
419-
strcpy(settings.mountPointPWUpload, settingValueStr);
425+
else if (strcmp(settingName, "mountPointUploadPW") == 0)
426+
strcpy(settings.mountPointUploadPW, settingValueStr);
420427
else if (strcmp(settingName, "mountPointDownload") == 0)
421428
strcpy(settings.mountPointDownload, settingValueStr);
422-
else if (strcmp(settingName, "mountPointPWDownload") == 0)
423-
strcpy(settings.mountPointPWDownload, settingValueStr);
429+
else if (strcmp(settingName, "mountPointDownloadPW") == 0)
430+
strcpy(settings.mountPointDownloadPW, settingValueStr);
424431
else if (strcmp(settingName, "casterTransmitGGA") == 0)
425432
settings.casterTransmitGGA = settingValueBool;
426433
else if (strcmp(settingName, "wifiSSID") == 0)
@@ -455,7 +462,10 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
455462
else if (strcmp(settingName, "factoryDefaultReset") == 0)
456463
factoryReset();
457464
else if (strcmp(settingName, "exitToRoverMode") == 0)
458-
requestChangeState(STATE_ROVER_NOT_STARTED);
465+
{
466+
ESP.restart();
467+
//requestChangeState(STATE_ROVER_NOT_STARTED);
468+
}
459469

460470
//Check for bulk settings (constellations and message rates)
461471
//Must be last on else list
@@ -555,22 +565,36 @@ void stringRecord(char* settingsCSV, const char *id, char* settingValue)
555565
}
556566

557567
//Break CSV into setting constituents
568+
//Can't use strtok because we may have two commas next to each other, ie measurementRateHz,4.00,measurementRateSec,,dynamicModel,0,
558569
bool parseIncomingSettings()
559570
{
560-
char settingName[50];
561-
char valueStr[50]; //firmwareFileName,RTK_Surveyor_Firmware_v14.bin,
562-
char *ptr = strtok(incomingSettings, ","); //measurementRateHz,2.00,
563-
for (int x = 0 ; ptr != NULL ; x++)
571+
char settingName[50] = {'\0'};
572+
char valueStr[50] = {'\0'}; //firmwareFileName,RTK_Surveyor_Firmware_v14.bin,
573+
574+
char* commaPtr = incomingSettings;
575+
char* headPtr = incomingSettings;
576+
while (*headPtr) //Check if string is over
564577
{
565-
strcpy(settingName, ptr);
566-
ptr = strtok(NULL, ","); //Move to next comma
567-
if (ptr == NULL) break;
578+
//Spin to first comma
579+
commaPtr = strstr(headPtr, ",");
580+
if (commaPtr != NULL) {
581+
*commaPtr = '\0';
582+
strcpy(settingName, headPtr);
583+
headPtr = commaPtr + 1;
584+
}
585+
586+
commaPtr = strstr(headPtr, ",");
587+
if (commaPtr != NULL) {
588+
*commaPtr = '\0';
589+
strcpy(valueStr, headPtr);
590+
headPtr = commaPtr + 1;
591+
}
568592

569-
strcpy(valueStr, ptr);
570-
ptr = strtok(NULL, ","); //Move to next comma
593+
Serial.printf("settingName: %s value: %s\n\r", settingName, valueStr);
571594

572-
//Serial.printf("settingName: %s value: %s\n\r", settingName, valueStr);
573-
updateSettingWithValue(settingName, valueStr);
595+
//Ignore zero length values (measurementRateSec) received from browser
596+
if (strlen(valueStr) > 0)
597+
updateSettingWithValue(settingName, valueStr);
574598
}
575599

576600
return (true);

Firmware/RTK_Surveyor/NVM.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ void recordSystemSettingsToFile()
155155
settingsFile.println("casterUser=" + (String)settings.casterUser);
156156
settingsFile.println("casterUserPW=" + (String)settings.casterUserPW);
157157
settingsFile.println("mountPointUpload=" + (String)settings.mountPointUpload);
158-
settingsFile.println("mountPointPWUpload=" + (String)settings.mountPointPWUpload);
158+
settingsFile.println("mountPointUploadPW=" + (String)settings.mountPointUploadPW);
159159
settingsFile.println("mountPointDownload=" + (String)settings.mountPointDownload);
160-
settingsFile.println("mountPointPWDownload=" + (String)settings.mountPointPWDownload);
160+
settingsFile.println("mountPointDownloadPW=" + (String)settings.mountPointDownloadPW);
161161
settingsFile.println("casterTransmitGGA=" + (String)settings.casterTransmitGGA);
162162
settingsFile.println("wifiSSID=" + (String)settings.wifiSSID);
163163
settingsFile.println("wifiPW=" + (String)settings.wifiPW);
@@ -404,12 +404,12 @@ bool parseLine(char* str) {
404404
strcpy(settings.casterUserPW, settingValue);
405405
else if (strcmp(settingName, "mountPointUpload") == 0)
406406
strcpy(settings.mountPointUpload, settingValue);
407-
else if (strcmp(settingName, "mountPointPWUpload") == 0)
408-
strcpy(settings.mountPointPWUpload, settingValue);
407+
else if (strcmp(settingName, "mountPointUploadPW") == 0)
408+
strcpy(settings.mountPointUploadPW, settingValue);
409409
else if (strcmp(settingName, "mountPointDownload") == 0)
410410
strcpy(settings.mountPointDownload, settingValue);
411-
else if (strcmp(settingName, "mountPointPWDownload") == 0)
412-
strcpy(settings.mountPointPWDownload, settingValue);
411+
else if (strcmp(settingName, "mountPointDownloadPW") == 0)
412+
strcpy(settings.mountPointDownloadPW, settingValue);
413413
else if (strcmp(settingName, "casterTransmitGGA") == 0)
414414
settings.casterTransmitGGA = d;
415415
else if (strcmp(settingName, "wifiSSID") == 0)

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const int FIRMWARE_VERSION_MAJOR = 1;
5151
const int FIRMWARE_VERSION_MINOR = 10;
5252

5353
#define COMPILE_WIFI //Comment out to remove all WiFi functionality
54-
//#define COMPILE_BT //Comment out to disable all Bluetooth
54+
#define COMPILE_BT //Comment out to disable all Bluetooth
5555
#define ENABLE_DEVELOPER //Uncomment this line to enable special developer modes (don't check power button at startup)
5656

5757
//Define the RTK board identifier:
@@ -307,7 +307,7 @@ AsyncWebSocket ws("/ws");
307307

308308
//Because the incoming string is longer than max len, there are multiple callbacks so we
309309
//use a global to combine the incoming
310-
char incomingSettings[2000];
310+
char incomingSettings[3000];
311311
int incomingSettingsSpot = 0;
312312
unsigned long timeSinceLastIncomingSetting = 0;
313313
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Firmware/RTK_Surveyor/States.ino

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void updateSystemState()
5454
startUART2Tasks(); //Start monitoring the UART1 from ZED for NMEA and UBX data (enables logging)
5555

5656
settings.lastState = STATE_ROVER_NOT_STARTED;
57-
recordSystemSettings();
57+
recordSystemSettings(); //Record this state for next POR
5858

5959
displayRoverSuccess(500);
6060

@@ -128,7 +128,7 @@ void updateSystemState()
128128
if (configureUbloxModuleBase() == true)
129129
{
130130
settings.lastState = STATE_BASE_NOT_STARTED; //Record this state for next POR
131-
recordSystemSettings();
131+
recordSystemSettings(); //Record this state for next POR
132132

133133
displayBaseSuccess(500); //Show 'Base Started'
134134

@@ -303,7 +303,7 @@ void updateSystemState()
303303
char serverBuffer[SERVER_BUFFER_SIZE];
304304

305305
snprintf(serverBuffer, SERVER_BUFFER_SIZE, "SOURCE %s /%s\r\nSource-Agent: NTRIP SparkFun_RTK_%s/v%d.%d\r\n\r\n",
306-
settings.mountPointPWUpload, settings.mountPointUpload, platformPrefix, FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR);
306+
settings.mountPointUploadPW, settings.mountPointUpload, platformPrefix, FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR);
307307

308308
//Serial.printf("Sending credentials:\n%s\n\r", serverBuffer);
309309
caster.write(serverBuffer, strlen(serverBuffer));
@@ -477,7 +477,7 @@ void updateSystemState()
477477
char serverBuffer[SERVER_BUFFER_SIZE];
478478

479479
snprintf(serverBuffer, SERVER_BUFFER_SIZE, "SOURCE %s /%s\r\nSource-Agent: NTRIP SparkFun_RTK_%s/v%d.%d\r\n\r\n",
480-
settings.mountPointPWUpload, settings.mountPointUpload, platformPrefix, FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR);
480+
settings.mountPointUploadPW, settings.mountPointUpload, platformPrefix, FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR);
481481

482482
//Serial.printf("Sending credentials:\n%s\n\r", serverBuffer);
483483
caster.write(serverBuffer, strlen(serverBuffer));
@@ -627,6 +627,7 @@ void updateSystemState()
627627
Serial.println();
628628

629629
parseIncomingSettings();
630+
recordSystemSettings(); //Record these settings to unit
630631

631632
//Clear buffer
632633
incomingSettingsSpot = 0;
@@ -643,7 +644,7 @@ void updateSystemState()
643644
if (millis() - lastTestMenuChange > 500)
644645
{
645646
zedUartPassed = false;
646-
647+
647648
//Enable RTCM 1230. This is the GLONASS bias sentence and is transmitted
648649
//even if there is no GPS fix. We use it to test serial output.
649650
i2cGNSS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_UART2, 1); //Enable message every second
@@ -689,10 +690,6 @@ void requestChangeState(SystemState requestedState)
689690
//Change states and print the new state
690691
void changeState(SystemState newState)
691692
{
692-
//If we are leaving WiFi config, record and implement settings
693-
if (systemState == STATE_WIFI_CONFIG)
694-
recordSystemSettings(); //Record the new settings to EEPROM and config file
695-
696693
systemState = newState;
697694

698695
//Debug print

0 commit comments

Comments
 (0)