Skip to content

Commit d358a27

Browse files
committed
Move NTRIP settings change request to atomic function in NtripClient
1 parent 36c3962 commit d358a27

File tree

8 files changed

+116
-86
lines changed

8 files changed

+116
-86
lines changed

Firmware/RTK_Everywhere/Begin.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ void beginBoard()
240240
present.minCN0 = true;
241241
present.minElevation = true;
242242
present.dynamicModel = true;
243+
present.display_type = DISPLAY_MAX_NONE;
243244

244245
#ifdef COMPILE_IM19_IMU
245246
present.imu_im19 = true; // Allow tiltUpdate() to run

Firmware/RTK_Everywhere/Developer.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void networkVerifyTables() {}
6666
//----------------------------------------
6767

6868
void ntripClientPrintStatus() {systemPrintln("**NTRIP Client not compiled**");}
69+
void ntripClientSettingsChanged() {}
6970
void ntripClientStop(bool clientAllocated) {online.ntripClient = false;}
7071
void ntripClientUpdate() {}
7172
void ntripClientValidateTables() {}

Firmware/RTK_Everywhere/GNSS.ino

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -688,25 +688,29 @@ bool createGNSSPassthrough()
688688
{
689689
return createPassthrough("/updateGnssFirmware.txt");
690690
}
691+
691692
bool createPassthrough(const char *filename)
692693
{
693694
if (online.fs == false)
694695
return false;
695696

696697
if (LittleFS.exists(filename))
697698
{
698-
if (settings.debugGnss)
699+
if (settings.debugGnssConfig)
699700
systemPrintf("LittleFS %s already exists\r\n", filename);
700701
return true;
701702
}
702703

703-
File updateUm980Firmware = LittleFS.open(filename, FILE_WRITE);
704-
updateUm980Firmware.close();
704+
if (settings.debugGnssConfig)
705+
systemPrintf("Creating passthrough file: %s \r\n", filename);
706+
707+
File simpleFile = LittleFS.open(filename, FILE_WRITE);
708+
simpleFile.close();
705709

706710
if (LittleFS.exists(filename))
707711
return true;
708712

709-
if (settings.debugGnss)
713+
if (settings.debugGnssConfig)
710714
systemPrintf("Unable to create %s on LittleFS\r\n", filename);
711715
return false;
712716
}
@@ -833,17 +837,22 @@ bool gnssFirmwareCheckUpdateFile(const char *filename)
833837
//----------------------------------------
834838
void gnssFirmwareRemoveUpdate()
835839
{
836-
return gnssFirmwareRemoveUpdateFile("/updateGnssFirmware.txt");
840+
gnssFirmwareRemoveUpdateFile("/updateGnssFirmware.txt");
837841
}
842+
838843
void gnssFirmwareRemoveUpdateFile(const char *filename)
839844
{
840845
if (online.fs == false)
841846
return;
842847

848+
if (settings.debugGnssConfig)
849+
systemPrintf("Removing passthrough file: %s \r\n", filename);
850+
851+
Serial.println("1");
843852
if (LittleFS.exists(filename))
844853
{
845-
if (settings.debugGnss)
846-
systemPrintf("Removing %s\r\n", filename);
854+
Serial.println("2");
855+
delay(50);
847856

848857
LittleFS.remove(filename);
849858
}

Firmware/RTK_Everywhere/GNSS_UM980.ino

Lines changed: 79 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void GNSS_UM980::begin()
8585

8686
if (_um980->begin(*serialGNSS) == false) // Give the serial port over to the library
8787
{
88-
if (settings.debugGnss)
88+
if (settings.debugGnssConfig)
8989
systemPrintln("GNSS UM980 failed to begin. Trying again.");
9090

9191
// Try again with power on delay
@@ -179,8 +179,7 @@ bool GNSS_UM980::configureBase()
179179
// a surveyInStart().
180180
gnssConfigure(GNSS_CONFIG_MODEL);
181181

182-
// Request receiver to use new settings
183-
gnssConfigure(GNSS_CONFIG_MESSAGE_RATE_NMEA);
182+
// Request a change to Base RTCM
184183
gnssConfigure(GNSS_CONFIG_MESSAGE_RATE_RTCM_BASE);
185184

186185
return (true);
@@ -189,53 +188,35 @@ bool GNSS_UM980::configureBase()
189188
//----------------------------------------
190189
bool GNSS_UM980::configureOnce()
191190
{
192-
/*
193-
Set COM port baud rates,
194-
UM980 COM1 - Connected to ESP32 through switches. Not used.
195-
UM980 COM2 - To IMU.
196-
UM980 COM3 - BT, config and LoRa Radio. Configured for 115200 from begin().
197-
Set minCN0
198-
Set elevationAngle
199-
Set Constellations
200-
Set messages
201-
Enable selected NMEA messages on COM3
202-
Enable selected RTCM messages on COM3
203-
*/
204191
bool response = true;
205-
response &= setBaudRate(2, 115200); // UM980 UART2 is connected to the IMU
206-
if (response == false)
207-
systemPrintln("setBaudRate failed");
208192

209-
// Assume if we've made it this far, the UM980 UART3 is communicating
210-
// response &= setBaudRateComm(115200); // UM980 UART3 is connected to the switch, then ESP32
193+
if (settings.debugGnssConfig)
194+
systemPrintln("Configuring UM980");
211195

212-
// Signal group control is not currently exposed to the user, thus is not configured using gnssConfigure()
213196
// Read, modify, write
214-
if (_um980->isConfigurationPresent("CONFIG SIGNALGROUP 2") == false)
197+
198+
// Output must be disabled before sending SIGNALGROUP command in order to get the OK response
199+
disableAllOutput(); // Disable COM1/2/3
200+
201+
if (_um980->sendCommand("CONFIG SIGNALGROUP 2") == false)
215202
{
216-
// Output must be disabled before sending SIGNALGROUP command in order to get the OK response
217-
disableAllOutput(); // Disable COM1/2/3
203+
systemPrintln("Signal group 2 command failed");
204+
response = false;
205+
}
206+
else
207+
{
208+
systemPrintln("Enabling additional reception on UM980. This can take a few seconds.");
218209

219-
if (_um980->sendCommand("CONFIG SIGNALGROUP 2") == false)
210+
while (1)
220211
{
221-
systemPrintln("Signal group 2 command failed");
222-
response = false;
212+
delay(1000); // Wait for device to reboot
213+
if (_um980->isConnected())
214+
break;
215+
else
216+
systemPrintln("UM980 rebooting");
223217
}
224-
else
225-
{
226-
systemPrintln("Enabling additional reception on UM980. This can take a few seconds.");
227218

228-
while (1)
229-
{
230-
delay(1000); // Wait for device to reboot
231-
if (_um980->isConnected())
232-
break;
233-
else
234-
systemPrintln("UM980 rebooting");
235-
}
236-
237-
systemPrintln("UM980 has completed reboot.");
238-
}
219+
systemPrintln("UM980 has completed reboot.");
239220
}
240221

241222
if (response)
@@ -299,8 +280,7 @@ bool GNSS_UM980::configureRover()
299280
// Sets the dynamic model (Survey/UAV/Automotive) and puts the device into Rover mode
300281
gnssConfigure(GNSS_CONFIG_MODEL);
301282

302-
// Request a change to NMEA and Rover RTCM
303-
gnssConfigure(GNSS_CONFIG_MESSAGE_RATE_NMEA);
283+
// Request a change to Rover RTCM
304284
gnssConfigure(GNSS_CONFIG_MESSAGE_RATE_RTCM_ROVER);
305285

306286
return (true);
@@ -364,7 +344,7 @@ void GNSS_UM980::debuggingEnable()
364344
// Turn off all NMEA and RTCM
365345
void GNSS_UM980::disableAllOutput()
366346
{
367-
if (settings.debugGnss)
347+
if (settings.debugGnssConfig)
368348
systemPrintln("UM980 disable output");
369349

370350
// Turn off local noise before moving to other ports
@@ -712,7 +692,13 @@ uint8_t GNSS_UM980::getMinute()
712692
uint8_t GNSS_UM980::getMode()
713693
{
714694
if (online.gnss)
715-
return (_um980->getMode());
695+
{
696+
int mode = _um980->getMode();
697+
if (settings.debugGnssConfig)
698+
systemPrintf("getMode(): %d\r\n", mode);
699+
700+
return (mode);
701+
}
716702
return (0);
717703
}
718704

@@ -1466,7 +1452,7 @@ bool GNSS_UM980::setConstellations()
14661452
response &= _um980->enableConstellation(um980ConstellationCommands[constellationNumber].textCommand);
14671453
if (response == false)
14681454
{
1469-
if (settings.debugGnss)
1455+
if (settings.debugGnssConfig)
14701456
systemPrintf("setConstellations failed to enable constellation %s [%d].\r\n",
14711457
um980ConstellationCommands[constellationNumber].textName, constellationNumber);
14721458
return (false); // Don't attempt other messages, assume communication is down
@@ -1478,7 +1464,7 @@ bool GNSS_UM980::setConstellations()
14781464

14791465
if (response == false)
14801466
{
1481-
if (settings.debugGnss)
1467+
if (settings.debugGnssConfig)
14821468
systemPrintf("setConstellations failed to disable constellation %s [%d].\r\n",
14831469
um980ConstellationCommands[constellationNumber].textName, constellationNumber);
14841470
return (false); // Don't attempt other messages, assume communication is down
@@ -1642,7 +1628,7 @@ bool GNSS_UM980::setMessagesNMEA()
16421628

16431629
if (response == false)
16441630
{
1645-
if (settings.debugGnss)
1631+
if (settings.debugGnssConfig)
16461632
systemPrintf("setMessagesNMEA failed to set %0.2f for message %s [%d].\r\n",
16471633
settings.um980MessageRatesNMEA[messageNumber],
16481634
umMessagesNMEA[messageNumber].msgTextName, messageNumber);
@@ -1712,7 +1698,7 @@ bool GNSS_UM980::setMessagesRTCMBase()
17121698

17131699
if (response == false)
17141700
{
1715-
if (settings.debugGnss)
1701+
if (settings.debugGnssConfig)
17161702
systemPrintf("setMessagesRTCMBase failed to set %0.2f for message %s [%d].\r\n",
17171703
settings.um980MessageRatesRTCMBase[messageNumber],
17181704
umMessagesRTCM[messageNumber].msgTextName, messageNumber);
@@ -1753,7 +1739,7 @@ bool GNSS_UM980::setMessagesRTCMRover()
17531739
settings.um980MessageRatesRTCMRover[messageNumber]);
17541740
if (response == false)
17551741
{
1756-
if (settings.debugGnss)
1742+
if (settings.debugGnssConfig)
17571743
systemPrintf("setMessagesRTCMRover failed to set %0.2f for message %s [%d].\r\n",
17581744
settings.um980MessageRatesRTCMRover[messageNumber],
17591745
umMessagesRTCM[messageNumber].msgTextName, messageNumber);
@@ -1816,6 +1802,10 @@ bool GNSS_UM980::setModel(uint8_t modelNumber)
18161802
return (_um980->setModeRoverUAV());
18171803
else if (modelNumber == UM980_DYN_MODEL_AUTOMOTIVE)
18181804
return (_um980->setModeRoverAutomotive());
1805+
else
1806+
{
1807+
systemPrintf("Uncaught model: %d\r\n", modelNumber);
1808+
}
18191809
}
18201810
return (false);
18211811
}
@@ -1922,13 +1912,13 @@ bool GNSS_UM980::setTilt()
19221912

19231913
// Read, modify, write
19241914
// The UM980 does not have a way to read the currently enabled messages so we do only a write
1925-
19261915
if (settings.enableTiltCompensation == true)
19271916
{
19281917
// Configure UM980 to output binary and NMEA reports out COM2, connected to IM19 COM3
19291918
response &= _um980->sendCommand("BESTPOSB COM2 0.2"); // 5Hz
19301919
response &= _um980->sendCommand("PSRVELB COM2 0.2");
19311920
response &= _um980->setNMEAPortMessage("GPGGA", "COM2", 0.2); // 5Hz
1921+
response &= setBaudRate(2, 115200); // UM980 UART2 is connected to the IMU
19321922
}
19331923
else
19341924
{
@@ -2098,15 +2088,6 @@ bool GNSS_UM980::setRtcmRoverMessageRateByName(const char *msgName, uint8_t msgR
20982088

20992089
//----------------------------------------
21002090

2101-
//----------------------------------------
2102-
// Force UART connection to GNSS for firmware update on the next boot by special file in
2103-
// LittleFS
2104-
//----------------------------------------
2105-
bool createUm980Passthrough()
2106-
{
2107-
return createPassthrough("/updateUm980Firmware.txt");
2108-
}
2109-
21102091
//----------------------------------------
21112092
void um980FirmwareBeginUpdate()
21122093
{
@@ -2127,10 +2108,10 @@ void um980FirmwareBeginUpdate()
21272108
// This makes our job much easier...
21282109

21292110
// Flag that we are in direct connect mode. Button task will um980FirmwareRemoveUpdate and exit
2130-
inDirectConnectMode = true;
2111+
// inDirectConnectMode = true;
21312112

21322113
// Paint GNSS Update
2133-
paintGnssUpdate();
2114+
// paintGnssUpdate();
21342115

21352116
// Stop all UART tasks. Redundant
21362117
tasksStopGnssUart();
@@ -2163,8 +2144,8 @@ void um980FirmwareBeginUpdate()
21632144
while (1)
21642145
{
21652146
// Data coming from UM980 to external USB
2166-
if (serialGNSS->available()) // Note: use if, not while
2167-
Serial.write(serialGNSS->read());
2147+
// if (serialGNSS->available()) // Note: use if, not while
2148+
// Serial.write(serialGNSS->read());
21682149

21692150
// Data coming from external USB to UM980
21702151
if (Serial.available()) // Note: use if, not while
@@ -2188,24 +2169,56 @@ void um980FirmwareBeginUpdate()
21882169
}
21892170
}
21902171

2172+
if (digitalRead(pin_powerButton) == HIGH)
2173+
{
2174+
while (digitalRead(pin_powerButton) == HIGH)
2175+
delay(100);
2176+
2177+
// Remove file and reset to exit pass-through mode
2178+
um980FirmwareRemoveUpdate();
2179+
2180+
// Beep to indicate exit
2181+
beepOn();
2182+
delay(300);
2183+
beepOff();
2184+
delay(100);
2185+
beepOn();
2186+
delay(300);
2187+
beepOff();
2188+
2189+
systemPrintln("Exiting UM980 passthrough mode");
2190+
systemFlush(); // Complete prints
2191+
2192+
ESP.restart();
2193+
}
21912194
// Button task will um980FirmwareRemoveUpdate and restart
21922195
}
21932196
}
21942197

2198+
const char *um980FirmwareFileName = "/updateUm980Firmware.txt";
2199+
2200+
//----------------------------------------
2201+
// Force UART connection to GNSS for firmware update on the next boot by special file in LittleFS
2202+
//----------------------------------------
2203+
bool um980CreatePassthrough()
2204+
{
2205+
return createPassthrough(um980FirmwareFileName);
2206+
}
2207+
21952208
//----------------------------------------
21962209
// Check if direct connection file exists
21972210
//----------------------------------------
21982211
bool um980FirmwareCheckUpdate()
21992212
{
2200-
return gnssFirmwareCheckUpdateFile("/updateUm980Firmware.txt");
2213+
return gnssFirmwareCheckUpdateFile(um980FirmwareFileName);
22012214
}
22022215

22032216
//----------------------------------------
22042217
// Remove direct connection file
22052218
//----------------------------------------
22062219
void um980FirmwareRemoveUpdate()
22072220
{
2208-
return gnssFirmwareRemoveUpdateFile("/updateUm980Firmware.txt");
2221+
gnssFirmwareRemoveUpdateFile(um980FirmwareFileName);
22092222
}
22102223

22112224
//----------------------------------------

0 commit comments

Comments
 (0)