Skip to content

Commit 6190c94

Browse files
committed
Record system settings when new data is received over AP config.
Previously, the user could hit buttons fast enough to cause data + a reset to hit at the same time.
1 parent c2c2a87 commit 6190c94

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ function resetToLoggingDefaults() {
499499
function exitConfig() {
500500
show("exitPage");
501501
hide("mainPage");
502-
ws.send("exitToRoverMode,1,");
502+
ws.send("exitAndReset,1,");
503503
}
504504

505505
function firmwareUploadWait() {

Firmware/RTK_Surveyor/Form.ino

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,10 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
381381
if (strcmp(settingValueStr, "true") == 0) settingValueBool = true;
382382

383383
if (strcmp(settingName, "maxLogTime_minutes") == 0)
384+
{
385+
newAPSettings = true; //Mark settings as new to force record before reset
384386
settings.maxLogTime_minutes = settingValue;
387+
}
385388
else if (strcmp(settingName, "measurementRateHz") == 0)
386389
settings.measurementRate = (int)(1000.0 / settingValue);
387390
else if (strcmp(settingName, "dynamicModel") == 0)
@@ -457,14 +460,18 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
457460
else if (strcmp(settingName, "firmwareFileName") == 0)
458461
{
459462
updateFromSD(settingValueStr);
463+
464+
//If update is successful, it will force system reset and not get here.
465+
460466
requestChangeState(STATE_ROVER_NOT_STARTED); //If update failed, return to Rover mode.
461467
}
462468
else if (strcmp(settingName, "factoryDefaultReset") == 0)
463469
factoryReset();
464-
else if (strcmp(settingName, "exitToRoverMode") == 0)
470+
else if (strcmp(settingName, "exitAndReset") == 0)
465471
{
472+
if(newAPSettings == true) recordSystemSettings(); //If we've recieved settings, record before restart
473+
466474
ESP.restart();
467-
//requestChangeState(STATE_ROVER_NOT_STARTED);
468475
}
469476

470477
//Check for bulk settings (constellations and message rates)
@@ -590,7 +597,7 @@ bool parseIncomingSettings()
590597
headPtr = commaPtr + 1;
591598
}
592599

593-
Serial.printf("settingName: %s value: %s\n\r", settingName, valueStr);
600+
//Serial.printf("settingName: %s value: %s\n\r", settingName, valueStr);
594601

595602
//Ignore zero length values (measurementRateSec) received from browser
596603
if (strlen(valueStr) > 0)

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ char ggaSentence[128] = {0};
395395
byte ggaSentenceSpot = 0;
396396
int ggaSentenceEndSpot = 0;
397397

398+
bool newAPSettings = false; //Goes true when new setting is received via AP config. Allows us to record settings when combined with a reset.
399+
398400
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
399401

400402
void setup()

Firmware/RTK_Surveyor/form.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ function resetToLoggingDefaults() {
522522
function exitConfig() {
523523
show("exitPage");
524524
hide("mainPage");
525-
ws.send("exitToRoverMode,1,");
525+
ws.send("exitAndReset,1,");
526526
}
527527

528528
function firmwareUploadWait() {

Firmware/RTK_Surveyor/settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ typedef enum
8383
CUSTOM_NMEA_TYPE_RESET_REASON = 0,
8484
CUSTOM_NMEA_TYPE_WAYPOINT,
8585
CUSTOM_NMEA_TYPE_EVENT,
86+
CUSTOM_NMEA_TYPE_SYSTEM_VERSION,
87+
CUSTOM_NMEA_TYPE_ZED_VERSION,
8688
} customNmeaType_e;
8789

8890
//Freeze and blink LEDs if we hit a bad error

0 commit comments

Comments
 (0)