Skip to content

Commit e94fd3f

Browse files
committed
Add the NTRIP Server number to the error messages
1 parent b5ea691 commit e94fd3f

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed

Firmware/RTK_Surveyor/NtripServer.ino

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -203,22 +203,23 @@ bool ntripServerConnectCaster(int serverIndex)
203203
}
204204

205205
if (settings.debugNtripServerState)
206-
systemPrintf("NTRIP Server connecting to %s:%d\r\n",
206+
systemPrintf("NTRIP Server %d connecting to %s:%d\r\n", serverIndex,
207207
settings.ntripServer_CasterHost,
208208
settings.ntripServer_CasterPort);
209209

210210
// Attempt a connection to the NTRIP caster
211211
if (!ntripServer->networkClient->connect(settings.ntripServer_CasterHost, settings.ntripServer_CasterPort))
212212
{
213213
if (settings.debugNtripServerState)
214-
systemPrintf("NTRIP Server connection to NTRIP caster %s:%d failed\r\n",
214+
systemPrintf("NTRIP Server %d connection to NTRIP caster %s:%d failed\r\n",
215+
serverIndex,
215216
settings.ntripServer_CasterHost,
216217
settings.ntripServer_CasterPort);
217218
return false;
218219
}
219220

220221
if (settings.debugNtripServerState)
221-
systemPrintln("NTRIP Server sending authorization credentials");
222+
systemPrintf("NTRIP Server %d sending authorization credentials\r\n", serverIndex);
222223

223224
// Build the authorization credentials message
224225
// * Mount point
@@ -274,14 +275,14 @@ bool ntripServerConnectLimitReached(int serverIndex)
274275
{
275276
seconds = ntripServer->connectionAttemptTimeout / 1000;
276277
if (seconds < 120)
277-
systemPrintf("NTRIP Server trying again in %d seconds.\r\n", seconds);
278+
systemPrintf("NTRIP Server %d trying again in %d seconds.\r\n", serverIndex, seconds);
278279
else
279-
systemPrintf("NTRIP Server trying again in %d minutes.\r\n", seconds / 60);
280+
systemPrintf("NTRIP Server %d trying again in %d minutes.\r\n", serverIndex, seconds / 60);
280281
}
281282
}
282283
else
283284
// No more connection attempts
284-
systemPrintln("NTRIP Server connection attempts exceeded!");
285+
systemPrintf("NTRIP Server %d connection attempts exceeded!\r\n", serverIndex);
285286
return limitReached;
286287
}
287288

@@ -325,7 +326,7 @@ void ntripServerPrintStatus (int serverIndex)
325326
if (settings.enableNtripServer == true &&
326327
(systemState >= STATE_BASE_NOT_STARTED && systemState <= STATE_BASE_FIXED_TRANSMITTING))
327328
{
328-
systemPrint("NTRIP Server ");
329+
systemPrintf("NTRIP Server %d ", serverIndex);
329330
ntripServerPrintStateSummary(serverIndex);
330331
systemPrintf(" - %s/%s:%d", settings.ntripServer_CasterHost, settings.ntripServer_MountPoint,
331332
settings.ntripServer_CasterPort);
@@ -386,7 +387,7 @@ void ntripServerProcessRTCM(int serverIndex, uint8_t incoming)
386387
struct tm timeinfo = rtc.getTimeStruct();
387388
char timestamp[30];
388389
strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S", &timeinfo);
389-
systemPrintf(" Tx RTCM: %s.%03ld, %d bytes sent\r\n", timestamp, rtc.getMillis(), zedBytesSent);
390+
systemPrintf(" Tx%d RTCM: %s.%03ld, %d bytes sent\r\n", serverIndex, timestamp, rtc.getMillis(), zedBytesSent);
390391
zedBytesSent = 0;
391392
}
392393
previousMilliseconds = currentMilliseconds;
@@ -396,7 +397,7 @@ void ntripServerProcessRTCM(int serverIndex, uint8_t incoming)
396397
if (((millis() - ntripServer->timer) > 100) && (ntripServer->bytesSent > 0))
397398
{
398399
if ((!inMainMenu) && settings.debugNtripServerState)
399-
systemPrintf("NTRIP Server transmitted %d RTCM bytes to Caster\r\n", ntripServer->bytesSent);
400+
systemPrintf("NTRIP Server %d transmitted %d RTCM bytes to Caster\r\n", serverIndex, ntripServer->bytesSent);
400401

401402
ntripServer->bytesSent = 0;
402403
}
@@ -450,20 +451,22 @@ void ntripServerRestart(int serverIndex)
450451
// Update the state of the NTRIP server state machine
451452
void ntripServerSetState(NTRIP_SERVER_DATA * ntripServer, uint8_t newState)
452453
{
454+
int serverIndex = ntripServer - &ntripServerArray[0];
455+
453456
if (settings.debugNtripServerState || PERIODIC_DISPLAY(PD_NTRIP_SERVER_STATE))
454457
{
455458
if (ntripServer->state == newState)
456-
systemPrint("*");
459+
systemPrintf("%d: *", serverIndex);
457460
else
458-
systemPrintf("%s --> ", ntripServerStateName[ntripServer->state]);
461+
systemPrintf("%d: %s --> ", serverIndex, ntripServerStateName[ntripServer->state]);
459462
}
460463
ntripServer->state = newState;
461464
if (settings.debugNtripServerState || PERIODIC_DISPLAY(PD_NTRIP_SERVER_STATE))
462465
{
463466
PERIODIC_CLEAR(PD_NTRIP_SERVER_STATE);
464467
if (newState >= NTRIP_SERVER_STATE_MAX)
465468
{
466-
systemPrintf("Unknown NTRIP Server state: %d\r\n", newState);
469+
systemPrintf("Unknown NTRIP Server %d state: %d\r\n", serverIndex, newState);
467470
reportFatalError("Unknown NTRIP Server state");
468471
}
469472
else
@@ -484,7 +487,7 @@ void ntripServerStart(int serverIndex)
484487
reportHeapNow(settings.debugNtripServerState);
485488

486489
// Start the NTRIP server
487-
systemPrintln ("NTRIP Server start");
490+
systemPrintf("NTRIP Server %d start\r\n", serverIndex);
488491
ntripServerStop(serverIndex, false);
489492
}
490493

@@ -581,7 +584,7 @@ void ntripServerUpdate(int serverIndex)
581584
if (!ntripServer->networkClient)
582585
{
583586
// Failed to allocate the ntripServer structure
584-
systemPrintln("ERROR: Failed to allocate the ntripServer structure!");
587+
systemPrintf("ERROR: Failed to allocate the ntripServer %d structure!\r\n", serverIndex);
585588
ntripServerShutdown(serverIndex);
586589
}
587590
else
@@ -637,7 +640,7 @@ void ntripServerUpdate(int serverIndex)
637640
{
638641
// Assume service not available
639642
if (ntripServerConnectLimitReached(serverIndex)) // Update ntripServer->connectionAttemptTimeout
640-
systemPrintln("NTRIP Server failed to connect! Do you have your caster address and port correct?");
643+
systemPrintf("NTRIP Server %d failed to connect! Do you have your caster address and port correct?\r\n", serverIndex);
641644
}
642645
else
643646
{
@@ -662,7 +665,7 @@ void ntripServerUpdate(int serverIndex)
662665
if (millis() - ntripServer->timer > 10000)
663666
{
664667
if (ntripServerConnectLimitReached(serverIndex))
665-
systemPrintln("Caster failed to respond. Do you have your caster address and port correct?");
668+
systemPrintf("Caster %d failed to respond. Do you have your caster address and port correct?\r\n", serverIndex);
666669
}
667670
}
668671
else
@@ -672,32 +675,32 @@ void ntripServerUpdate(int serverIndex)
672675
ntripServerResponse(serverIndex, response, sizeof(response));
673676

674677
if (settings.debugNtripServerState)
675-
systemPrintf("Server Response: %s\r\n", response);
678+
systemPrintf("Server %d Response: %s\r\n", serverIndex, response);
676679
else
677-
log_d("Server Response: %s", response);
680+
log_d("Server %d Response: %s", serverIndex, response);
678681

679682
// Look for various responses
680683
if (strstr(response, "200") != nullptr) //'200' found
681684
{
682685
// We got a response, now check it for possible errors
683686
if (strcasestr(response, "banned") != nullptr)
684687
{
685-
systemPrintf("NTRIP Server connected to caster but caster responded with banned error: %s\r\n",
686-
response);
688+
systemPrintf("NTRIP Server %d connected to caster but caster responded with banned error: %s\r\n",
689+
serverIndex, response);
687690

688691
// Stop NTRIP Server operations
689692
ntripServerShutdown(serverIndex);
690693
}
691694
else if (strcasestr(response, "sandbox") != nullptr)
692695
{
693-
systemPrintf("NTRIP Server connected to caster but caster responded with sandbox error: %s\r\n",
694-
response);
696+
systemPrintf("NTRIP Server %d connected to caster but caster responded with sandbox error: %s\r\n",
697+
serverIndex, response);
695698

696699
// Stop NTRIP Server operations
697700
ntripServerShutdown(serverIndex);
698701
}
699702

700-
systemPrintf("NTRIP Server connected to %s:%d %s\r\n", settings.ntripServer_CasterHost,
703+
systemPrintf("NTRIP Server %d connected to %s:%d %s\r\n", serverIndex, settings.ntripServer_CasterHost,
701704
settings.ntripServer_CasterPort, settings.ntripServer_MountPoint);
702705

703706
// Connection is now open, start the RTCM correction data timer
@@ -713,8 +716,8 @@ void ntripServerUpdate(int serverIndex)
713716
else if (strstr(response, "401") != nullptr)
714717
{
715718
systemPrintf(
716-
"NTRIP Caster responded with unauthorized error: %s. Are you sure your caster credentials are correct?\r\n",
717-
response);
719+
"NTRIP Caster %d responded with unauthorized error: %s. Are you sure your caster credentials are correct?\r\n",
720+
serverIndex, response);
718721

719722
// Give up - Shutdown NTRIP server, no further retries
720723
ntripServerShutdown(serverIndex);
@@ -723,11 +726,11 @@ void ntripServerUpdate(int serverIndex)
723726
// Other errors returned by the caster
724727
else
725728
{
726-
systemPrintf("NTRIP Server connected but caster responded with problem: %s\r\n", response);
729+
systemPrintf("NTRIP Server %d connected but caster responded with problem: %s\r\n", serverIndex, response);
727730

728731
// Check for connection limit
729732
if (ntripServerConnectLimitReached(serverIndex))
730-
systemPrintln("NTRIP Server retry limit reached; do you have your caster address and port correct?");
733+
systemPrintf("NTRIP Server %d retry limit reached; do you have your caster address and port correct?\r\n", serverIndex);
731734
}
732735
}
733736
break;
@@ -743,13 +746,13 @@ void ntripServerUpdate(int serverIndex)
743746
else if (!ntripServer->networkClient->connected())
744747
{
745748
// Broken connection, retry the NTRIP connection
746-
systemPrintln("Connection to NTRIP Caster was lost");
749+
systemPrintf("Connection to NTRIP Caster %d was lost\r\n", serverIndex);
747750
ntripServerRestart(serverIndex);
748751
}
749752
else if ((millis() - ntripServer->timer) > (15 * 1000))
750753
{
751754
// GNSS stopped sending RTCM correction data
752-
systemPrintln("NTRIP Server breaking connection to caster due to lack of RTCM data!");
755+
systemPrintf("NTRIP Server %d breaking connection to caster due to lack of RTCM data!\r\n", serverIndex);
753756
ntripServerRestart(serverIndex);
754757
}
755758
else
@@ -767,7 +770,7 @@ void ntripServerUpdate(int serverIndex)
767770
ntripServer->connectionAttempts = 0;
768771
ntripServer->connectionAttemptTimeout = 0;
769772
if (settings.debugNtripServerState)
770-
systemPrintln("NTRIP Server resetting connection attempt counter and timeout");
773+
systemPrintf("NTRIP Server %d resetting connection attempt counter and timeout\r\n", serverIndex);
771774
}
772775

773776
// All is well

0 commit comments

Comments
 (0)