@@ -203,22 +203,23 @@ bool ntripServerConnectCaster(int serverIndex)
203
203
}
204
204
205
205
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 ,
207
207
settings.ntripServer_CasterHost ,
208
208
settings.ntripServer_CasterPort );
209
209
210
210
// Attempt a connection to the NTRIP caster
211
211
if (!ntripServer->networkClient ->connect (settings.ntripServer_CasterHost , settings.ntripServer_CasterPort ))
212
212
{
213
213
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,
215
216
settings.ntripServer_CasterHost ,
216
217
settings.ntripServer_CasterPort );
217
218
return false ;
218
219
}
219
220
220
221
if (settings.debugNtripServerState )
221
- systemPrintln (" NTRIP Server sending authorization credentials" );
222
+ systemPrintf (" NTRIP Server %d sending authorization credentials\r\n " , serverIndex );
222
223
223
224
// Build the authorization credentials message
224
225
// * Mount point
@@ -274,14 +275,14 @@ bool ntripServerConnectLimitReached(int serverIndex)
274
275
{
275
276
seconds = ntripServer->connectionAttemptTimeout / 1000 ;
276
277
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);
278
279
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 );
280
281
}
281
282
}
282
283
else
283
284
// No more connection attempts
284
- systemPrintln (" NTRIP Server connection attempts exceeded!" );
285
+ systemPrintf (" NTRIP Server %d connection attempts exceeded!\r\n " , serverIndex );
285
286
return limitReached;
286
287
}
287
288
@@ -325,7 +326,7 @@ void ntripServerPrintStatus (int serverIndex)
325
326
if (settings.enableNtripServer == true &&
326
327
(systemState >= STATE_BASE_NOT_STARTED && systemState <= STATE_BASE_FIXED_TRANSMITTING))
327
328
{
328
- systemPrint (" NTRIP Server " );
329
+ systemPrintf (" NTRIP Server %d " , serverIndex );
329
330
ntripServerPrintStateSummary (serverIndex);
330
331
systemPrintf (" - %s/%s:%d" , settings.ntripServer_CasterHost , settings.ntripServer_MountPoint ,
331
332
settings.ntripServer_CasterPort );
@@ -386,7 +387,7 @@ void ntripServerProcessRTCM(int serverIndex, uint8_t incoming)
386
387
struct tm timeinfo = rtc.getTimeStruct ();
387
388
char timestamp[30 ];
388
389
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);
390
391
zedBytesSent = 0 ;
391
392
}
392
393
previousMilliseconds = currentMilliseconds;
@@ -396,7 +397,7 @@ void ntripServerProcessRTCM(int serverIndex, uint8_t incoming)
396
397
if (((millis () - ntripServer->timer ) > 100 ) && (ntripServer->bytesSent > 0 ))
397
398
{
398
399
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 );
400
401
401
402
ntripServer->bytesSent = 0 ;
402
403
}
@@ -450,20 +451,22 @@ void ntripServerRestart(int serverIndex)
450
451
// Update the state of the NTRIP server state machine
451
452
void ntripServerSetState (NTRIP_SERVER_DATA * ntripServer, uint8_t newState)
452
453
{
454
+ int serverIndex = ntripServer - &ntripServerArray[0 ];
455
+
453
456
if (settings.debugNtripServerState || PERIODIC_DISPLAY (PD_NTRIP_SERVER_STATE))
454
457
{
455
458
if (ntripServer->state == newState)
456
- systemPrint ( " * " );
459
+ systemPrintf ( " %d: * " , serverIndex );
457
460
else
458
- systemPrintf (" %s --> " , ntripServerStateName[ntripServer->state ]);
461
+ systemPrintf (" %d: % s --> " , serverIndex , ntripServerStateName[ntripServer->state ]);
459
462
}
460
463
ntripServer->state = newState;
461
464
if (settings.debugNtripServerState || PERIODIC_DISPLAY (PD_NTRIP_SERVER_STATE))
462
465
{
463
466
PERIODIC_CLEAR (PD_NTRIP_SERVER_STATE);
464
467
if (newState >= NTRIP_SERVER_STATE_MAX)
465
468
{
466
- systemPrintf (" Unknown NTRIP Server state: %d\r\n " , newState);
469
+ systemPrintf (" Unknown NTRIP Server %d state: %d\r\n " , serverIndex , newState);
467
470
reportFatalError (" Unknown NTRIP Server state" );
468
471
}
469
472
else
@@ -484,7 +487,7 @@ void ntripServerStart(int serverIndex)
484
487
reportHeapNow (settings.debugNtripServerState );
485
488
486
489
// Start the NTRIP server
487
- systemPrintln (" NTRIP Server start" );
490
+ systemPrintf (" NTRIP Server %d start\r\n " , serverIndex );
488
491
ntripServerStop (serverIndex, false );
489
492
}
490
493
@@ -581,7 +584,7 @@ void ntripServerUpdate(int serverIndex)
581
584
if (!ntripServer->networkClient )
582
585
{
583
586
// 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 );
585
588
ntripServerShutdown (serverIndex);
586
589
}
587
590
else
@@ -637,7 +640,7 @@ void ntripServerUpdate(int serverIndex)
637
640
{
638
641
// Assume service not available
639
642
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 );
641
644
}
642
645
else
643
646
{
@@ -662,7 +665,7 @@ void ntripServerUpdate(int serverIndex)
662
665
if (millis () - ntripServer->timer > 10000 )
663
666
{
664
667
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 );
666
669
}
667
670
}
668
671
else
@@ -672,32 +675,32 @@ void ntripServerUpdate(int serverIndex)
672
675
ntripServerResponse (serverIndex, response, sizeof (response));
673
676
674
677
if (settings.debugNtripServerState )
675
- systemPrintf (" Server Response: %s\r\n " , response);
678
+ systemPrintf (" Server %d Response: %s\r\n " , serverIndex , response);
676
679
else
677
- log_d (" Server Response: %s" , response);
680
+ log_d (" Server %d Response: %s" , serverIndex , response);
678
681
679
682
// Look for various responses
680
683
if (strstr (response, " 200" ) != nullptr ) // '200' found
681
684
{
682
685
// We got a response, now check it for possible errors
683
686
if (strcasestr (response, " banned" ) != nullptr )
684
687
{
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);
687
690
688
691
// Stop NTRIP Server operations
689
692
ntripServerShutdown (serverIndex);
690
693
}
691
694
else if (strcasestr (response, " sandbox" ) != nullptr )
692
695
{
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);
695
698
696
699
// Stop NTRIP Server operations
697
700
ntripServerShutdown (serverIndex);
698
701
}
699
702
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 ,
701
704
settings.ntripServer_CasterPort , settings.ntripServer_MountPoint );
702
705
703
706
// Connection is now open, start the RTCM correction data timer
@@ -713,8 +716,8 @@ void ntripServerUpdate(int serverIndex)
713
716
else if (strstr (response, " 401" ) != nullptr )
714
717
{
715
718
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);
718
721
719
722
// Give up - Shutdown NTRIP server, no further retries
720
723
ntripServerShutdown (serverIndex);
@@ -723,11 +726,11 @@ void ntripServerUpdate(int serverIndex)
723
726
// Other errors returned by the caster
724
727
else
725
728
{
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);
727
730
728
731
// Check for connection limit
729
732
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 );
731
734
}
732
735
}
733
736
break ;
@@ -743,13 +746,13 @@ void ntripServerUpdate(int serverIndex)
743
746
else if (!ntripServer->networkClient ->connected ())
744
747
{
745
748
// 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 );
747
750
ntripServerRestart (serverIndex);
748
751
}
749
752
else if ((millis () - ntripServer->timer ) > (15 * 1000 ))
750
753
{
751
754
// 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 );
753
756
ntripServerRestart (serverIndex);
754
757
}
755
758
else
@@ -767,7 +770,7 @@ void ntripServerUpdate(int serverIndex)
767
770
ntripServer->connectionAttempts = 0 ;
768
771
ntripServer->connectionAttemptTimeout = 0 ;
769
772
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 );
771
774
}
772
775
773
776
// All is well
0 commit comments