Skip to content

Commit c616989

Browse files
committed
Properly bring ubxMsg and ubxConstellation arrays into settings/NVM. Add ESF keys.
1 parent b79c91d commit c616989

File tree

9 files changed

+170
-207
lines changed

9 files changed

+170
-207
lines changed

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void beginBoard()
3838

3939
//Bug in ZED-F9P v1.13 firmware causes RTK LED to not light when RTK Floating with SBAS on.
4040
//The following changes the POR default but will be overwritten by settings in NVM or settings file
41-
ubxConstellations[1].enabled = false;
41+
settings.ubxConstellations[1].enabled = false;
4242

4343
strcpy(platformFilePrefix, "SFE_Surveyor");
4444
strcpy(platformPrefix, "Surveyor");

Firmware/RTK_Surveyor/Form.ino

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ void createSettingsString(char* settingsCSV)
243243
//GNSS Config
244244
stringRecord(settingsCSV, "measurementRateHz", 1000.0 / settings.measurementRate, 2); //2 = decimals to print
245245
stringRecord(settingsCSV, "dynamicModel", settings.dynamicModel);
246-
stringRecord(settingsCSV, "ubxConstellationsGPS", ubxConstellations[0].enabled); //GPS
247-
stringRecord(settingsCSV, "ubxConstellationsSBAS", ubxConstellations[1].enabled); //SBAS
248-
stringRecord(settingsCSV, "ubxConstellationsGalileo", ubxConstellations[2].enabled); //Galileo
249-
stringRecord(settingsCSV, "ubxConstellationsBeiDou", ubxConstellations[3].enabled); //BeiDou
250-
stringRecord(settingsCSV, "ubxConstellationsGLONASS", ubxConstellations[5].enabled); //GLONASS
246+
stringRecord(settingsCSV, "ubxConstellationsGPS", settings.ubxConstellations[0].enabled); //GPS
247+
stringRecord(settingsCSV, "ubxConstellationsSBAS", settings.ubxConstellations[1].enabled); //SBAS
248+
stringRecord(settingsCSV, "ubxConstellationsGalileo", settings.ubxConstellations[2].enabled); //Galileo
249+
stringRecord(settingsCSV, "ubxConstellationsBeiDou", settings.ubxConstellations[3].enabled); //BeiDou
250+
stringRecord(settingsCSV, "ubxConstellationsGLONASS", settings.ubxConstellations[5].enabled); //GLONASS
251251
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
252-
stringRecord(settingsCSV, ubxMessages[x].msgTextName, ubxMessages[x].msgRate);
252+
stringRecord(settingsCSV, settings.ubxMessages[x].msgTextName, settings.ubxMessages[x].msgRate);
253253

254254
//Base Config
255255
stringRecord(settingsCSV, "baseTypeSurveyIn", !settings.fixedBase);
@@ -394,11 +394,11 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
394394
for (int x = 0 ; x < MAX_CONSTELLATIONS ; x++)
395395
{
396396
char tempString[50]; //ubxConstellationsSBAS
397-
sprintf(tempString, "ubxConstellations%s", ubxConstellations[x].textName);
397+
sprintf(tempString, "ubxConstellations%s", settings.ubxConstellations[x].textName);
398398

399399
if (strcmp(settingName, tempString) == 0)
400400
{
401-
ubxConstellations[x].enabled = settingValueBool;
401+
settings.ubxConstellations[x].enabled = settingValueBool;
402402
knownSetting = true;
403403
break;
404404
}
@@ -410,9 +410,9 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
410410
{
411411
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
412412
{
413-
if (strcmp(settingName, ubxMessages[x].msgTextName) == 0)
413+
if (strcmp(settingName, settings.ubxMessages[x].msgTextName) == 0)
414414
{
415-
ubxMessages[x].msgRate = settingValue;
415+
settings.ubxMessages[x].msgRate = settingValue;
416416
knownSetting = true;
417417
break;
418418
}

Firmware/RTK_Surveyor/NVM.ino

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ void loadSettingsPartial()
6060
//Check to see if EEPROM is blank
6161
uint32_t testRead = 0;
6262
if (EEPROM.get(0, testRead) == 0xFFFFFFFF)
63+
{
64+
ESP_LOGD(TAG, "EEPROM is blank");
6365
return; //EEPROM is blank, assume default settings
66+
}
6467

6568
EEPROM.get(0, settings); //Read current settings
6669
}
@@ -172,15 +175,15 @@ void recordSystemSettingsToFile()
172175
for (int x = 0 ; x < MAX_CONSTELLATIONS ; x++)
173176
{
174177
char tempString[50]; //constellation.BeiDou=1
175-
sprintf(tempString, "constellation.%s=%d", ubxConstellations[x].textName, ubxConstellations[x].enabled);
178+
sprintf(tempString, "constellation.%s=%d", settings.ubxConstellations[x].textName, settings.ubxConstellations[x].enabled);
176179
settingsFile.println(tempString);
177180
}
178181

179182
//Record message settings
180183
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
181184
{
182185
char tempString[50]; //message.nmea_dtm.msgRate=5
183-
sprintf(tempString, "message.%s.msgRate=%d", ubxMessages[x].msgTextName, ubxMessages[x].msgRate);
186+
sprintf(tempString, "message.%s.msgRate=%d", settings.ubxMessages[x].msgTextName, settings.ubxMessages[x].msgRate);
184187
settingsFile.println(tempString);
185188
}
186189

@@ -448,11 +451,11 @@ bool parseLine(char* str) {
448451
for (int x = 0 ; x < MAX_CONSTELLATIONS ; x++)
449452
{
450453
char tempString[50]; //constellation.GPS=1
451-
sprintf(tempString, "constellation.%s", ubxConstellations[x].textName);
454+
sprintf(tempString, "constellation.%s", settings.ubxConstellations[x].textName);
452455

453456
if (strcmp(settingName, tempString) == 0)
454457
{
455-
ubxConstellations[x].enabled = d;
458+
settings.ubxConstellations[x].enabled = d;
456459
knownSetting = true;
457460
break;
458461
}
@@ -465,11 +468,11 @@ bool parseLine(char* str) {
465468
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
466469
{
467470
char tempString[50]; //message.nmea_dtm.msgRate=5
468-
sprintf(tempString, "message.%s.msgRate", ubxMessages[x].msgTextName);
471+
sprintf(tempString, "message.%s.msgRate", settings.ubxMessages[x].msgTextName);
469472

470473
if (strcmp(settingName, tempString) == 0)
471474
{
472-
ubxMessages[x].msgRate = d;
475+
settings.ubxMessages[x].msgRate = d;
473476
knownSetting = true;
474477
break;
475478
}
@@ -489,6 +492,11 @@ bool parseLine(char* str) {
489492
//ESP32 doesn't have erase command so we do it here
490493
void eepromErase()
491494
{
495+
if(online.eeprom == false)
496+
{
497+
ESP_LOGD(TAG, "Error: EEPROM not online");
498+
return;
499+
}
492500
for (int i = 0 ; i < EEPROM_SIZE ; i++) {
493501
EEPROM.write(i, 0xFF); //Reset to all 1s
494502
}

Firmware/RTK_Surveyor/Rover.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ bool configureUbloxModuleRover()
3535
}
3636

3737
//Re-enable any RTCM msgs on UART1 the user has set within settings
38-
response &= configureGNSSMessageRates(COM_PORT_UART1, ubxMessages); //Make sure the appropriate messages are enabled
38+
response &= configureGNSSMessageRates(COM_PORT_UART1, settings.ubxMessages); //Make sure the appropriate messages are enabled
3939

4040
if (response == false)
4141
Serial.println(F("Disable RTCM failed"));

Firmware/RTK_Surveyor/System.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ bool configureUbloxModule()
218218

219219
response &= configureConstellations(); //Enable the constellations the user has set
220220

221-
response &= configureGNSSMessageRates(COM_PORT_UART1, ubxMessages); //Make sure the appropriate messages are enabled
221+
response &= configureGNSSMessageRates(COM_PORT_UART1, settings.ubxMessages); //Make sure the appropriate messages are enabled
222222

223223
response &= i2cGNSS.setAutoPVT(true, false); //Tell the GPS to "send" each solution, but do not update stale data when accessed
224224
response &= i2cGNSS.setAutoHPPOSLLH(true, false); //Tell the GPS to "send" each high res solution, but do not update stale data when accessed

Firmware/RTK_Surveyor/menuGNSS.ino

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ void menuConstellations()
148148

149149
for (int x = 0 ; x < MAX_CONSTELLATIONS ; x++)
150150
{
151-
Serial.printf("%d) Constellation %s: ", x + 1, ubxConstellations[x].textName);
152-
if (ubxConstellations[x].enabled == true)
151+
Serial.printf("%d) Constellation %s: ", x + 1, settings.ubxConstellations[x].textName);
152+
if (settings.ubxConstellations[x].enabled == true)
153153
Serial.print("Enabled");
154154
else
155155
Serial.print("Disabled");
@@ -164,13 +164,13 @@ void menuConstellations()
164164
{
165165
incoming--; //Align choice to constallation array of 0 to 5
166166

167-
ubxConstellations[incoming].enabled ^= 1;
167+
settings.ubxConstellations[incoming].enabled ^= 1;
168168

169169
//3.10.6: To avoid cross-correlation issues, it is recommended that GPS and QZSS are always both enabled or both disabled.
170170
if (incoming == SFE_UBLOX_GNSS_ID_GPS || incoming == 4) //QZSS ID is 5 but array location is 4
171171
{
172-
ubxConstellations[SFE_UBLOX_GNSS_ID_GPS].enabled = ubxConstellations[incoming].enabled; //GPS ID is 0 and array location is 0
173-
ubxConstellations[4].enabled = ubxConstellations[incoming].enabled; //QZSS ID is 5 but array location is 4
172+
settings.ubxConstellations[SFE_UBLOX_GNSS_ID_GPS].enabled = settings.ubxConstellations[incoming].enabled; //GPS ID is 0 and array location is 0
173+
settings.ubxConstellations[4].enabled = settings.ubxConstellations[incoming].enabled; //QZSS ID is 5 but array location is 4
174174
}
175175
}
176176
else if (incoming == STATUS_PRESSED_X)
@@ -258,14 +258,14 @@ bool configureConstellations()
258258
for (int x = 0 ; x < MAX_CONSTELLATIONS ; x++)
259259
{
260260
//Standard UBX protocol method takes ~533-783ms
261-
uint8_t currentlyEnabled = getConstellation(ubxConstellations[x].gnssID); //Qeury the module for the current setting
262-
if (currentlyEnabled != ubxConstellations[x].enabled)
263-
response &= setConstellation(ubxConstellations[x].gnssID, ubxConstellations[x].enabled);
261+
uint8_t currentlyEnabled = getConstellation(settings.ubxConstellations[x].gnssID); //Qeury the module for the current setting
262+
if (currentlyEnabled != settings.ubxConstellations[x].enabled)
263+
response &= setConstellation(settings.ubxConstellations[x].gnssID, settings.ubxConstellations[x].enabled);
264264

265265
//Get/set val method takes ~642ms but does not work because we don't send additional sigCfg keys at same time
266-
// uint8_t currentlyEnabled = i2cGNSS.getVal8(ubxConstellations[x].configKey, VAL_LAYER_RAM, 1200);
267-
// if (currentlyEnabled != ubxConstellations[x].enabled)
268-
// response &= i2cGNSS.setVal(ubxConstellations[x].configKey, ubxConstellations[x].enabled);
266+
// uint8_t currentlyEnabled = i2cGNSS.getVal8(settings.ubxConstellations[x].configKey, VAL_LAYER_RAM, 1200);
267+
// if (currentlyEnabled != settings.ubxConstellations[x].enabled)
268+
// response &= i2cGNSS.setVal(settings.ubxConstellations[x].configKey, settings.ubxConstellations[x].enabled);
269269
}
270270
//long stopTime = millis();
271271

Firmware/RTK_Surveyor/menuMessages.ino

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void menuMessages()
108108
menuMessagesSubtype("TIM");
109109
else if (incoming == 7)
110110
{
111-
setGNSSMessageRates(ubxMessages, 0); //Turn off all messages
111+
setGNSSMessageRates(settings.ubxMessages, 0); //Turn off all messages
112112
setMessageRateByName("UBX_NMEA_GGA", 1);
113113
setMessageRateByName("UBX_NMEA_GSA", 1);
114114
setMessageRateByName("UBX_NMEA_GST", 1);
@@ -118,7 +118,7 @@ void menuMessages()
118118
}
119119
else if (incoming == 8)
120120
{
121-
setGNSSMessageRates(ubxMessages, 0); //Turn off all messages
121+
setGNSSMessageRates(settings.ubxMessages, 0); //Turn off all messages
122122
setMessageRateByName("UBX_NMEA_GGA", 1);
123123
setMessageRateByName("UBX_NMEA_GSA", 1);
124124
setMessageRateByName("UBX_NMEA_GST", 1);
@@ -131,12 +131,12 @@ void menuMessages()
131131
}
132132
else if (incoming == 9)
133133
{
134-
setGNSSMessageRates(ubxMessages, 0); //Turn off all messages
134+
setGNSSMessageRates(settings.ubxMessages, 0); //Turn off all messages
135135
Serial.println(F("All messages disabled"));
136136
}
137137
else if (incoming == 10)
138138
{
139-
setGNSSMessageRates(ubxMessages, 1); //Turn on all messages to report once per fix
139+
setGNSSMessageRates(settings.ubxMessages, 1); //Turn on all messages to report once per fix
140140
Serial.println(F("All messages enabled"));
141141
}
142142
else if (incoming == STATUS_PRESSED_X)
@@ -149,12 +149,12 @@ void menuMessages()
149149

150150
while (Serial.available()) Serial.read(); //Empty buffer of any newline chars
151151

152-
bool response = configureGNSSMessageRates(COM_PORT_UART1, ubxMessages); //Make sure the appropriate messages are enabled
152+
bool response = configureGNSSMessageRates(COM_PORT_UART1, settings.ubxMessages); //Make sure the appropriate messages are enabled
153153
if (response == false)
154154
{
155155
Serial.println(F("menuMessages: Failed to enable UART1 messages - Try 1"));
156156
//Try again
157-
response = configureGNSSMessageRates(COM_PORT_UART1, ubxMessages); //Make sure the appropriate messages are enabled
157+
response = configureGNSSMessageRates(COM_PORT_UART1, settings.ubxMessages); //Make sure the appropriate messages are enabled
158158
if (response == false)
159159
Serial.println(F("menuMessages: Failed to enable UART1 messages - Try 2"));
160160
else
@@ -182,10 +182,10 @@ void menuMessagesSubtype(const char* messageType)
182182
for (int x = 0 ; x < (endOfBlock - startOfBlock) ; x++)
183183
{
184184
//Check to see if this ZED platform supports this message
185-
if (ubxMessages[x + startOfBlock].supported & zedModuleType)
185+
if (settings.ubxMessages[x + startOfBlock].supported & zedModuleType)
186186
{
187-
Serial.printf("%d) Message %s: ", x + 1, ubxMessages[x + startOfBlock].msgTextName);
188-
Serial.println(ubxMessages[x + startOfBlock].msgRate);
187+
Serial.printf("%d) Message %s: ", x + 1, settings.ubxMessages[x + startOfBlock].msgTextName);
188+
Serial.println(settings.ubxMessages[x + startOfBlock].msgRate);
189189
}
190190
}
191191

@@ -196,8 +196,8 @@ void menuMessagesSubtype(const char* messageType)
196196
if (incoming >= 1 && incoming <= (endOfBlock - startOfBlock))
197197
{
198198
//Check to see if this ZED platform supports this message
199-
if (ubxMessages[(incoming - 1) + startOfBlock].supported & zedModuleType)
200-
inputMessageRate(ubxMessages[(incoming - 1) + startOfBlock]);
199+
if (settings.ubxMessages[(incoming - 1) + startOfBlock].supported & zedModuleType)
200+
inputMessageRate(settings.ubxMessages[(incoming - 1) + startOfBlock]);
201201
else
202202
printUnknown(incoming);
203203
}
@@ -245,7 +245,7 @@ bool configureGNSSMessageRates(uint8_t portType, ubxMsg *localMessage)
245245
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
246246
{
247247
//Check to see if this ZED platform supports this message
248-
if (ubxMessages[x].supported & zedModuleType)
248+
if (settings.ubxMessages[x].supported & zedModuleType)
249249
response &= configureMessageRate(portType, localMessage[x]);
250250
}
251251

@@ -499,7 +499,7 @@ void setMessageOffsets(const char* messageType, int& startOfBlock, int& endOfBlo
499499
//Find the first occurrence
500500
for (startOfBlock = 0 ; startOfBlock < MAX_UBX_MSG ; startOfBlock++)
501501
{
502-
if (strstr(ubxMessages[startOfBlock].msgTextName, messageNamePiece) != NULL) break;
502+
if (strstr(settings.ubxMessages[startOfBlock].msgTextName, messageNamePiece) != NULL) break;
503503
}
504504
if (startOfBlock == MAX_UBX_MSG)
505505
{
@@ -512,7 +512,7 @@ void setMessageOffsets(const char* messageType, int& startOfBlock, int& endOfBlo
512512
//Find the last occurrence
513513
for (endOfBlock = startOfBlock + 1 ; endOfBlock < MAX_UBX_MSG ; endOfBlock++)
514514
{
515-
if (strstr(ubxMessages[endOfBlock].msgTextName, messageNamePiece) == NULL) break;
515+
if (strstr(settings.ubxMessages[endOfBlock].msgTextName, messageNamePiece) == NULL) break;
516516
}
517517
}
518518

@@ -521,7 +521,7 @@ uint8_t getActiveMessageCount()
521521
{
522522
uint8_t count = 0;
523523
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
524-
if (ubxMessages[x].msgRate > 0) count++;
524+
if (settings.ubxMessages[x].msgRate > 0) count++;
525525
return (count);
526526
}
527527

@@ -530,9 +530,9 @@ bool setMessageRateByName(const char *msgName, uint8_t msgRate)
530530
{
531531
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
532532
{
533-
if (strcmp(ubxMessages[x].msgTextName, msgName) == 0)
533+
if (strcmp(settings.ubxMessages[x].msgTextName, msgName) == 0)
534534
{
535-
ubxMessages[x].msgRate = msgRate;
535+
settings.ubxMessages[x].msgRate = msgRate;
536536
return (true);
537537
}
538538
}

Firmware/RTK_Surveyor/menuTest.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void menuTest()
9595
else if (incoming == 4)
9696
{
9797
//Send the current settings to USB
98-
bool response = configureGNSSMessageRates(COM_PORT_USB, ubxMessages); //Make sure the appropriate messages are enabled
98+
bool response = configureGNSSMessageRates(COM_PORT_USB, settings.ubxMessages); //Make sure the appropriate messages are enabled
9999
if (response == false)
100100
Serial.println(F("menuTest: Failed to enable USB messages"));
101101
else

0 commit comments

Comments
 (0)