Skip to content

Commit fb5a536

Browse files
committed
Better NTRIP Server periodic printing
1 parent 946fd44 commit fb5a536

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

Firmware/RTK_Everywhere/NtripClient.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ void ntripClientSetState(uint8_t newState)
467467
{
468468
if (newState >= NTRIP_CLIENT_STATE_MAX)
469469
{
470-
systemPrintf("Unknown NTRIP Client state: %d\r\n", newState);
470+
systemPrintf("Unknown client state: %d\r\n", newState);
471471
reportFatalError("Unknown NTRIP Client state");
472472
}
473473
else

Firmware/RTK_Everywhere/NtripServer.ino

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -447,22 +447,30 @@ void ntripServerRestart(int serverIndex)
447447
// Update the state of the NTRIP server state machine
448448
void ntripServerSetState(NTRIP_SERVER_DATA *ntripServer, uint8_t newState)
449449
{
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+
}
451459

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)
453462
{
454463
if (ntripServer->state == newState)
455-
systemPrintf("%d: *", serverIndex);
464+
systemPrintf("NTRIP Server %d: *", serverIndex);
456465
else
457-
systemPrintf("%d: %s --> ", serverIndex, ntripServerStateName[ntripServer->state]);
466+
systemPrintf("NTRIP Server %d: %s --> ", serverIndex, ntripServerStateName[ntripServer->state]);
458467
}
459468
ntripServer->state = newState;
460-
if (settings.debugNtripServerState || PERIODIC_DISPLAY(PD_NTRIP_SERVER_STATE))
469+
if (settings.debugNtripServerState)
461470
{
462-
PERIODIC_CLEAR(PD_NTRIP_SERVER_STATE);
463471
if (newState >= NTRIP_SERVER_STATE_MAX)
464472
{
465-
systemPrintf("Unknown NTRIP Server %d state: %d\r\n", serverIndex, newState);
473+
systemPrintf("Unknown server state: %d\r\n", newState);
466474
reportFatalError("Unknown NTRIP Server state");
467475
}
468476
else
@@ -555,7 +563,11 @@ void ntripServerStop(int serverIndex, bool shutdown)
555563
// servers have disconnected?
556564
}
557565
else
566+
{
567+
if (settings.debugNtripServerState)
568+
systemPrintf("ntripServerStop server %d start requested\r\n", serverIndex);
558569
ntripServerSetState(ntripServer, NTRIP_SERVER_ON);
570+
}
559571
}
560572

561573
// Update the NTRIP server state machine
@@ -819,7 +831,11 @@ void ntripServerUpdate(int serverIndex)
819831

820832
// Periodically display the state
821833
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+
}
823839
}
824840

825841
// Update the NTRIP server state machine

0 commit comments

Comments
 (0)