Skip to content

Commit 9d8471e

Browse files
committed
TcpServer: Determine operating mode in tcpServerEnabled
1 parent 94169c4 commit 9d8471e

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Firmware/RTK_Everywhere/RTK_Everywhere.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ bool otaRequestFirmwareUpdate = false;
439439

440440
bool enableRCFirmware; // Goes true from AP config page
441441
bool currentlyParsingData; // Goes true when we hit 750ms timeout with new data
442+
bool tcpServerInCasterMode;// True when TCP server is running in caster mode
442443

443444
// Give up connecting after this number of attempts
444445
// Connection attempts are throttled to increase the time between attempts

Firmware/RTK_Everywhere/Tasks.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ void processUart1Message(SEMP_PARSE_STATE *parse, uint16_t type)
754754
// If BaseCasterOverride is enabled, remove everything but RTCM from the circular buffer
755755
// to avoid saturating the downstream radio link that is consuming over a TCP (NTRIP Caster) connection
756756
// Remove NMEA, etc after passing to the GNSS receiver library so that we still have SIV and other stats available
757-
if (settings.baseCasterOverride == true)
757+
if (tcpServerInCasterMode)
758758
{
759759
if (type != RTK_RTCM_PARSER_INDEX)
760760
{

Firmware/RTK_Everywhere/TcpServer.ino

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ int32_t tcpServerClientSendData(int index, uint8_t *data, uint16_t length)
171171
//----------------------------------------
172172
bool tcpServerEnabled(const char ** line)
173173
{
174+
bool casterMode;
174175
bool enabled;
175176
const char * name;
176177
uint16_t port;
@@ -192,13 +193,17 @@ bool tcpServerEnabled(const char ** line)
192193
{
193194
// TCP server running in Rover mode
194195
name = "TCP Server";
196+
casterMode = false;
195197
port = settings.tcpServerPort;
196198
}
197199

198200
// Determine if the base caster should be running
199201
else if (EQ_RTK_MODE(baseCasterMode)
200202
&& (settings.enableNtripCaster || settings.baseCasterOverride))
201203
{
204+
// TCP server running in caster mode
205+
casterMode = true;
206+
202207
// Select the base caster WiFi mode and port number
203208
if (settings.baseCasterOverride)
204209
{
@@ -224,11 +229,13 @@ bool tcpServerEnabled(const char ** line)
224229
{
225230
// Update the TCP server configuration
226231
tcpServerName = name;
232+
tcpServerInCasterMode = casterMode;
227233
tcpServerPort = port;
228234
}
229235

230236
// Shutdown and restart the TCP server when configuration changes
231237
else if ((name != tcpServerName)
238+
|| (casterMode != tcpServerInCasterMode)
232239
|| (port != tcpServerPort))
233240
{
234241
*line = ", Wrong state to switch configuration!";
@@ -603,7 +610,7 @@ void tcpServerUpdate()
603610

604611
// If we are acting as an NTRIP Caster, intercept the initial communication from the client
605612
// and respond accordingly
606-
if (settings.enableNtripCaster || settings.baseCasterOverride)
613+
if (tcpServerInCasterMode)
607614
{
608615
// Read response from client
609616
char response[512];
@@ -646,7 +653,7 @@ void tcpServerUpdate()
646653
if (settings.debugTcpServer)
647654
systemPrintf("Unknown response: %s\r\n", response);
648655
}
649-
} // settings.enableNtripCaster == true || settings.baseCasterOverride == true
656+
} // tcpServerInCasterMode
650657

651658
// Make client online after any NTRIP injections so ring buffer can start outputting data to it
652659
tcpServerClientConnected = tcpServerClientConnected | (1 << index);

0 commit comments

Comments
 (0)