Skip to content

Commit 4bc5a6b

Browse files
authored
Merge pull request #438 from sparkfun/Add_Ref_Stn_Ethernet
Add RTCM Buffer. Hide Ref Stn battery icon. Correct online.ethernetStatus state checking
2 parents 725fd3e + 204664c commit 4bc5a6b

File tree

14 files changed

+156
-128
lines changed

14 files changed

+156
-128
lines changed

.github/workflows/compile-rtk-firmware.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
ArduinoJson@6.19.4
7272
pubsubclient@2.8.0
7373
ESP32_BleSerial@1.0.4
74-
"SparkFun u-blox GNSS v3"@3.0.7
74+
"SparkFun u-blox GNSS v3"@3.0.8
7575
"SparkFun MAX1704x Fuel Gauge Arduino Library"@1.0.4
7676
"SparkFun LIS2DH12 Arduino Library"@1.0.3
7777
"ESP32-OTA-Pull"@1.0.0

Firmware/RTK_Surveyor/Base.ino

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,15 @@ bool surveyInStart()
141141

142142
if (surveyInReset() == false)
143143
{
144-
systemPrintln("Survey reset failed");
144+
systemPrintln("Survey reset failed - attempt 1/3");
145145
if (surveyInReset() == false)
146-
systemPrintln("Survey reset failed - 2nd attempt");
146+
{
147+
systemPrintln("Survey reset failed - attempt 2/3");
148+
if (surveyInReset() == false)
149+
{
150+
systemPrintln("Survey reset failed - attempt 3/3");
151+
}
152+
}
147153
}
148154
}
149155

@@ -292,6 +298,13 @@ bool startFixedBase()
292298
//Useful for passing the RTCM correction data to a radio, Ntrip broadcaster, etc.
293299
void DevUBLOXGNSS::processRTCM(uint8_t incoming)
294300
{
301+
//We need to prevent ntripServerProcessRTCM from writing data via Ethernet (SPI W5500)
302+
//during an SPI checkUbloxSpi...
303+
//We can pass incoming to ntripServerProcessRTCM if the GNSS is I2C or the variant does not have Ethernet.
304+
//For the Ref Stn, processRTCMBuffer is called manually from inside ntripServerUpdate
305+
if ((USE_SPI_GNSS) && (HAS_ETHERNET))
306+
return;
307+
295308
//Check for too many digits
296309
if (settings.enableResetDisplay == true)
297310
{
@@ -319,3 +332,44 @@ void DevUBLOXGNSS::processRTCM(uint8_t incoming)
319332
espnowProcessRTCM(incoming);
320333
}
321334
}
335+
336+
//For Ref Stn (USE_SPI_GNSS and HAS_ETHERNET), call ntripServerProcessRTCM manually if there is RTCM data in the buffer
337+
void processRTCMBuffer()
338+
{
339+
if ((USE_I2C_GNSS) || (!HAS_ETHERNET))
340+
return;
341+
342+
//Check if there is any data waiting in the RTCM buffer
343+
uint16_t rtcmBytesAvail = theGNSS.rtcmBufferAvailable();
344+
if (rtcmBytesAvail > 0)
345+
{
346+
//Check for too many digits
347+
if (settings.enableResetDisplay == true)
348+
{
349+
if (rtcmPacketsSent > 99) rtcmPacketsSent = 1; //Trim to two digits to avoid overlap
350+
}
351+
else
352+
{
353+
if (rtcmPacketsSent > 999) rtcmPacketsSent = 1; //Trim to three digits to avoid log icon and increasing bar
354+
}
355+
356+
while (rtcmBytesAvail > 0)
357+
{
358+
uint8_t incoming;
359+
360+
if (theGNSS.extractRTCMBufferData(&incoming, 1) != 1)
361+
return;
362+
363+
rtcmBytesAvail--;
364+
365+
//Data in the u-blox library RTCM buffer is pre-checked. We don't need to check it again here.
366+
367+
rtcmLastReceived = millis();
368+
rtcmBytesSent++;
369+
370+
ntripServerProcessRTCM(incoming);
371+
372+
espnowProcessRTCM(incoming);
373+
}
374+
}
375+
}

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ void beginGNSS()
631631
//Use gnssHandlerBufferSize for now. TODO: work out if the SPI GNSS needs its own buffer size setting
632632
//Also used by Tasks.ino
633633
theGNSS.setFileBufferSize(settings.gnssHandlerBufferSize);
634+
theGNSS.setRTCMBufferSize(settings.gnssHandlerBufferSize);
634635
}
635636

636637
if (USE_I2C_GNSS)
@@ -671,6 +672,12 @@ void beginGNSS()
671672
displayGNSSFail(1000);
672673
return;
673674
}
675+
if (theGNSS.getRTCMBufferSize() != settings.gnssHandlerBufferSize) //Need to call getRTCMBufferSize after begin
676+
{
677+
log_d("GNSS offline - no RAM for RTCM buffer");
678+
displayGNSSFail(1000);
679+
return;
680+
}
674681
}
675682

676683
//Increase transactions to reduce transfer time
@@ -841,7 +848,7 @@ void beginLEDs()
841848
//Configure the on board MAX17048 fuel gauge
842849
void beginFuelGauge()
843850
{
844-
if (productVariant == REFERENCE_STATION)
851+
if (HAS_NO_BATTERY)
845852
return; //Reference station does not have a battery
846853

847854
//Set up the MAX17048 LiPo fuel gauge

Firmware/RTK_Surveyor/Display.ino

Lines changed: 26 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,21 @@ void beginDisplay()
126126
systemPrintln("Display not detected");
127127
}
128128

129+
//Avoid code repetition
130+
void displayBatteryVsEthernet()
131+
{
132+
if (HAS_BATTERY)
133+
icons |= ICON_BATTERY; //Top right
134+
else //if (HAS_ETHERNET)
135+
{
136+
if (online.ethernetStatus == ETH_CONNECTED)
137+
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
138+
else
139+
blinking_icons ^= ICON_ETHERNET;
140+
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
141+
}
142+
}
143+
129144
//Given the system state, display the appropriate information
130145
void updateDisplay()
131146
{
@@ -205,50 +220,23 @@ void updateDisplay()
205220
| ICON_HORIZONTAL_ACCURACY //Center right
206221
| paintSIV() //Bottom left
207222
| ICON_LOGGING; //Bottom right
208-
if (productVariant != REFERENCE_STATION)
209-
icons |= ICON_BATTERY; //Top right
210-
else
211-
{
212-
if (online.ethernetStatus == ETH_CONNECTED)
213-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
214-
else
215-
blinking_icons ^= ICON_ETHERNET;
216-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
217-
}
223+
displayBatteryVsEthernet(); //Top right
218224
iconsRadio = setRadioIcons(); //Top left
219225
break;
220226
case (STATE_ROVER_NO_FIX):
221227
icons = ICON_CROSS_HAIR //Center left
222228
| ICON_HORIZONTAL_ACCURACY //Center right
223229
| paintSIV() //Bottom left
224230
| ICON_LOGGING; //Bottom right
225-
if (productVariant != REFERENCE_STATION)
226-
icons |= ICON_BATTERY; //Top right
227-
else
228-
{
229-
if (online.ethernetStatus == ETH_CONNECTED)
230-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
231-
else
232-
blinking_icons ^= ICON_ETHERNET;
233-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
234-
}
231+
displayBatteryVsEthernet(); //Top right
235232
iconsRadio = setRadioIcons(); //Top left
236233
break;
237234
case (STATE_ROVER_FIX):
238235
icons = ICON_CROSS_HAIR //Center left
239236
| ICON_HORIZONTAL_ACCURACY //Center right
240237
| paintSIV() //Bottom left
241238
| ICON_LOGGING; //Bottom right
242-
if (productVariant != REFERENCE_STATION)
243-
icons |= ICON_BATTERY; //Top right
244-
else
245-
{
246-
if (online.ethernetStatus == ETH_CONNECTED)
247-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
248-
else
249-
blinking_icons ^= ICON_ETHERNET;
250-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
251-
}
239+
displayBatteryVsEthernet(); //Top right
252240
iconsRadio = setRadioIcons(); //Top left
253241
break;
254242
case (STATE_ROVER_RTK_FLOAT):
@@ -257,33 +245,15 @@ void updateDisplay()
257245
| ICON_HORIZONTAL_ACCURACY //Center right
258246
| paintSIV() //Bottom left
259247
| ICON_LOGGING; //Bottom right
260-
if (productVariant != REFERENCE_STATION)
261-
icons |= ICON_BATTERY; //Top right
262-
else
263-
{
264-
if (online.ethernetStatus == ETH_CONNECTED)
265-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
266-
else
267-
blinking_icons ^= ICON_ETHERNET;
268-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
269-
}
248+
displayBatteryVsEthernet(); //Top right
270249
iconsRadio = setRadioIcons(); //Top left
271250
break;
272251
case (STATE_ROVER_RTK_FIX):
273252
icons = ICON_CROSS_HAIR_DUAL//Center left
274253
| ICON_HORIZONTAL_ACCURACY //Center right
275254
| paintSIV() //Bottom left
276255
| ICON_LOGGING; //Bottom right
277-
if (productVariant != REFERENCE_STATION)
278-
icons |= ICON_BATTERY; //Top right
279-
else
280-
{
281-
if (online.ethernetStatus == ETH_CONNECTED)
282-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
283-
else
284-
blinking_icons ^= ICON_ETHERNET;
285-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
286-
}
256+
displayBatteryVsEthernet(); //Top right
287257
iconsRadio = setRadioIcons(); //Top left
288258
break;
289259

@@ -300,74 +270,29 @@ void updateDisplay()
300270
| ICON_HORIZONTAL_ACCURACY //Center right
301271
| paintSIV() //Bottom left
302272
| ICON_LOGGING; //Bottom right
303-
if (productVariant != REFERENCE_STATION)
304-
icons |= ICON_BATTERY; //Top right
305-
else
306-
{
307-
if (online.ethernetStatus == ETH_CONNECTED)
308-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
309-
else
310-
blinking_icons ^= ICON_ETHERNET;
311-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
312-
}
273+
displayBatteryVsEthernet(); //Top right
313274
iconsRadio = setRadioIcons(); //Top left
314275
break;
315276
case (STATE_BASE_TEMP_SURVEY_STARTED):
316277
icons = ICON_LOGGING; //Bottom right
317-
if (productVariant != REFERENCE_STATION)
318-
icons |= ICON_BATTERY; //Top right
319-
else
320-
{
321-
if (online.ethernetStatus == ETH_CONNECTED)
322-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
323-
else
324-
blinking_icons ^= ICON_ETHERNET;
325-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
326-
}
278+
displayBatteryVsEthernet(); //Top right
327279
iconsRadio = setRadioIcons(); //Top left
328280
paintBaseTempSurveyStarted();
329281
break;
330282
case (STATE_BASE_TEMP_TRANSMITTING):
331283
icons = ICON_LOGGING; //Bottom right
332-
if (productVariant != REFERENCE_STATION)
333-
icons |= ICON_BATTERY; //Top right
334-
else
335-
{
336-
if (online.ethernetStatus == ETH_CONNECTED)
337-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
338-
else
339-
blinking_icons ^= ICON_ETHERNET;
340-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
341-
}
284+
displayBatteryVsEthernet(); //Top right
342285
iconsRadio = setRadioIcons(); //Top left
343286
paintRTCM();
344287
break;
345288
case (STATE_BASE_FIXED_NOT_STARTED):
346289
icons = 0; //Top right
347-
if (productVariant != REFERENCE_STATION)
348-
icons |= ICON_BATTERY; //Top right
349-
else
350-
{
351-
if (online.ethernetStatus == ETH_CONNECTED)
352-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
353-
else
354-
blinking_icons ^= ICON_ETHERNET;
355-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
356-
}
290+
displayBatteryVsEthernet(); //Top right
357291
iconsRadio = setRadioIcons(); //Top left
358292
break;
359293
case (STATE_BASE_FIXED_TRANSMITTING):
360294
icons = ICON_LOGGING; //Bottom right
361-
if (productVariant != REFERENCE_STATION)
362-
icons |= ICON_BATTERY; //Top right
363-
else
364-
{
365-
if (online.ethernetStatus == ETH_CONNECTED)
366-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
367-
else
368-
blinking_icons ^= ICON_ETHERNET;
369-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
370-
}
295+
displayBatteryVsEthernet(); //Top right
371296
iconsRadio = setRadioIcons(); //Top left
372297
paintRTCM();
373298
break;
@@ -3268,7 +3193,7 @@ const uint8_t * getMacAddress()
32683193
return wifiMACAddress;
32693194
#endif
32703195
#ifdef COMPILE_ETHERNET
3271-
else if (online.ethernetStatus >= ETH_BEGUN_NO_LINK)
3196+
else if ((online.ethernetStatus >= ETH_STARTED_CHECK_CABLE) && (online.ethernetStatus <= ETH_CONNECTED))
32723197
return ethernetMACAddress;
32733198
#endif
32743199
#endif

Firmware/RTK_Surveyor/Form.ino

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,12 @@ void createSettingsString(char* newSettings)
763763

764764
stringRecord(newSettings, "logFileName", logFileName);
765765

766-
if (productVariant != REFERENCE_STATION) //Ref Stn does not have a battery
766+
if (HAS_NO_BATTERY) //Ref Stn does not have a battery
767+
{
768+
stringRecord(newSettings, "batteryIconFileName", "src/BatteryBlank.png");
769+
stringRecord(newSettings, "batteryPercent", " ");
770+
}
771+
else
767772
{
768773
//Determine battery icon
769774
int iconLevel = 0;
@@ -921,7 +926,12 @@ void createDynamicDataString(char* settingsCSV)
921926
stringRecord(settingsCSV, "ecefY", ecefY, 3);
922927
stringRecord(settingsCSV, "ecefZ", ecefZ, 3);
923928

924-
if (productVariant != REFERENCE_STATION) //Ref Stn does not have a battery
929+
if (HAS_NO_BATTERY) //Ref Stn does not have a battery
930+
{
931+
stringRecord(settingsCSV, "batteryIconFileName", "src/BatteryBlank.png");
932+
stringRecord(settingsCSV, "batteryPercent", " ");
933+
}
934+
else
925935
{
926936
//Determine battery icon
927937
int iconLevel = 0;

Firmware/RTK_Surveyor/NtripClient.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,7 @@ void ntripClientUpdate()
367367
#ifdef COMPILE_ETHERNET
368368
if (HAS_ETHERNET)
369369
{
370-
if (online.ethernetStatus < ETH_BEGUN_NO_LINK)
371-
{
372-
systemPrintln("Error: Please connect Ethernet before starting NTRIP Client");
373-
ntripClientStop(true); //Do not allocate new wifiClient
374-
}
375-
else
370+
if ((online.ethernetStatus >= ETH_STARTED_CHECK_CABLE) && (online.ethernetStatus <= ETH_CONNECTED))
376371
{
377372
//Pause until connection timeout has passed
378373
if (millis() - ntripClientLastConnectionAttempt > ntripClientConnectionAttemptTimeout)
@@ -382,6 +377,11 @@ void ntripClientUpdate()
382377
ntripClientSetState(NTRIP_CLIENT_WIFI_ETHERNET_STARTED);
383378
}
384379
}
380+
else
381+
{
382+
systemPrintln("Error: Please connect Ethernet before starting NTRIP Client");
383+
ntripClientStop(true); //Do not allocate new wifiClient
384+
}
385385
}
386386
else
387387
#endif
@@ -412,7 +412,7 @@ void ntripClientUpdate()
412412
{
413413
if (online.ethernetStatus == ETH_CONNECTED)
414414
ntripClientSetState(NTRIP_CLIENT_WIFI_ETHERNET_CONNECTED);
415-
else if (online.ethernetStatus >= ETH_BEGUN_NO_LINK)
415+
else
416416
ntripClientSetState(NTRIP_CLIENT_OFF);
417417
}
418418
else

0 commit comments

Comments
 (0)