Hi @CharlieT ,
You shouldn’t need to reboot the Thing each time the NTRIP connection drops out, but you do need a way to detect if the connection has dropped and then automatically reconnect. The following should work:
The loop() waits for the user to press a key and then calls beginServing(). beginServing() is the code which does all of the work, sending data to the NTRIP Server. When the connection drops, beginServing() exits and returns to the loop(). What you need is code to automatically call beginServing() after a suitable delay.
If you replace the loop():
void loop()
{
if (Serial.available())
beginServing();
Serial.println(F("Press any key to start serving"));
delay(1000);
}
with:
void loop()
{
if (Serial.available() || ((millis() - lastSentRTCM_ms) > (2 * maxTimeBeforeHangup_ms)))
beginServing();
Serial.println(F("Press any key to start serving"));
delay(1000);
}
it will do two things: the code will automatically start serving after 20 seconds (you won’t need to press a key to start serving); and the code will automatically reconnect to the server 10 seconds after the connection is dropped. What it won’t do is automatically reconnect to WiFi if your WiFi goes down, you will still need to power-cycle or reset the Thing to recover from that.
Claude is really good at making changes like this to your code. All you need to do is point it at the folder where your Base code is saved and then tell it in plain English what changes you want it to make. It would go something like this:
Read the Arduino code in folder "C:\Users\My_User\Documents\Arduino\Example14_NTRIPServer".
Adapt the code in the loop() so that it: automatically starts serving after a 20 second start-up delay; automatically reconnects to the NTRIP server 10 seconds after the connection drops.
Claude will ask for write permission on your Example14_NTRIPServer folder so it can write the changes. That’s OK. You can trust it.
If you want to automatically reconnect if your WiFi goes down, you can ask it to do that too:
Adapt the code in startup() and loop() so that the code will automatically reconnect to WiFi and the NTRIP Server if the WiFi link goes down.
Explain all of the changes you make as if you were explaining them to a novice programmer.
You can also ask it questions like this:
SparkFun are suggesting I change the loop() to the following. I am a novice programmer. Please explain how these changes will make the code automatically reconnect to the NTRIP Server.
void loop()
{
if (Serial.available() || ((millis() - lastSentRTCM_ms) > (2 * maxTimeBeforeHangup_ms)))
beginServing();
Serial.println(F("Press any key to start serving"));
delay(1000);
}
Claude is very, very good at this kind of thing…
I hope this helps,
Paul