Skip to content

Commit b75f686

Browse files
committed
Add wifiStop sequence
Allows the network layer to shutdown WiFi if no consumers
1 parent 8eb02a1 commit b75f686

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

Firmware/RTK_Everywhere/WiFi.ino

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,19 @@ void wifiStart(NetIndex_t index, uintptr_t parameter, bool debug)
527527
//----------------------------------------
528528
// Wifi start sequence
529529
//----------------------------------------
530-
NETWORK_POLL_SEQUENCE wifiStartSequence[] =
531-
{ // State Parameter Description
532-
{wifiStart, 0, "Initialize Wifi"},
533-
{nullptr, 0, "Termination"},
530+
NETWORK_POLL_SEQUENCE wifiStartSequence[] = {
531+
// State Parameter Description
532+
{wifiStart, 0, "Initialize WiFi"},
533+
{nullptr, 0, "Termination"},
534+
};
535+
536+
//----------------------------------------
537+
// Wifi start sequence
538+
//----------------------------------------
539+
NETWORK_POLL_SEQUENCE wifiStopSequence[] = {
540+
// State Parameter Description
541+
{wifiStop, 0, "Shutdown WiFi"},
542+
{nullptr, 0, "Termination"},
534543
};
535544

536545
//----------------------------------------
@@ -571,11 +580,21 @@ void wifiStop()
571580
systemPrintln("WiFi Stopped");
572581
}
573582

583+
// Take the network offline
584+
networkMarkOffline(NETWORK_WIFI);
585+
574586
// Display the heap state
575587
reportHeapNow(settings.debugWifiState);
576588
wifiRunning = false;
577589
}
578590

591+
// Needed for wifiStopSequence
592+
void wifiStop(NetIndex_t index, uintptr_t parameter, bool debug)
593+
{
594+
wifiStop();
595+
networkSequenceNextEntry(NETWORK_WIFI, settings.debugNetworkLayer);
596+
}
597+
579598
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
580599
// WiFi Config Support Routines - compiled out
581600
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Firmware/RTK_Everywhere/menuFirmware.ino

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -979,9 +979,6 @@ void otaUpdate()
979979
char currentVersion[21];
980980
getFirmwareVersion(currentVersion, sizeof(currentVersion), enableRCFirmware);
981981

982-
Serial.printf("otaReportedVersion: %s\r\n", otaReportedVersion);
983-
Serial.printf("currentVersion: %s\r\n", currentVersion);
984-
985982
// If we are doing just a version check, set version number, turn off network request and stop machine
986983
if (otaRequestFirmwareVersionCheck == true)
987984
{

Firmware/RTK_Everywhere/settings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,7 @@ typedef struct _NETWORK_TABLE_ENTRY
18421842

18431843
// Sequence table declarations
18441844
extern NETWORK_POLL_SEQUENCE wifiStartSequence[];
1845+
extern NETWORK_POLL_SEQUENCE wifiStopSequence[];
18451846
extern NETWORK_POLL_SEQUENCE laraBootSequence[];
18461847
extern NETWORK_POLL_SEQUENCE laraOffSequence[];
18471848
extern NETWORK_POLL_SEQUENCE laraOnSequence[];
@@ -1858,7 +1859,7 @@ const NETWORK_TABLE_ENTRY networkInterfaceTable[] =
18581859
{&ETH, "Ethernet", &present.ethernet_ws5500, PD_ETHERNET_STATE, nullptr, nullptr, nullptr},
18591860
#endif // COMPILE_ETHERNET
18601861
#ifdef COMPILE_WIFI
1861-
{&WiFi.STA, "WiFi", nullptr, PD_WIFI_STATE, nullptr, wifiStartSequence, nullptr},
1862+
{&WiFi.STA, "WiFi", nullptr, PD_WIFI_STATE, nullptr, wifiStartSequence, wifiStopSequence},
18621863
#endif // COMPILE_WIFI
18631864
#ifdef COMPILE_CELLULAR
18641865
{&PPP, "Cellular", &present.cellular_lara, PD_CELLULAR_STATE, laraBootSequence, laraOnSequence, laraOffSequence},

0 commit comments

Comments
 (0)