Skip to content

Commit 8e3b504

Browse files
committed
Rework corrections priority support
1 parent 652e7cd commit 8e3b504

14 files changed

+560
-227
lines changed

Firmware/RTK_Everywhere/Begin.ino

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,29 +1421,6 @@ void deleteSDSizeCheckTask()
14211421
}
14221422
}
14231423

1424-
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1425-
// Corrections Priorities Housekeeping
1426-
void initializeCorrectionsPriorities()
1427-
{
1428-
clearRegisteredCorrectionsSources(); // Clear (initialize) the vector of corrections sources. Probably redundant...?
1429-
}
1430-
1431-
void updateCorrectionsPriorities()
1432-
{
1433-
checkRegisteredCorrectionsSources(); // Delete any expired corrections sources
1434-
}
1435-
1436-
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1437-
// Check and initialize any arrays that won't be initialized by gnssConfigure (checkGNSSArrayDefaults)
1438-
// TODO: find a better home for this
1439-
void checkArrayDefaults()
1440-
{
1441-
if (!validateCorrectionPriorities())
1442-
initializeCorrectionPriorities();
1443-
if (!validateCorrectionPriorities())
1444-
reportFatalError("initializeCorrectionPriorities failed.");
1445-
}
1446-
14471424
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
14481425
// Time Pulse ISR
14491426
// Triggered by the rising edge of the time pulse signal, indicates the top-of-second.

Firmware/RTK_Everywhere/ESPNOW.ino

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,8 @@ void espnowOnDataReceived(const esp_now_recv_info *mac, const uint8_t *incomingD
108108
espnowRSSI = packetRSSI; // Record this packet's RSSI as an ESP NOW packet
109109

110110
// We've just received ESP-Now data. We assume this is RTCM and push it directly to the GNSS.
111-
// BUT we need to consider the Corrections Priorities.
112-
// Step 1: check if CORR_ESPNOW is registered as a correction source. If not, register it.
113-
// Step 2: check if CORR_ESPNOW is the highest - actually LOWEST - registered correction source.
114-
// If it is, push the data. If not, discard the data.
115-
116-
// Step 1
117-
updateCorrectionsLastSeen(CORR_ESPNOW); // This will (re)register the correction source if needed
118-
119-
// Step 2
120-
if (isHighestRegisteredCorrectionsSource(CORR_ESPNOW))
111+
// Determine if ESPNOW is the correction source
112+
if (correctionLastSeen(CORR_ESPNOW))
121113
{
122114
// Pass RTCM bytes (presumably) from ESP NOW out ESP32-UART to GNSS
123115
gnssPushRawData((uint8_t *)incomingData, len);
@@ -696,4 +688,4 @@ bool espnowSetChannel(uint8_t channelNumber)
696688
#else
697689
return (false);
698690
#endif
699-
}
691+
}

Firmware/RTK_Everywhere/LoRa.ino

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,7 @@ void updateLora()
170170
rtcmCount = Serial.readBytes(rtcmData, sizeof(rtcmData));
171171

172172
// We've just received data. We assume this is RTCM and push it directly to the GNSS.
173-
// BUT we need to consider the Corrections Priorities.
174-
// Step 1: check if CORR_RADIO_LORA is registered as a correction source. If not, register it.
175-
// Step 2: check if CORR_RADIO_LORA is the highest - actually LOWEST - registered correction source.
176-
// If it is, push the data. If not, discard the data.
177-
178-
// Step 1
179-
updateCorrectionsLastSeen(CORR_RADIO_LORA); // This will (re)register the correction source if needed
180-
181-
// Step 2
182-
if (isHighestRegisteredCorrectionsSource(CORR_RADIO_LORA))
173+
if (correctionLastSeen(CORR_RADIO_LORA))
183174
{
184175
// Pass RTCM bytes (presumably) from LoRa out ESP32-UART to GNSS
185176
gnssPushRawData(rtcmData, rtcmCount); // Push RTCM to GNSS module
@@ -258,16 +249,7 @@ void updateLora()
258249
rtcmCount = Serial.readBytes(rtcmData, sizeof(rtcmData));
259250

260251
// We've just received data. We assume this is RTCM and push it directly to the GNSS.
261-
// BUT we need to consider the Corrections Priorities.
262-
// Step 1: check if CORR_RADIO_LORA is registered as a correction source. If not, register it.
263-
// Step 2: check if CORR_RADIO_LORA is the highest - actually LOWEST - registered correction source.
264-
// If it is, push the data. If not, discard the data.
265-
266-
// Step 1
267-
updateCorrectionsLastSeen(CORR_RADIO_LORA); // This will (re)register the correction source if needed
268-
269-
// Step 2
270-
if (isHighestRegisteredCorrectionsSource(CORR_RADIO_LORA))
252+
if (correctionLastSeen(CORR_RADIO_LORA))
271253
{
272254
// Pass RTCM bytes (presumably) from LoRa out ESP32-UART to GNSS
273255
gnssPushRawData(rtcmData, rtcmCount); // Push RTCM to GNSS module

Firmware/RTK_Everywhere/MQTT_Client.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,8 @@ void mqttClientReceiveMessage(int messageSize)
481481
&& (strcmp(topic, localizedDistributionTileTopic.c_str()) == 0))
482482
)
483483
{
484-
// SPARTN
485-
updateCorrectionsLastSeen(CORR_IP);
486-
if (isHighestRegisteredCorrectionsSource(CORR_IP))
484+
// Determine if MQTT (SPARTN data) is the correction source
485+
if (correctionLastSeen(CORR_IP))
487486
{
488487
if (((settings.debugMqttClientData == true) || (settings.debugCorrections == true)) &&
489488
!inMainMenu)

Firmware/RTK_Everywhere/NVM.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ void recordSystemSettingsToFile(File *settingsFile)
492492
{
493493
char tempString[80]; // correctionsPriority_Ethernet_IP_(PointPerfect/MQTT)=99
494494
snprintf(tempString, sizeof(tempString), "%s%s=%0d", rtkSettingsEntries[i].name,
495-
correctionsSourceNames[x], settings.correctionsSourcesPriority[x]);
495+
correctionGetName(x), settings.correctionsSourcesPriority[x]);
496496
settingsFile->println(tempString);
497497
}
498498
}
@@ -1198,7 +1198,7 @@ bool parseLine(char *str)
11981198
case tCorrSPri: {
11991199
for (int x = 0; x < qualifier; x++)
12001200
{
1201-
if ((suffix[0] == correctionsSourceNames[x][0]) && (strcmp(suffix, correctionsSourceNames[x]) == 0))
1201+
if ((suffix[0] == correctionGetName(x)[0]) && (strcmp(suffix, correctionGetName(x)) == 0))
12021202
{
12031203
settings.correctionsSourcesPriority[x] = d;
12041204
knownSetting = true;

Firmware/RTK_Everywhere/NtripClient.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,7 @@ void ntripClientUpdate()
827827

828828
netIncomingRTCM = true;
829829

830-
updateCorrectionsLastSeen(CORR_TCP);
831-
if (isHighestRegisteredCorrectionsSource(CORR_TCP))
830+
if (correctionLastSeen(CORR_TCP))
832831
{
833832
// Push RTCM to GNSS module over I2C / SPI
834833
gnssPushRawData(rtcmData, rtcmCount);

Firmware/RTK_Everywhere/PointPerfectLibrary.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ void updatePplTask(void *e)
3434
{
3535
if (rtcmLength > 0)
3636
{
37-
updateCorrectionsLastSeen(pplCorrectionsSource);
38-
if (isHighestRegisteredCorrectionsSource(pplCorrectionsSource))
37+
if (correctionLastSeen(pplCorrectionsSource))
3938
{
4039
// Set ZED SOURCE to 1 (L-Band) if needed
4140
// Note: this is almost certainly redundant. It would only be used if we

Firmware/RTK_Everywhere/RTK_Everywhere.ino

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,7 @@ uint16_t failedParserMessages_RTCM;
785785
uint16_t failedParserMessages_NMEA;
786786

787787
// Corrections Priorities Support
788-
std::vector<registeredCorrectionsSource>
789-
registeredCorrectionsSources; // vector (linked list) of registered corrections sources for this device
790-
correctionsSource pplCorrectionsSource = CORR_NUM; // Record which source is feeding the PPL
788+
CORRECTION_ID_T pplCorrectionsSource = CORR_NUM; // Record which source is feeding the PPL
791789

792790
// configureViaEthernet:
793791
// Set to true if configureViaEthernet.txt exists in LittleFS.
@@ -1011,9 +1009,6 @@ void setup()
10111009
DMW_b("verifyTables");
10121010
verifyTables(); // Verify the consistency of the internal tables
10131011

1014-
DMW_b("initializeCorrectionsPriorities");
1015-
initializeCorrectionsPriorities(); // Initialize (clear) the registeredCorrectionsSources vector
1016-
10171012
DMW_b("findSpiffsPartition");
10181013
if (!findSpiffsPartition())
10191014
{
@@ -1253,8 +1248,8 @@ void loop()
12531248
DMW_c("otaAutoUpdate");
12541249
otaAutoUpdate();
12551250

1256-
DMW_c("updateCorrectionsPriorities");
1257-
updateCorrectionsPriorities(); // Update registeredCorrectionsSources, delete expired sources
1251+
DMW_c("correctionUpdateSource");
1252+
correctionUpdateSource(); // Retire expired sources
12581253

12591254
DMW_c("updateProvisioning");
12601255
updateProvisioning(); // Check if we should attempt to connect to PointPerfect to get keys / certs / correction

Firmware/RTK_Everywhere/Tasks.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ void addToGnssBuffer(uint8_t incoming)
265265
// Push the buffered data in bulk to the GNSS
266266
void sendGnssBuffer()
267267
{
268-
updateCorrectionsLastSeen(CORR_BLUETOOTH);
269-
if (isHighestRegisteredCorrectionsSource(CORR_BLUETOOTH))
268+
if (correctionLastSeen(CORR_BLUETOOTH))
270269
{
271270
if (gnssPushRawData(bluetoothOutgoingToGnss, bluetoothOutgoingToGnssHead))
272271
{

Firmware/RTK_Everywhere/menuCommands.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ SettingValueResponse updateSettingWithValue(bool inCommands, const char *setting
866866
case tCorrSPri: {
867867
for (int x = 0; x < qualifier; x++)
868868
{
869-
if ((suffix[0] == correctionsSourceNames[x][0]) && (strcmp(suffix, correctionsSourceNames[x]) == 0))
869+
if ((suffix[0] == correctionGetName(x)[0]) && (strcmp(suffix, correctionGetName(x)) == 0))
870870
{
871871
settings.correctionsSourcesPriority[x] = settingValue;
872872
knownSetting = true;
@@ -1514,7 +1514,7 @@ void createSettingsString(char *newSettings)
15141514
{
15151515
char tempString[80]; // correctionsPriority.Ethernet_IP_(PointPerfect/MQTT)=99
15161516
snprintf(tempString, sizeof(tempString), "%s%s,%0d,", rtkSettingsEntries[i].name,
1517-
correctionsSourceNames[x], settings.correctionsSourcesPriority[x]);
1517+
correctionGetName(x), settings.correctionsSourcesPriority[x]);
15181518
stringRecord(newSettings, tempString);
15191519
}
15201520
}
@@ -2220,7 +2220,7 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
22202220
case tCorrSPri: {
22212221
for (int x = 0; x < qualifier; x++)
22222222
{
2223-
if ((suffix[0] == correctionsSourceNames[x][0]) && (strcmp(suffix, correctionsSourceNames[x]) == 0))
2223+
if ((suffix[0] == correctionGetName(x)[0]) && (strcmp(suffix, correctionGetName(x)) == 0))
22242224
{
22252225
writeToString(settingValueStr, settings.correctionsSourcesPriority[x]);
22262226
knownSetting = true;
@@ -2624,7 +2624,7 @@ void commandList(bool inCommands, int i)
26242624
// Record corrections priorities
26252625
for (int x = 0; x < rtkSettingsEntries[i].qualifier; x++)
26262626
{
2627-
snprintf(settingName, sizeof(settingName), "%s%s", rtkSettingsEntries[i].name, correctionsSourceNames[x]);
2627+
snprintf(settingName, sizeof(settingName), "%s%s", rtkSettingsEntries[i].name, correctionGetName(x));
26282628

26292629
getSettingValue(inCommands, settingName, settingValue);
26302630
commandSendExecuteListResponse(settingName, "int", settingValue);

0 commit comments

Comments
 (0)