Skip to content

Commit 8ef0a71

Browse files
committed
Gracefully fail if caster does not respond.
1 parent f1a26a5 commit 8ef0a71

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
Add ntripClient_TransmitGGA to AP config
4444
Add ntripServer_CasterUser/PW to AP config
4545
Add maxLogLength_minutes to AP config
46-
4746
*/
4847

4948
const int FIRMWARE_VERSION_MAJOR = 1;
@@ -425,6 +424,8 @@ bool firstPowerOn = true; //After boot, apply new settings to ZED if user switch
425424
unsigned long splashStart = 0; //Controls how long the splash is displayed for. Currently min of 2s.
426425
unsigned long clientWiFiStartTime = 0; //If we cannot connect to local wifi for NTRIP client, give up/go to Rover after 8 seconds
427426
bool restartRover = false; //If user modifies any NTRIP Client settings, we need to restart the rover
427+
int ntripClientConnectionAttempts = 0;
428+
int maxNtripClientConnectionAttempts = 3; //Give up connecting after this number of attempts
428429

429430
unsigned long startTime = 0; //Used for checking longest running functions
430431
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Firmware/RTK_Surveyor/States.ino

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,21 @@ void updateSystemState()
221221

222222
changeState(STATE_ROVER_CLIENT_STARTED);
223223
}
224+
else
225+
{
226+
log_d("Caster failed to connect. Trying again.");
227+
228+
if (ntripClientConnectionAttempts++ >= maxNtripClientConnectionAttempts)
229+
{
230+
Serial.println(F("Caster failed to connect. Do you have your caster address and port correct?"));
231+
ntripClient.stop();
232+
233+
stopWiFi(); //Turn off WiFi and release all resources
234+
startBluetooth(); //Turn on Bluetooth with 'Rover' name
235+
236+
changeState(STATE_ROVER_NO_FIX); //Start rover without WiFi
237+
}
238+
}
224239
#endif
225240
}
226241
break;

Firmware/RTK_Surveyor/menuSystem.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ void menuSystem()
5757
if (zedUartPassed == false)
5858
{
5959
stopUART2Tasks(); //Stop absoring ZED serial via task
60+
delay(250); //Wait for tasks to abort
6061

6162
//Clear out buffer before starting
6263
while (serialGNSS.available()) serialGNSS.read();
6364
serialGNSS.flush();
6465

65-
//begin() attempts 3 connections with X timeout per attempt
6666
SFE_UBLOX_GNSS myGNSS;
67-
if (myGNSS.begin(serialGNSS) == true)
67+
if (myGNSS.begin(serialGNSS) == true) //begin() attempts 3 connections
6868
{
6969
zedUartPassed = true;
7070
Serial.print(F("BT Online"));

0 commit comments

Comments
 (0)