Skip to content

Commit 54c0955

Browse files
committed
TcpServer: Select WiFi mode in tcpServerEnabled
1 parent 9d8471e commit 54c0955

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Firmware/RTK_Everywhere/TcpServer.ino

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ static NetworkServer *tcpServer = nullptr;
9595
static uint16_t tcpServerPort;
9696
static uint8_t tcpServerState;
9797
static uint32_t tcpServerTimer;
98+
static bool tcpServerWiFiSoftAp;
9899
static const char * tcpServerName;
99100

100101
// TCP server clients
@@ -175,6 +176,7 @@ bool tcpServerEnabled(const char ** line)
175176
bool enabled;
176177
const char * name;
177178
uint16_t port;
179+
bool softAP;
178180

179181
do
180182
{
@@ -195,6 +197,7 @@ bool tcpServerEnabled(const char ** line)
195197
name = "TCP Server";
196198
casterMode = false;
197199
port = settings.tcpServerPort;
200+
softAP = false;
198201
}
199202

200203
// Determine if the base caster should be running
@@ -207,13 +210,17 @@ bool tcpServerEnabled(const char ** line)
207210
// Select the base caster WiFi mode and port number
208211
if (settings.baseCasterOverride)
209212
{
213+
// Using soft AP
210214
name = "Base Caster";
211215
port = 2101;
216+
softAP = true;
212217
}
213218
else
214219
{
215220
name = "NTRIP Caster";
221+
// Using WiFi station
216222
port = settings.tcpServerPort;
223+
softAP = false;
217224
}
218225
}
219226

@@ -231,12 +238,14 @@ bool tcpServerEnabled(const char ** line)
231238
tcpServerName = name;
232239
tcpServerInCasterMode = casterMode;
233240
tcpServerPort = port;
241+
tcpServerWiFiSoftAp = softAP;
234242
}
235243

236244
// Shutdown and restart the TCP server when configuration changes
237245
else if ((name != tcpServerName)
238246
|| (casterMode != tcpServerInCasterMode)
239-
|| (port != tcpServerPort))
247+
|| (port != tcpServerPort)
248+
|| (softAP != tcpServerWiFiSoftAp))
240249
{
241250
*line = ", Wrong state to switch configuration!";
242251
break;
@@ -468,7 +477,8 @@ void tcpServerUpdate()
468477

469478
// Shutdown the TCP server when the mode or setting changes
470479
DMW_st(tcpServerSetState, tcpServerState);
471-
connected = networkConsumerIsConnected(NETCONSUMER_TCP_SERVER);
480+
connected = networkConsumerIsConnected(NETCONSUMER_TCP_SERVER)
481+
|| (tcpServerWiFiSoftAp && wifiSoftApOnline);
472482
enabled = tcpServerEnabled(&line);
473483
if ((tcpServerState > TCP_SERVER_STATE_OFF) && !enabled)
474484
tcpServerStop();
@@ -517,7 +527,7 @@ void tcpServerUpdate()
517527
// Wait until the network is connected
518528
case TCP_SERVER_STATE_WAIT_FOR_NETWORK:
519529
// Wait until the network is connected to the media
520-
if (connected || wifiSoftApOnline)
530+
if (connected)
521531
{
522532
// Delay before starting the TCP server
523533
if ((millis() - tcpServerTimer) >= (1 * 1000))
@@ -538,7 +548,7 @@ void tcpServerUpdate()
538548
// Handle client connections and link failures
539549
case TCP_SERVER_STATE_RUNNING:
540550
// Determine if the network has failed
541-
if ((connected == false && wifiSoftApOnline == false) || (!settings.enableTcpServer && !settings.baseCasterOverride))
551+
if (connected == false)
542552
{
543553
if ((settings.debugTcpServer || PERIODIC_DISPLAY(PD_TCP_SERVER_DATA)) && (!inMainMenu))
544554
{

0 commit comments

Comments
 (0)