Skip to content

Commit 4b59aca

Browse files
committed
NtripServer: Use macro to compute NETCONSUMER_NTRIP_SERVER + serverIndex
1 parent e2ad3fd commit 4b59aca

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Firmware/RTK_Everywhere/NtripServer.ino

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ const int ntripServerStateNameEntries = sizeof(ntripServerStateName) / sizeof(nt
169169

170170
const RtkMode_t ntripServerMode = RTK_MODE_BASE_FIXED;
171171

172+
//----------------------------------------
173+
// Macros
174+
//----------------------------------------
175+
176+
#define NETWORK_CONSUMER(x) (NETCONSUMER_NTRIP_SERVER + x)
177+
172178
//----------------------------------------
173179
// Locals
174180
//----------------------------------------
@@ -557,7 +563,7 @@ void ntripServerStart(int serverIndex)
557563
systemPrintf("NTRIP Server %d start\r\n", serverIndex);
558564
ntripServerStop(serverIndex, false);
559565
if (ntripServerEnabled(serverIndex, nullptr))
560-
networkConsumerAdd(NETCONSUMER_NTRIP_SERVER + serverIndex, NETWORK_ANY, __FILE__, __LINE__);
566+
networkConsumerAdd(NETWORK_CONSUMER(serverIndex), NETWORK_ANY, __FILE__, __LINE__);
561567
}
562568

563569
//----------------------------------------
@@ -588,7 +594,7 @@ void ntripServerStop(int serverIndex, bool shutdown)
588594

589595
// Determine the next NTRIP server state
590596
online.ntripServer[serverIndex] = false;
591-
networkConsumerOffline(NETCONSUMER_NTRIP_SERVER + serverIndex);
597+
networkConsumerOffline(NETWORK_CONSUMER(serverIndex));
592598
if (shutdown)
593599
{
594600
if (settings.debugNtripServerState)
@@ -599,7 +605,7 @@ void ntripServerStop(int serverIndex, bool shutdown)
599605
systemPrintf("NTRIP Server %d caster port not configured!\r\n", serverIndex);
600606
if (settings.debugNtripServerState && (!settings.ntripServer_MountPoint[serverIndex][0]))
601607
systemPrintf("NTRIP Server %d mount point not configured!\r\n", serverIndex);
602-
networkConsumerRemove(NETCONSUMER_NTRIP_SERVER + serverIndex, NETWORK_ANY, __FILE__, __LINE__);
608+
networkConsumerRemove(NETWORK_CONSUMER(serverIndex), NETWORK_ANY, __FILE__, __LINE__);
603609
ntripServerSetState(ntripServer, NTRIP_SERVER_OFF);
604610
ntripServer->connectionAttempts = 0;
605611
ntripServer->connectionAttemptTimeout = 0;
@@ -635,7 +641,7 @@ void ntripServerUpdate(int serverIndex)
635641

636642
// Shutdown the NTRIP server when the mode or setting changes
637643
DMW_ds(ntripServerSetState, ntripServer);
638-
connected = networkConsumerIsConnected(NETCONSUMER_NTRIP_SERVER + serverIndex);
644+
connected = networkConsumerIsConnected(NETWORK_CONSUMER(serverIndex));
639645
enabled = ntripServerEnabled(serverIndex, &line);
640646
if (!enabled && (ntripServer->state > NTRIP_SERVER_OFF))
641647
ntripServerShutdown(serverIndex);
@@ -676,14 +682,14 @@ void ntripServerUpdate(int serverIndex)
676682
reportHeapNow(settings.debugNtripServerState);
677683

678684
// Reset the timeout when the network changes
679-
if (networkChanged(NETCONSUMER_NTRIP_SERVER + serverIndex))
685+
if (networkChanged(NETWORK_CONSUMER(serverIndex)))
680686
{
681687
ntripServer->connectionAttempts = 0;
682688
ntripServer->connectionAttemptTimeout = 0;
683689
}
684690

685691
// The network is available for the NTRIP server
686-
networkUserAdd(NETCONSUMER_NTRIP_SERVER + serverIndex, __FILE__, __LINE__);
692+
networkUserAdd(NETWORK_CONSUMER(serverIndex), __FILE__, __LINE__);
687693
ntripServerSetState(ntripServer, NTRIP_SERVER_NETWORK_CONNECTED);
688694
}
689695
}

0 commit comments

Comments
 (0)