Skip to content

Commit b2963d5

Browse files
committed
TcpServer: Separate the tcpServerTimer from the tcpServerClientTimers
1 parent 72fb0bb commit b2963d5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Firmware/RTK_Everywhere/TcpServer.ino

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static const char * tcpServerName;
101101
// TCP server clients
102102
static volatile uint8_t tcpServerClientConnected;
103103
static volatile uint8_t tcpServerClientDataSent;
104+
static uint32_t tcpServerClientTimer[TCP_SERVER_MAX_CLIENTS];
104105
static volatile uint8_t tcpServerClientWriteError;
105106
static NetworkClient *tcpServerClient[TCP_SERVER_MAX_CLIENTS];
106107
static IPAddress tcpServerClientIpAddress[TCP_SERVER_MAX_CLIENTS];
@@ -335,8 +336,8 @@ void tcpServerClientUpdate(uint8_t index)
335336
// The client data structure is in use
336337
// Check for a working TCP server client connection
337338
clientConnected = tcpServerClient[index]->connected();
338-
dataSent = ((millis() - tcpServerTimer) < TCP_SERVER_CLIENT_DATA_TIMEOUT) ||
339-
(tcpServerClientDataSent & (1 << index));
339+
dataSent = ((millis() - tcpServerClientTimer[index]) < TCP_SERVER_CLIENT_DATA_TIMEOUT)
340+
|| (tcpServerClientDataSent & (1 << index));
340341
if ((clientConnected && dataSent) == false)
341342
{
342343
// Broken connection, shutdown the TCP server client link
@@ -419,6 +420,9 @@ void tcpServerClientUpdate(uint8_t index)
419420
}
420421
} // tcpServerInCasterMode
421422

423+
// Start the data timer
424+
tcpServerClientTimer[index] = millis();
425+
422426
// Make client online after any NTRIP injections so ring buffer can start outputting data to it
423427
tcpServerClientConnected = tcpServerClientConnected | (1 << index);
424428
tcpServerClientDataSent = tcpServerClientDataSent | (1 << index);
@@ -546,7 +550,7 @@ void tcpServerStopClient(int index)
546550
// Determine the shutdown reason
547551
connected = tcpServerClient[index]->connected()
548552
&& (!(tcpServerClientWriteError & (1 << index)));
549-
dataSent = ((millis() - tcpServerTimer) < TCP_SERVER_CLIENT_DATA_TIMEOUT)
553+
dataSent = ((millis() - tcpServerClientTimer[index]) < TCP_SERVER_CLIENT_DATA_TIMEOUT)
550554
|| (tcpServerClientDataSent & (1 << index));
551555
if (!dataSent)
552556
systemPrintf("%s: No data sent over %d seconds\r\n",

0 commit comments

Comments
 (0)