@@ -447,22 +447,30 @@ void ntripServerRestart(int serverIndex)
447
447
// Update the state of the NTRIP server state machine
448
448
void ntripServerSetState (NTRIP_SERVER_DATA *ntripServer, uint8_t newState)
449
449
{
450
- int serverIndex = ntripServer - &ntripServerArray[0 ];
450
+ int serverIndex = -999 ;
451
+ for (int index = 0 ; index < NTRIP_SERVER_MAX; index++)
452
+ {
453
+ if (ntripServer == &ntripServerArray[index])
454
+ {
455
+ serverIndex = index;
456
+ break ;
457
+ }
458
+ }
451
459
452
- if (settings.debugNtripServerState || PERIODIC_DISPLAY (PD_NTRIP_SERVER_STATE))
460
+ // PERIODIC_DISPLAY(PD_NTRIP_SERVER_STATE) is handled by ntripServerUpdate
461
+ if (settings.debugNtripServerState )
453
462
{
454
463
if (ntripServer->state == newState)
455
- systemPrintf (" %d: *" , serverIndex);
464
+ systemPrintf (" NTRIP Server %d: *" , serverIndex);
456
465
else
457
- systemPrintf (" %d: %s --> " , serverIndex, ntripServerStateName[ntripServer->state ]);
466
+ systemPrintf (" NTRIP Server %d: %s --> " , serverIndex, ntripServerStateName[ntripServer->state ]);
458
467
}
459
468
ntripServer->state = newState;
460
- if (settings.debugNtripServerState || PERIODIC_DISPLAY (PD_NTRIP_SERVER_STATE) )
469
+ if (settings.debugNtripServerState )
461
470
{
462
- PERIODIC_CLEAR (PD_NTRIP_SERVER_STATE);
463
471
if (newState >= NTRIP_SERVER_STATE_MAX)
464
472
{
465
- systemPrintf (" Unknown NTRIP Server %d state: %d\r\n " , serverIndex , newState);
473
+ systemPrintf (" Unknown server state: %d\r\n " , newState);
466
474
reportFatalError (" Unknown NTRIP Server state" );
467
475
}
468
476
else
@@ -555,7 +563,11 @@ void ntripServerStop(int serverIndex, bool shutdown)
555
563
// servers have disconnected?
556
564
}
557
565
else
566
+ {
567
+ if (settings.debugNtripServerState )
568
+ systemPrintf (" ntripServerStop server %d start requested\r\n " , serverIndex);
558
569
ntripServerSetState (ntripServer, NTRIP_SERVER_ON);
570
+ }
559
571
}
560
572
561
573
// Update the NTRIP server state machine
@@ -819,7 +831,11 @@ void ntripServerUpdate(int serverIndex)
819
831
820
832
// Periodically display the state
821
833
if (PERIODIC_DISPLAY (PD_NTRIP_SERVER_STATE))
822
- ntripServerSetState (ntripServer, ntripServer->state );
834
+ {
835
+ systemPrintf (" NTRIP Server %d state: %s\r\n " , serverIndex, ntripServerStateName[ntripServer->state ]);
836
+ if (serverIndex == (NTRIP_SERVER_MAX - 1 ))
837
+ PERIODIC_CLEAR (PD_NTRIP_SERVER_STATE); // Clear the periodic display only on the last server
838
+ }
823
839
}
824
840
825
841
// Update the NTRIP server state machine
0 commit comments