Skip to content

Commit a25f384

Browse files
committed
Revert "Merge pull request #525 from LeeLeahy2/fix-network-failover-detection"
This reverts commit ae201aa, reversing changes made to a145103.
1 parent cfbdc4f commit a25f384

File tree

12 files changed

+38
-70
lines changed

12 files changed

+38
-70
lines changed

Firmware/RTK_Everywhere/HTTP_Client.ino

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ static uint32_t httpClientConnectionAttemptTimeout = 5 * 1000L; // Wait 5s
5959
static int httpClientConnectionAttemptsTotal; // Count the number of connection attempts absolutely
6060

6161
static volatile uint32_t httpClientLastDataReceived; // Last time data was received via HTTP
62-
static NetPriority_t httpClientPriority = NETWORK_OFFLINE;
6362

6463
static NetworkClientSecure *httpSecureClient;
6564

@@ -276,7 +275,6 @@ void httpClientUpdate()
276275
case HTTP_CLIENT_ON: {
277276
if ((millis() - httpClientTimer) > httpClientConnectionAttemptTimeout)
278277
{
279-
httpClientPriority = NETWORK_OFFLINE;
280278
httpClientSetState(HTTP_CLIENT_NETWORK_STARTED);
281279
}
282280
break;
@@ -288,16 +286,16 @@ void httpClientUpdate()
288286
if (!httpClientModeNeeded)
289287
httpClientStop(true);
290288

291-
// Wait until the network is connected to the media
292-
else if (networkIsConnected(&httpClientPriority))
289+
// Wait until the network is connected
290+
else if (networkHasInternet())
293291
httpClientSetState(HTTP_CLIENT_CONNECTING_2_SERVER);
294292
break;
295293
}
296294

297295
// Connect to the HTTP server
298296
case HTTP_CLIENT_CONNECTING_2_SERVER: {
299297
// Determine if the network has failed
300-
if (!networkIsConnected(&httpClientPriority))
298+
if (networkHasInternet() == false)
301299
{
302300
// Failed to connect to the network, attempt to restart the network
303301
httpClientStop(true); // Was httpClientRestart(); - #StopVsRestart
@@ -354,7 +352,7 @@ void httpClientUpdate()
354352

355353
case HTTP_CLIENT_CONNECTED: {
356354
// Determine if the network has failed
357-
if (!networkIsConnected(&httpClientPriority))
355+
if (networkHasInternet() == false)
358356
{
359357
// Failed to connect to the network, attempt to restart the network
360358
httpClientStop(true); // Was httpClientRestart(); - #StopVsRestart
@@ -558,7 +556,7 @@ void httpClientUpdate()
558556
// Hang here until httpClientModeNeeded is set to false by updateProvisioning
559557
case HTTP_CLIENT_COMPLETE: {
560558
// Determine if the network has failed
561-
if (!networkIsConnected(&httpClientPriority))
559+
if (networkHasInternet() == false)
562560
// Failed to connect to the network, attempt to restart the network
563561
httpClientStop(true); // Was httpClientRestart(); - #StopVsRestart
564562
break;

Firmware/RTK_Everywhere/MQTT_Client.ino

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ static uint32_t mqttClientConnectionAttemptTimeout;
138138
static int mqttClientConnectionAttemptsTotal; // Count the number of connection attempts absolutely
139139

140140
static volatile uint32_t mqttClientLastDataReceived; // Last time data was received via MQTT
141-
static NetPriority_t mqttClientPriority = NETWORK_OFFLINE;
142141

143142
static NetworkClientSecure *mqttSecureClient;
144143

@@ -723,7 +722,6 @@ void mqttClientUpdate()
723722
case MQTT_CLIENT_ON: {
724723
if ((millis() - mqttClientTimer) > mqttClientConnectionAttemptTimeout)
725724
{
726-
mqttClientPriority = NETWORK_OFFLINE;
727725
mqttClientSetState(MQTT_CLIENT_WAIT_FOR_NETWORK);
728726
}
729727
break;
@@ -736,15 +734,15 @@ void mqttClientUpdate()
736734
mqttClientStop(true);
737735

738736
// Wait until the network is connected to the media
739-
else if (networkIsConnected(&mqttClientPriority))
737+
else if (networkHasInternet())
740738
mqttClientSetState(MQTT_CLIENT_CONNECTING_2_SERVER);
741739
break;
742740
}
743741

744742
// Connect to the MQTT server
745743
case MQTT_CLIENT_CONNECTING_2_SERVER: {
746744
// Determine if the network has failed
747-
if (!networkIsConnected(&mqttClientPriority))
745+
if (networkHasInternet() == false)
748746
{
749747
// Failed to connect to the network, attempt to restart the network
750748
mqttClientStop(true); // Was mqttClientRestart(); - #StopVsRestart
@@ -890,7 +888,7 @@ void mqttClientUpdate()
890888

891889
case MQTT_CLIENT_SERVICES_CONNECTED: {
892890
// Determine if the network has failed
893-
if (!networkIsConnected(&mqttClientPriority))
891+
if (networkHasInternet() == false)
894892
{
895893
// Failed to connect to the network, attempt to restart the network
896894
mqttClientStop(true); // Was mqttClientRestart(); - #StopVsRestart

Firmware/RTK_Everywhere/NTP.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ const RtkMode_t ntpServerMode = RTK_MODE_NTP;
7575
// Locals
7676
//----------------------------------------
7777

78-
static NetPriority_t ntpServerPriority = NETWORK_OFFLINE;
7978
static NetworkUDP *ntpServer; // This will be instantiated when we know the NTP port
8079
static uint8_t ntpServerState;
8180
static uint32_t lastLoggedNTPRequest;
@@ -793,7 +792,6 @@ void ntpServerUpdate()
793792
// The NTP server only works over Ethernet
794793
if (networkInterfaceHasInternet(NETWORK_ETHERNET))
795794
{
796-
ntpServerPriority = NETWORK_OFFLINE;
797795
ntpServerSetState(NTP_STATE_NETWORK_CONNECTED);
798796
}
799797
}

Firmware/RTK_Everywhere/Network.ino

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -586,22 +586,6 @@ const char *networkGetNameByPriority(NetPriority_t priority)
586586
return "None";
587587
}
588588

589-
//----------------------------------------
590-
// Determine if the network is available
591-
//----------------------------------------
592-
bool networkIsConnected(NetPriority_t *clientPriority)
593-
{
594-
// If the client is using the highest priority network and that
595-
// network is still available then continue as normal
596-
if (networkHasInternet_bm && (*clientPriority == networkPriority))
597-
return (networkHasInternet_bm & (1 << networkIndexTable[networkPriority]))
598-
? true : false;
599-
600-
// The network has changed, notify the client of the change
601-
*clientPriority = networkPriority;
602-
return false;
603-
}
604-
605589
//----------------------------------------
606590
// Determine if the network interface is online
607591
//----------------------------------------

Firmware/RTK_Everywhere/NtripClient.ino

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ static volatile uint8_t ntripClientState = NTRIP_CLIENT_OFF;
187187
static int ntripClientConnectionAttempts; // Count the number of connection attempts between restarts
188188
static uint32_t ntripClientConnectionAttemptTimeout;
189189
static int ntripClientConnectionAttemptsTotal; // Count the number of connection attempts absolutely
190-
static NetPriority_t ntripClientPriority = NETWORK_OFFLINE;
191190

192191
// NTRIP client timer usage:
193192
// * Reconnection delay
@@ -563,7 +562,6 @@ void ntripClientUpdate()
563562

564563
// Start the network
565564
case NTRIP_CLIENT_ON:
566-
ntripClientPriority = NETWORK_OFFLINE;
567565
ntripClientSetState(NTRIP_CLIENT_WAIT_FOR_NETWORK);
568566
break;
569567

@@ -573,8 +571,8 @@ void ntripClientUpdate()
573571
if (ntripClientForcedShutdown || NEQ_RTK_MODE(ntripClientMode) || !settings.enableNtripClient)
574572
ntripClientStop(true);
575573

576-
// Wait until the network is connected to the media
577-
else if (networkIsConnected(&ntripClientPriority))
574+
// Wait until the network is connected
575+
else if (networkHasInternet())
578576
{
579577
// Allocate the ntripClient structure
580578
ntripClient = new NetworkClient();
@@ -596,7 +594,7 @@ void ntripClientUpdate()
596594

597595
case NTRIP_CLIENT_NETWORK_CONNECTED:
598596
// Determine if the network has failed
599-
if (!networkIsConnected(&ntripClientPriority))
597+
if (networkHasInternet() == false)
600598
// Failed to connect to to the network, attempt to restart the network
601599
ntripClientStop(true); // Was ntripClientRestart(); - #StopVsRestart
602600

@@ -629,7 +627,7 @@ void ntripClientUpdate()
629627

630628
case NTRIP_CLIENT_WAIT_RESPONSE:
631629
// Determine if the network has failed
632-
if (!networkIsConnected(&ntripClientPriority))
630+
if (networkHasInternet() == false)
633631
// Failed to connect to to the network, attempt to restart the network
634632
ntripClientStop(true); // Was ntripClientRestart(); - #StopVsRestart
635633

@@ -750,7 +748,7 @@ void ntripClientUpdate()
750748

751749
case NTRIP_CLIENT_CONNECTED:
752750
// Determine if the network has failed
753-
if (!networkIsConnected(&ntripClientPriority))
751+
if (networkHasInternet() == false)
754752
// Failed to connect to to the network, attempt to restart the network
755753
ntripClientStop(true); // Was ntripClientRestart(); - #StopVsRestart
756754

Firmware/RTK_Everywhere/NtripServer.ino

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ const RtkMode_t ntripServerMode = RTK_MODE_BASE_FIXED;
175175

176176
// NTRIP Servers
177177
static NTRIP_SERVER_DATA ntripServerArray[NTRIP_SERVER_MAX];
178-
static NetPriority_t ntripServerPriority = NETWORK_OFFLINE;
179178

180179
//----------------------------------------
181180
// NTRIP Server Routines
@@ -608,7 +607,6 @@ void ntripServerUpdate(int serverIndex)
608607

609608
// Start the network
610609
case NTRIP_SERVER_ON:
611-
ntripServerPriority = NETWORK_OFFLINE;
612610
ntripServerSetState(ntripServer, NTRIP_SERVER_WAIT_FOR_NETWORK);
613611
break;
614612

@@ -624,7 +622,7 @@ void ntripServerUpdate(int serverIndex)
624622
}
625623

626624
// Wait until the network is connected
627-
else if (networkIsConnected(&ntripServerPriority))
625+
else if (networkHasInternet())
628626
{
629627
// Allocate the networkClient structure
630628
ntripServer->networkClient = new NetworkClient();
@@ -647,7 +645,7 @@ void ntripServerUpdate(int serverIndex)
647645
// Network available
648646
case NTRIP_SERVER_NETWORK_CONNECTED:
649647
// Determine if the network has failed
650-
if (!networkIsConnected(&ntripServerPriority))
648+
if (networkHasInternet() == false)
651649
// Failed to connect to to the network, attempt to restart the network
652650
ntripServerStop(serverIndex, true); // Was ntripServerRestart(serverIndex); - #StopVsRestart
653651

@@ -665,7 +663,7 @@ void ntripServerUpdate(int serverIndex)
665663
// Wait for GNSS correction data
666664
case NTRIP_SERVER_WAIT_GNSS_DATA:
667665
// Determine if the network has failed
668-
if (!networkIsConnected(&ntripServerPriority))
666+
if (networkHasInternet() == false)
669667
// Failed to connect to to the network, attempt to restart the network
670668
ntripServerStop(serverIndex, true); // Was ntripServerRestart(serverIndex); - #StopVsRestart
671669

@@ -675,7 +673,7 @@ void ntripServerUpdate(int serverIndex)
675673
// Initiate the connection to the NTRIP caster
676674
case NTRIP_SERVER_CONNECTING:
677675
// Determine if the network has failed
678-
if (!networkIsConnected(&ntripServerPriority))
676+
if (networkHasInternet() == false)
679677
// Failed to connect to to the network, attempt to restart the network
680678
ntripServerStop(serverIndex, true); // Was ntripServerRestart(serverIndex); - #StopVsRestart
681679

@@ -703,7 +701,7 @@ void ntripServerUpdate(int serverIndex)
703701
// Wait for authorization response
704702
case NTRIP_SERVER_AUTHORIZATION:
705703
// Determine if the network has failed
706-
if (!networkIsConnected(&ntripServerPriority))
704+
if (networkHasInternet() == false)
707705
// Failed to connect to to the network, attempt to restart the network
708706
ntripServerStop(serverIndex, true); // Was ntripServerRestart(serverIndex); - #StopVsRestart
709707

@@ -797,7 +795,7 @@ void ntripServerUpdate(int serverIndex)
797795
// NTRIP server authorized to send RTCM correction data to NTRIP caster
798796
case NTRIP_SERVER_CASTING:
799797
// Determine if the network has failed
800-
if (!networkIsConnected(&ntripServerPriority))
798+
if (networkHasInternet() == false)
801799
// Failed to connect to the network, attempt to restart the network
802800
ntripServerStop(serverIndex, true); // Was ntripServerRestart(serverIndex); - #StopVsRestart
803801

Firmware/RTK_Everywhere/TcpClient.ino

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ const RtkMode_t tcpClientMode = RTK_MODE_BASE_FIXED | RTK_MODE_BASE_SURVEY_IN |
148148

149149
static NetworkClient *tcpClient;
150150
static IPAddress tcpClientIpAddress;
151-
static NetPriority_t tcpClientPriority = NETWORK_OFFLINE;
152151
static uint8_t tcpClientState;
153152
static volatile RING_BUFFER_OFFSET tcpClientTail;
154153
static volatile bool tcpClientWriteError;
@@ -417,7 +416,6 @@ void tcpClientUpdate()
417416
if (EQ_RTK_MODE(tcpClientMode) && settings.enableTcpClient)
418417
{
419418
timer = 0;
420-
tcpClientPriority = NETWORK_OFFLINE;
421419
tcpClientSetState(TCP_CLIENT_STATE_WAIT_FOR_NETWORK);
422420
}
423421
break;
@@ -429,7 +427,7 @@ void tcpClientUpdate()
429427
tcpClientStop();
430428

431429
// Wait until the network is connected
432-
else if (networkIsConnected(&tcpClientPriority))
430+
else if (networkHasInternet())
433431
{
434432
#ifdef COMPILE_WIFI
435433
// Determine if WiFi is required
@@ -465,7 +463,7 @@ void tcpClientUpdate()
465463
// Attempt the connection ot the TCP server
466464
case TCP_CLIENT_STATE_CLIENT_STARTING:
467465
// Determine if the network has failed
468-
if (!networkIsConnected(&tcpClientPriority))
466+
if (networkHasInternet() == false)
469467
// Failed to connect to to the network, attempt to restart the network
470468
tcpClientStop();
471469

@@ -510,7 +508,7 @@ void tcpClientUpdate()
510508
// Wait for the TCP client to shutdown or a TCP client link failure
511509
case TCP_CLIENT_STATE_CONNECTED:
512510
// Determine if the network has failed
513-
if (!networkIsConnected(&tcpClientPriority))
511+
if (networkHasInternet() == false)
514512
// Failed to connect to to the network, attempt to restart the network
515513
tcpClientStop();
516514

Firmware/RTK_Everywhere/TcpServer.ino

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ static volatile uint8_t tcpServerClientWriteError;
7676
static NetworkClient *tcpServerClient[TCP_SERVER_MAX_CLIENTS];
7777
static IPAddress tcpServerClientIpAddress[TCP_SERVER_MAX_CLIENTS];
7878
static volatile RING_BUFFER_OFFSET tcpServerClientTails[TCP_SERVER_MAX_CLIENTS];
79-
static NetPriority_t tcpServerPriority = NETWORK_OFFLINE;
8079

8180
//----------------------------------------
8281
// TCP Server handleGnssDataTask Support Routines
@@ -381,7 +380,6 @@ void tcpServerUpdate()
381380
{
382381
if (settings.debugTcpServer && (!inMainMenu))
383382
systemPrintln("TCP server start");
384-
tcpServerPriority = NETWORK_OFFLINE;
385383
tcpServerSetState(TCP_SERVER_STATE_WAIT_FOR_NETWORK);
386384
}
387385
break;
@@ -393,7 +391,7 @@ void tcpServerUpdate()
393391
tcpServerStop();
394392

395393
// Wait until the network is connected to the media
396-
else if (networkIsConnected(&tcpServerPriority))
394+
else if (networkHasInternet() || WIFI_SOFT_AP_RUNNING())
397395
{
398396
// Delay before starting the TCP server
399397
if ((millis() - tcpServerTimer) >= (1 * 1000))
@@ -411,7 +409,7 @@ void tcpServerUpdate()
411409
// Handle client connections and link failures
412410
case TCP_SERVER_STATE_RUNNING:
413411
// Determine if the network has failed
414-
if ((networkIsConnected(&tcpServerPriority) == false && WIFI_SOFT_AP_RUNNING() == false) || (!settings.enableTcpServer && !settings.baseCasterOverride))
412+
if ((networkHasInternet() == false && WIFI_SOFT_AP_RUNNING() == false) || (!settings.enableTcpServer && !settings.baseCasterOverride))
415413
{
416414
if ((settings.debugTcpServer || PERIODIC_DISPLAY(PD_TCP_SERVER_DATA)) && (!inMainMenu))
417415
{

Firmware/RTK_Everywhere/UdpServer.ino

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ static NetworkUDP *udpServer = nullptr;
9494
static uint8_t udpServerState;
9595
static uint32_t udpServerTimer;
9696
static volatile RING_BUFFER_OFFSET udpServerTail;
97-
static NetPriority_t udpServerPriority;
9897

9998
//----------------------------------------
10099
// UDP Server handleGnssDataTask Support Routines
@@ -107,7 +106,7 @@ int32_t udpServerSendDataBroadcast(uint8_t *data, uint16_t length)
107106
return 0;
108107

109108
// Send the data as broadcast
110-
if (settings.enableUdpServer && online.udpServer && networkIsConnected(&udpServerPriority))
109+
if (settings.enableUdpServer && online.udpServer && networkHasInternet())
111110
{
112111
IPAddress broadcastAddress = networkGetBroadcastIpAddress();
113112
udpServer->beginPacket(broadcastAddress, settings.udpServerPort);
@@ -325,7 +324,6 @@ void udpServerUpdate()
325324
{
326325
if (settings.debugUdpServer && (!inMainMenu))
327326
systemPrintln("UDP server starting the network");
328-
udpServerPriority = NETWORK_OFFLINE;
329327
udpServerSetState(UDP_SERVER_STATE_WAIT_FOR_NETWORK);
330328
}
331329
break;
@@ -337,7 +335,7 @@ void udpServerUpdate()
337335
udpServerStop();
338336

339337
// Wait until the network is connected
340-
else if (networkIsConnected(&udpServerPriority) || WIFI_SOFT_AP_RUNNING())
338+
else if (networkHasInternet() || WIFI_SOFT_AP_RUNNING())
341339
{
342340
// Delay before starting the UDP server
343341
if ((millis() - udpServerTimer) >= (1 * 1000))
@@ -355,7 +353,7 @@ void udpServerUpdate()
355353
// Handle client connections and link failures
356354
case UDP_SERVER_STATE_RUNNING:
357355
// Determine if the network has failed
358-
if ((networkIsConnected(&udpServerPriority) == false && WIFI_SOFT_AP_RUNNING() == false) || (!settings.enableUdpServer && !settings.baseCasterOverride))
356+
if ((networkHasInternet() == false && WIFI_SOFT_AP_RUNNING() == false) || (!settings.enableUdpServer && !settings.baseCasterOverride))
359357
{
360358
if ((settings.debugUdpServer || PERIODIC_DISPLAY(PD_UDP_SERVER_DATA)) && (!inMainMenu))
361359
{

0 commit comments

Comments
 (0)