@@ -380,7 +380,7 @@ void ntripServerPrintStatus(int serverIndex)
380380 if (ntripServer->state == NTRIP_SERVER_CASTING)
381381 // Use ntripServer->timer since it gets reset after each successful data
382382 // reception from the NTRIP caster
383- milliseconds = ntripServer->timer - ntripServer-> startTime ;
383+ milliseconds = ntripServer->getUptime () ;
384384 else
385385 {
386386 milliseconds = ntripServer->startTime ;
@@ -434,20 +434,15 @@ void ntripServerProcessRTCM(int serverIndex, uint8_t incoming)
434434 }
435435
436436 // If we have not gotten new RTCM bytes for a period of time, assume end of frame
437- if (((millis () - ntripServer->timer ) > 100 ) && (ntripServer->bytesSent > 0 ))
438- {
439- if ((!inMainMenu) && settings.debugNtripServerRtcm )
440- systemPrintf (" NTRIP Server %d transmitted %d RTCM bytes to Caster\r\n " , serverIndex,
441- ntripServer->bytesSent );
442-
443- ntripServer->bytesSent = 0 ;
444- }
437+ if (ntripServer->checkBytesSentAndReset (100 ) && (!inMainMenu) && settings.debugNtripServerRtcm )
438+ systemPrintf (" NTRIP Server %d transmitted %d RTCM bytes to Caster\r\n " , serverIndex,
439+ ntripServer->bytesSent );
445440
446441 if (ntripServer->networkClient && ntripServer->networkClient ->connected ())
447442 {
448443 if (ntripServer->networkClient ->write (incoming) == 1 ) // Send this byte to socket
449444 {
450- ntripServer->updateAfterWrite ();
445+ ntripServer->updateTimerAndBytesSent ();
451446 netOutgoingRTCM = true ;
452447 while (ntripServer->networkClient ->available ())
453448 ntripServer->networkClient ->read (); // Absorb any unwanted incoming traffic
@@ -498,7 +493,7 @@ void ntripServerRestart(int serverIndex)
498493
499494 // Save the previous uptime value
500495 if (ntripServer->state == NTRIP_SERVER_CASTING)
501- ntripServer->startTime = ntripServer->timer - ntripServer-> startTime ;
496+ ntripServer->startTime = ntripServer->getUptime () ;
502497 ntripServerConnectLimitReached (serverIndex);
503498}
504499
@@ -576,7 +571,7 @@ void ntripServerStop(int serverIndex, bool shutdown)
576571 // Increase timeouts if we started the network
577572 if (ntripServer->state > NTRIP_SERVER_OFF)
578573 // Mark the Server stop so that we don't immediately attempt re-connect to Caster
579- ntripServer->timer = millis ();
574+ ntripServer->setTimerToMillis ();
580575
581576 // Determine the next NTRIP server state
582577 online.ntripServer [serverIndex] = false ;
@@ -707,7 +702,7 @@ void ntripServerUpdate(int serverIndex)
707702 // Initiate the connection to the NTRIP caster
708703 case NTRIP_SERVER_CONNECTING:
709704 // Delay before opening the NTRIP server connection
710- if (( millis () - ntripServer->timer ) >= ntripServer-> connectionAttemptTimeout )
705+ if (ntripServer->checkConnectionAttemptTimeout () )
711706 {
712707 // Attempt a connection to the NTRIP caster
713708 if (!ntripServerConnectCaster (serverIndex))
@@ -721,7 +716,7 @@ void ntripServerUpdate(int serverIndex)
721716 else
722717 {
723718 // Connection open to NTRIP caster, wait for the authorization response
724- ntripServer->timer = millis ();
719+ ntripServer->setTimerToMillis ();
725720 ntripServerSetState (serverIndex, NTRIP_SERVER_AUTHORIZATION);
726721 }
727722 }
@@ -734,7 +729,7 @@ void ntripServerUpdate(int serverIndex)
734729 strlen (" ICY 200 OK" )) // Wait until at least a few bytes have arrived
735730 {
736731 // Check for response timeout
737- if (( millis () - ntripServer->timer ) > 10000 )
732+ if (ntripServer->millisSinceTimer ( ) > 10000 )
738733 {
739734 if (ntripServerConnectLimitReached (serverIndex))
740735 systemPrintf (
@@ -781,7 +776,7 @@ void ntripServerUpdate(int serverIndex)
781776 settings.ntripServer_MountPoint [serverIndex]);
782777
783778 // Connection is now open, start the RTCM correction data timer
784- ntripServer->timer = millis ();
779+ ntripServer->setTimerToMillis ();
785780
786781 // We don't use a task because we use I2C hardware (and don't have a semaphore).
787782 online.ntripServer [serverIndex] = true ;
@@ -826,7 +821,7 @@ void ntripServerUpdate(int serverIndex)
826821 settings.ntripServer_CasterHost [serverIndex]);
827822 ntripServerRestart (serverIndex);
828823 }
829- else if (ntripServer->millisSinceLastWrite () > (10 * 1000 ))
824+ else if (ntripServer->millisSinceTimer () > (10 * 1000 ))
830825 {
831826 // GNSS stopped sending RTCM correction data
832827 systemPrintf (" NTRIP Server %d breaking connection to %s due to lack of RTCM data!\r\n " , serverIndex,
@@ -841,7 +836,7 @@ void ntripServerUpdate(int serverIndex)
841836 // connection. However increasing backoff delays should be
842837 // added when the NTRIP caster fails after a short connection
843838 // interval.
844- if ((ntripServer->millisSinceStart () > NTRIP_SERVER_CONNECTION_TIME) &&
839+ if ((ntripServer->millisSinceStartTime () > NTRIP_SERVER_CONNECTION_TIME) &&
845840 (ntripServer->connectionAttempts || ntripServer->connectionAttemptTimeout ))
846841 {
847842 // After a long connection period, reset the attempt counter
0 commit comments