@@ -135,6 +135,9 @@ void updateLora()
135
135
loraState = LORA_TX;
136
136
}
137
137
138
+ if (inBaseMode () == false )
139
+ loraState = LORA_NOT_STARTED; // Force restart to move to other modes
140
+
138
141
break ;
139
142
140
143
case (LORA_TX):
@@ -151,6 +154,9 @@ void updateLora()
151
154
loraBytesSent = 0 ;
152
155
}
153
156
}
157
+
158
+ if (inBaseMode () == false )
159
+ loraState = LORA_NOT_STARTED; // Force restart to move to other modes
154
160
}
155
161
156
162
break ;
@@ -163,30 +169,37 @@ void updateLora()
163
169
164
170
rtcmCount = Serial.readBytes (rtcmData, sizeof (rtcmData));
165
171
166
- gnssPushRawData (rtcmData, rtcmCount); // Push RTCM to GNSS module
172
+ // 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.
167
177
168
- if (settings.debugLora == true )
169
- {
170
- static unsigned long lastReport = 0 ;
171
- static int loraRtcmCount = 0 ;
178
+ // Step 1
179
+ updateCorrectionsLastSeen (CORR_RADIO_LORA); // This will (re)register the correction source if needed
172
180
173
- loraRtcmCount += rtcmCount;
181
+ // Step 2
182
+ if (isHighestRegisteredCorrectionsSource (CORR_RADIO_LORA))
183
+ {
184
+ // Pass RTCM bytes (presumably) from LoRa out ESP32-UART to GNSS
185
+ gnssPushRawData (rtcmData, rtcmCount); // Push RTCM to GNSS module
174
186
175
- if (millis () - lastReport > 3000 )
187
+ if (((settings. debugCorrections == true ) || (settings. debugLora == true )) && !inMainMenu )
176
188
{
177
- lastReport = millis ();
178
-
179
189
systemFlush (); // Complete prints
180
190
muxSelectUsb (); // Connect USB
181
191
182
- systemPrintf (" Bytes received from LoRa: %d \r\n " , loraRtcmCount );
192
+ systemPrintf (" LoRa received %d RTCM bytes, pushed to GNSS \r\n " , rtcmCount );
183
193
systemFlush (); // Allow print to complete
184
194
185
195
muxSelectLoRa (); // Disconnect from USB
186
-
187
- loraRtcmCount = 0 ;
188
196
}
189
197
}
198
+ else
199
+ {
200
+ if ((settings.debugCorrections == true ) && !inMainMenu)
201
+ systemPrintf (" LoRa received %d RTCM bytes, NOT pushed due to priority\r\n " , rtcmCount);
202
+ }
190
203
}
191
204
192
205
if (isUsbAttached () == true ) // USB cable attached, share the ESP32 UART0 connection between USB And LoRa
@@ -236,30 +249,37 @@ void updateLora()
236
249
237
250
rtcmCount = Serial.readBytes (rtcmData, sizeof (rtcmData));
238
251
239
- gnssPushRawData (rtcmData, rtcmCount); // Push RTCM to GNSS module
252
+ // We've just received data. We assume this is RTCM and push it directly to the GNSS.
253
+ // BUT we need to consider the Corrections Priorities.
254
+ // Step 1: check if CORR_RADIO_LORA is registered as a correction source. If not, register it.
255
+ // Step 2: check if CORR_RADIO_LORA is the highest - actually LOWEST - registered correction source.
256
+ // If it is, push the data. If not, discard the data.
240
257
241
- if (settings.debugLora == true )
242
- {
243
- static unsigned long lastReport = 0 ;
244
- static int loraRtcmCount = 0 ;
258
+ // Step 1
259
+ updateCorrectionsLastSeen (CORR_RADIO_LORA); // This will (re)register the correction source if needed
245
260
246
- loraRtcmCount += rtcmCount;
261
+ // Step 2
262
+ if (isHighestRegisteredCorrectionsSource (CORR_RADIO_LORA))
263
+ {
264
+ // Pass RTCM bytes (presumably) from LoRa out ESP32-UART to GNSS
265
+ gnssPushRawData (rtcmData, rtcmCount); // Push RTCM to GNSS module
247
266
248
- if (millis () - lastReport > 3000 )
267
+ if (((settings. debugCorrections == true ) || (settings. debugLora == true )) && !inMainMenu )
249
268
{
250
- lastReport = millis ();
251
-
252
269
systemFlush (); // Complete prints
253
270
muxSelectUsb (); // Connect USB
254
271
255
- systemPrintf (" Bytes received from LoRa: %d \r\n " , loraRtcmCount );
272
+ systemPrintf (" LoRa received %d RTCM bytes, pushed to GNSS \r\n " , rtcmCount );
256
273
systemFlush (); // Allow print to complete
257
274
258
275
muxSelectLoRa (); // Disconnect from USB
259
-
260
- loraRtcmCount = 0 ;
261
276
}
262
277
}
278
+ else
279
+ {
280
+ if ((settings.debugCorrections == true ) && !inMainMenu)
281
+ systemPrintf (" LoRa received %d RTCM bytes, NOT pushed due to priority\r\n " , rtcmCount);
282
+ }
263
283
}
264
284
265
285
if (isUsbAttached () == false ) // USB cable detached
0 commit comments