diff --git a/Firmware/RTK_Everywhere/NtripServer.ino b/Firmware/RTK_Everywhere/NtripServer.ino index f3e882abe..e03af9a99 100644 --- a/Firmware/RTK_Everywhere/NtripServer.ino +++ b/Firmware/RTK_Everywhere/NtripServer.ino @@ -434,9 +434,10 @@ void ntripServerProcessRTCM(int serverIndex, uint8_t incoming) } // If we have not gotten new RTCM bytes for a period of time, assume end of frame - if (ntripServer->checkBytesSentAndReset(100) && (!inMainMenu) && settings.debugNtripServerRtcm) + uint32_t totalBytesSent; + if (ntripServer->checkBytesSentAndReset(100, &totalBytesSent) && (!inMainMenu) && settings.debugNtripServerRtcm) systemPrintf("NTRIP Server %d transmitted %d RTCM bytes to Caster\r\n", serverIndex, - ntripServer->bytesSent); + totalBytesSent); if (ntripServer->networkClient && ntripServer->networkClient->connected()) { diff --git a/Firmware/RTK_Everywhere/TcpServer.ino b/Firmware/RTK_Everywhere/TcpServer.ino index ab86d2923..b4f115834 100644 --- a/Firmware/RTK_Everywhere/TcpServer.ino +++ b/Firmware/RTK_Everywhere/TcpServer.ino @@ -120,7 +120,7 @@ static const char * tcpServerName; static volatile uint8_t tcpServerClientConnected; static volatile uint8_t tcpServerClientDataSent; static volatile uint8_t tcpServerClientSendingData; -static uint32_t tcpServerClientTimer[TCP_SERVER_MAX_CLIENTS]; +static volatile uint32_t tcpServerClientTimer[TCP_SERVER_MAX_CLIENTS]; static volatile uint8_t tcpServerClientWriteError; static NetworkClient *tcpServerClient[TCP_SERVER_MAX_CLIENTS]; static IPAddress tcpServerClientIpAddress[TCP_SERVER_MAX_CLIENTS]; @@ -168,9 +168,12 @@ int32_t tcpServerClientSendData(int index, uint8_t *data, uint16_t length) length = tcpServerClient[index]->write(data, length); if (length > 0) { - // Update the data sent flag when data successfully sent + // Update the data sent flag and timer when data successfully sent if (length > 0) + { tcpServerClientDataSent = tcpServerClientDataSent | (1 << index); + tcpServerClientTimer[index] = millis(); + } if ((settings.debugTcpServer || PERIODIC_DISPLAY(PD_TCP_SERVER_CLIENT_DATA)) && (!inMainMenu)) systemPrintf("%s wrote %d bytes to %s\r\n", tcpServerName, length, diff --git a/Firmware/RTK_Everywhere/settings.h b/Firmware/RTK_Everywhere/settings.h index 383e48e35..18be8d845 100644 --- a/Firmware/RTK_Everywhere/settings.h +++ b/Firmware/RTK_Everywhere/settings.h @@ -519,7 +519,7 @@ typedef struct } } - bool checkBytesSentAndReset(uint32_t timerLimit) + bool checkBytesSentAndReset(uint32_t timerLimit, uint32_t *totalBytesSent) { bool retVal = false; if (serverSemaphore == NULL) @@ -529,6 +529,7 @@ typedef struct if (((millis() - timer) > timerLimit) && (bytesSent > 0)) { retVal = true; + *totalBytesSent = bytesSent; bytesSent = 0; } xSemaphoreGive(serverSemaphore);