Skip to content

Commit b370bf6

Browse files
authored
Merge pull request #805 from sparkfun/pcUpdates_ntripServer_CasterEnabled
The Iliad - Book I
2 parents abceb25 + 84bb8a2 commit b370bf6

32 files changed

+988
-273
lines changed

Firmware/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ RUN arduino-cli lib install "SparkFun MAX1704x Fuel Gauge Arduino Library"@1.0.4
7676
RUN arduino-cli lib install "SparkFun u-blox GNSS v3"@3.1.10
7777
RUN arduino-cli lib install "SparkFun Qwiic OLED Arduino Library"@1.0.13
7878
RUN arduino-cli lib install SSLClientESP32@2.0.0
79-
RUN arduino-cli lib install "SparkFun Extensible Message Parser"@1.0.4
79+
RUN arduino-cli lib install "SparkFun Extensible Message Parser"@1.0.6
8080
RUN arduino-cli lib install "SparkFun BQ40Z50 Battery Manager Arduino Library"@1.0.0
8181
RUN arduino-cli lib install "ArduinoMqttClient"@0.1.8
8282
RUN arduino-cli lib install "SparkFun u-blox PointPerfect Library"@1.11.4
8383
RUN arduino-cli lib install "SparkFun IM19 IMU Arduino Library"@1.0.1
84-
RUN arduino-cli lib install "SparkFun UM980 Triband RTK GNSS Arduino Library"@1.0.9
84+
RUN arduino-cli lib install "SparkFun UM980 Triband RTK GNSS Arduino Library"@1.0.10
8585
RUN arduino-cli lib install "SparkFun LG290P Quadband RTK GNSS Arduino Library"@1.0.8
8686
RUN arduino-cli lib install "SparkFun I2C Expander Arduino Library"@1.0.1
8787
RUN arduino-cli lib install "SparkFun Apple Accessory Arduino Library"@3.0.9

Firmware/RTK_Everywhere/AP-Config/index.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,11 @@
903903
<div class="collapse" id="ntripServerConfig0">
904904
<div class="card card-body" style="margin-top:5px;">
905905

906+
<div class="form-check mt-3 mb-2 box-margin20">
907+
<label class="form-check-label" for="ntripServerCasterEnabled_0">Enable</label>
908+
<input class="form-check-input" type="checkbox" value="" id="ntripServerCasterEnabled_0">
909+
</div>
910+
906911
<div class="form-group row">
907912
<label for="ntripServerCasterHost_0"
908913
class="box-margin20 col-sm-3 col-5 col-form-label">Caster
@@ -976,6 +981,11 @@
976981
<div class="collapse" id="ntripServerConfig1">
977982
<div class="card card-body" style="margin-top:5px;">
978983

984+
<div class="form-check mt-3 mb-2 box-margin20">
985+
<label class="form-check-label" for="ntripServerCasterEnabled_1">Enable</label>
986+
<input class="form-check-input" type="checkbox" value="" id="ntripServerCasterEnabled_1">
987+
</div>
988+
979989
<div class="form-group row">
980990
<label for="ntripServerCasterHost_1"
981991
class="box-margin20 col-sm-3 col-5 col-form-label">Caster
@@ -1049,6 +1059,11 @@
10491059
<div class="collapse" id="ntripServerConfig2">
10501060
<div class="card card-body" style="margin-top:5px;">
10511061

1062+
<div class="form-check mt-3 mb-2 box-margin20">
1063+
<label class="form-check-label" for="ntripServerCasterEnabled_2">Enable</label>
1064+
<input class="form-check-input" type="checkbox" value="" id="ntripServerCasterEnabled_2">
1065+
</div>
1066+
10521067
<div class="form-group row">
10531068
<label for="ntripServerCasterHost_2"
10541069
class="box-margin20 col-sm-3 col-5 col-form-label">Caster
@@ -1122,6 +1137,11 @@
11221137
<div class="collapse" id="ntripServerConfig3">
11231138
<div class="card card-body" style="margin-top:5px;">
11241139

1140+
<div class="form-check mt-3 mb-2 box-margin20">
1141+
<label class="form-check-label" for="ntripServerCasterEnabled_3">Enable</label>
1142+
<input class="form-check-input" type="checkbox" value="" id="ntripServerCasterEnabled_3">
1143+
</div>
1144+
11251145
<div class="form-group row">
11261146
<label for="ntripServerCasterHost_3"
11271147
class="box-margin20 col-sm-3 col-5 col-form-label">Caster

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,16 @@ function parseIncoming(msg) {
661661
ge("antennaHeight_m").value = val / 1000.0;
662662
}
663663

664+
//enableExtCorrRadio should be bool but is sent as uint8_t because it _could_ be 254
665+
else if (id.includes("enableExtCorrRadio")) {
666+
if (val == 0) {
667+
ge(id).checked = false;
668+
}
669+
else {
670+
ge(id).checked = true;
671+
}
672+
}
673+
664674
//Check boxes / radio buttons
665675
else if (val == "true") {
666676
try {

Firmware/RTK_Everywhere/Base.ino

Lines changed: 114 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,125 @@
22
Base.ino
33
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
44

5-
// This function gets called when an RTCM packet passes parser check in processUart1Message() task
6-
// Pass data along to NTRIP Server, or ESP-NOW radio
7-
void processRTCM(uint8_t *rtcmData, uint16_t dataLength)
5+
// Enough storage for two rounds of RTCM 1074,1084,1094,1124,1005
6+
// To help prevent the "no increase in file size" and "due to lack of RTCM" glitch:
7+
// RTCM is stored in PSRAM by the processUart1Message task and written by sendRTCMToConsumers
8+
const uint8_t rtcmConsumerBufferEntries = 16;
9+
const uint16_t rtcmConsumerBufferEntrySize = 1032; // RTCM can be up to 1024 + 6 bytes
10+
uint16_t rtcmConsumerBufferLengths[rtcmConsumerBufferEntries];
11+
volatile uint8_t rtcmConsumerBufferHead;
12+
volatile uint8_t rtcmConsumerBufferTail;
13+
uint8_t *rtcmConsumerBufferPtr = nullptr;
14+
15+
//----------------------------------------
16+
// Allocate and initialize the rtcmConsumerBuffer
17+
//----------------------------------------
18+
bool rtcmConsumerBufferAllocated()
819
{
9-
// Give this byte to the various possible transmission methods
10-
for (int x = 0; x < dataLength; x++)
20+
if (rtcmConsumerBufferPtr == nullptr)
1121
{
12-
for (int serverIndex = 0; serverIndex < NTRIP_SERVER_MAX; serverIndex++)
13-
ntripServerProcessRTCM(serverIndex, rtcmData[x]);
22+
rtcmConsumerBufferPtr = (uint8_t *)rtkMalloc(
23+
(size_t)rtcmConsumerBufferEntrySize * (size_t)rtcmConsumerBufferEntries,
24+
"ntripBuffer");
25+
for (uint8_t i = 0; i < rtcmConsumerBufferEntries; i++)
26+
rtcmConsumerBufferLengths[i] = 0;
27+
rtcmConsumerBufferHead = 0;
28+
rtcmConsumerBufferTail = 0;
29+
}
30+
if (rtcmConsumerBufferPtr == nullptr)
31+
{
32+
systemPrintln("rtcmConsumerBuffer malloc failed!");
33+
return false;
1434
}
1535

16-
for (int x = 0; x < dataLength; x++)
17-
espNowProcessRTCM(rtcmData[x]);
36+
return true;
37+
}
1838

19-
loraProcessRTCM(rtcmData, dataLength);
39+
//----------------------------------------
40+
// Check how many RTCM buffers contain data
41+
//----------------------------------------
42+
uint8_t rtcmBuffersInUse()
43+
{
44+
if (!rtcmConsumerBufferAllocated())
45+
return 0;
46+
47+
uint8_t buffersInUse = rtcmConsumerBufferHead - rtcmConsumerBufferTail;
48+
if (buffersInUse >= rtcmConsumerBufferEntries) // Wrap if Tail is > Head
49+
buffersInUse += rtcmConsumerBufferEntries;
50+
return buffersInUse;
51+
}
52+
53+
//----------------------------------------
54+
// Check if any RTCM data is available
55+
//----------------------------------------
56+
bool rtcmDataAvailable()
57+
{
58+
return (rtcmBuffersInUse() > 0);
59+
}
60+
61+
//----------------------------------------
62+
// Store each RTCM message in a PSRAM buffer
63+
// This function gets called as each complete RTCM message comes in
64+
// The messages are written to the servers by sendRTCMToConsumers
65+
//----------------------------------------
66+
void storeRTCMForConsumers(uint8_t *rtcmData, uint16_t dataLength)
67+
{
68+
if (!rtcmConsumerBufferAllocated())
69+
return;
70+
71+
// Check if a buffer is available
72+
if (rtcmBuffersInUse() < (rtcmConsumerBufferEntries - 1))
73+
{
74+
uint8_t *dest = rtcmConsumerBufferPtr;
75+
dest += (size_t)rtcmConsumerBufferEntrySize * (size_t)rtcmConsumerBufferHead;
76+
memcpy(dest, rtcmData, dataLength); // Store the RTCM
77+
rtcmConsumerBufferLengths[rtcmConsumerBufferHead] = dataLength; // Store the length
78+
rtcmConsumerBufferHead = rtcmConsumerBufferHead + 1; // Increment the Head
79+
rtcmConsumerBufferHead = rtcmConsumerBufferHead % rtcmConsumerBufferEntries; // Wrap
80+
}
81+
else
82+
{
83+
if (settings.debugNtripServerRtcm && (!inMainMenu))
84+
systemPrintln("rtcmConsumerBuffer full. RTCM lost");
85+
}
86+
}
87+
88+
//----------------------------------------
89+
// Send the stored RTCM to consumers: ntripServer, LoRa and ESP-NOW
90+
//----------------------------------------
91+
void sendRTCMToConsumers()
92+
{
93+
if (!rtcmConsumerBufferAllocated())
94+
return;
95+
96+
while (rtcmConsumerBufferHead != rtcmConsumerBufferTail)
97+
{
98+
uint8_t *dest = rtcmConsumerBufferPtr;
99+
dest += (size_t)rtcmConsumerBufferEntrySize * (size_t)rtcmConsumerBufferTail;
100+
101+
// NTRIP Server
102+
for (int serverIndex = 0; serverIndex < NTRIP_SERVER_MAX; serverIndex++)
103+
ntripServerSendRTCM(serverIndex, dest, rtcmConsumerBufferLengths[rtcmConsumerBufferTail]);
104+
105+
// LoRa
106+
loraProcessRTCM(dest, rtcmConsumerBufferLengths[rtcmConsumerBufferTail]);
107+
108+
// ESP-NOW
109+
for (uint16_t x = 0; x < rtcmConsumerBufferLengths[rtcmConsumerBufferTail]; x++)
110+
espNowProcessRTCM(dest[x]);
111+
112+
rtcmConsumerBufferTail = rtcmConsumerBufferTail + 1; // Increment the Tail
113+
rtcmConsumerBufferTail = rtcmConsumerBufferTail % rtcmConsumerBufferEntries; // Wrap
114+
}
115+
}
116+
117+
//----------------------------------------
118+
// Store data ready to be passed along to NTRIP Server, or ESP-NOW radio
119+
// This function gets called when an RTCM packet passes parser check in processUart1Message() task
120+
//----------------------------------------
121+
void processRTCM(uint8_t *rtcmData, uint16_t dataLength)
122+
{
123+
storeRTCMForConsumers(rtcmData, dataLength);
20124

21125
rtcmLastPacketSent = millis();
22126
rtcmPacketsSent++;

Firmware/RTK_Everywhere/Begin.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ void beginBoard()
357357
pin_modeButton = 0;
358358
// 24, D2 : Status LED
359359
pin_baseStatusLED = 2;
360+
//pin_debug = 2; // On EVK we can use the Status LED for debug
360361
// 29, D5 : GNSS TP via 74LVC4066 switch
361362
pin_GNSS_TimePulse = 5;
362363
// 14, D12 : I2C1 SDA via 74LVC4066 switch
@@ -421,6 +422,10 @@ void beginBoard()
421422
pinMode(pin_baseStatusLED, OUTPUT);
422423
baseStatusLedOff();
423424

425+
DMW_if systemPrintf("pin_debug: %d\r\n", pin_debug);
426+
pinMode(pin_debug, OUTPUT);
427+
pinDebugOff();
428+
424429
DMW_if systemPrintf("pin_Cellular_Network_Indicator: %d\r\n", pin_Cellular_Network_Indicator);
425430
pinMode(pin_Cellular_Network_Indicator, INPUT);
426431

Firmware/RTK_Everywhere/Bluetooth.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -742,13 +742,13 @@ void bluetoothStop()
742742
{
743743
bluetoothSerialBle->flush(); // Complete any transfers
744744
bluetoothSerialBle->disconnect(); // Drop any clients
745-
bluetoothSerialBle->end(); // Release resources
745+
//bluetoothSerialBle->end(); // Release resources : causes FreeRTOS Task "BLEFlushTask_" should not return, Aborting now!
746746
//delete bluetoothSerialBle;
747747
//bluetoothSerialBle = nullptr;
748748

749749
bluetoothSerialBleCommands->flush(); // Complete any transfers
750750
bluetoothSerialBleCommands->disconnect(); // Drop any clients
751-
bluetoothSerialBleCommands->end(); // Release resources
751+
//bluetoothSerialBleCommands->end(); // Release resources : causes FreeRTOS Task "BLEFlushTask_" should not return, Aborting now!
752752
//delete bluetoothSerialBleCommands;
753753
//bluetoothSerialBleCommands = nullptr;
754754

@@ -776,13 +776,13 @@ void bluetoothStop()
776776
{
777777
bluetoothSerialBle->flush(); // Complete any transfers
778778
bluetoothSerialBle->disconnect(); // Drop any clients
779-
bluetoothSerialBle->end(); // Release resources
779+
//bluetoothSerialBle->end(); // Release resources : FreeRTOS Task "BLEFlushTask_" should not return, Aborting now!
780780
//delete bluetoothSerialBle;
781781
//bluetoothSerialBle = nullptr;
782782

783783
bluetoothSerialBleCommands->flush(); // Complete any transfers
784784
bluetoothSerialBleCommands->disconnect(); // Drop any clients
785-
bluetoothSerialBleCommands->end(); // Release resources
785+
//bluetoothSerialBleCommands->end(); // Release resources : FreeRTOS Task "BLEFlushTask_" should not return, Aborting now!
786786
//delete bluetoothSerialBleCommands;
787787
//bluetoothSerialBleCommands = nullptr;
788788

Firmware/RTK_Everywhere/Developer.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,11 @@ void ntripClientSettingsChanged() {}
238238
#ifndef COMPILE_NTRIP_SERVER
239239
bool ntripServerIsCasting(int serverIndex) {return false;}
240240
void ntripServerPrintStatus(int serverIndex) {systemPrintf("**NTRIP Server %d not compiled**\r\n", serverIndex);}
241-
void ntripServerProcessRTCM(int serverIndex, uint8_t incoming) {}
241+
void ntripServerSendRTCM(int serverIndex, uint8_t *rtcmData, uint16_t dataLength) {}
242242
void ntripServerStop(int serverIndex, bool shutdown) {online.ntripServer[serverIndex] = false;}
243243
void ntripServerUpdate() {}
244244
void ntripServerValidateTables() {}
245+
void ntripServerSettingsChanged(int serverIndex) {}
245246
#endif // COMPILE_NTRIP_SERVER
246247

247248
//----------------------------------------

Firmware/RTK_Everywhere/Display.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ void displayUpdate()
346346
break;
347347

348348
case (STATE_BASE_CASTER_NOT_STARTED):
349+
case (STATE_BASE_ASSIST_NOT_STARTED):
349350
case (STATE_BASE_NOT_STARTED):
350351
case (STATE_BASE_CONFIG_WAIT):
351352
displayBaseStart(0); // Show 'Base' while the system configures the Base
@@ -1281,6 +1282,7 @@ void setModeIcon(std::vector<iconPropertyBlinking> *iconList)
12811282
break;
12821283

12831284
case (STATE_BASE_CASTER_NOT_STARTED):
1285+
case (STATE_BASE_ASSIST_NOT_STARTED):
12841286
case (STATE_BASE_NOT_STARTED):
12851287
case (STATE_BASE_CONFIG_WAIT):
12861288
// Do nothing. Static display shown during state change.

Firmware/RTK_Everywhere/GNSS.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ typedef enum
2121
class GNSS
2222
{
2323
protected:
24-
float _altitude; // Altitude in meters
24+
double _altitude; // Altitude in meters
25+
double _geoidalSeparation; // Geoidal separation in meters
2526
float _horizontalAccuracy; // Horizontal position accuracy in meters
2627
double _latitude; // Latitude in degrees
2728
double _longitude; // Longitude in degrees
@@ -166,6 +167,9 @@ class GNSS
166167
// Returns the fix type or zero if not online
167168
virtual uint8_t getFixType();
168169

170+
// Returns the geoidal separation
171+
virtual double getGeoidalSeparation();
172+
169173
// Returns the hours of 24 hour clock or zero if not online
170174
virtual uint8_t getHour();
171175

Firmware/RTK_Everywhere/GNSS_LG290P.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ class GNSS_LG290P : GNSS
230230
// Returns the fix type or zero if not online
231231
uint8_t getFixType();
232232

233+
// Returns the geoidal separation
234+
double getGeoidalSeparation();
235+
233236
// Returns the hours of 24 hour clock or zero if not online
234237
uint8_t getHour();
235238

0 commit comments

Comments
 (0)