Skip to content

Commit 38aa82f

Browse files
committed
Match otaUpdate to otaCheckVersion
1 parent 3fd8fa5 commit 38aa82f

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

Firmware/RTK_Everywhere/menuFirmware.ino

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ bool otaCheckVersion(char *versionAvailable, uint8_t versionAvailableLength)
517517
// If we were in WIFI_AP mode, return to WIFI_AP mode
518518
// There may be some overlap with systemState STATE_WIFI_CONFIG ? Not sure...
519519
if (wasInAPmode)
520-
WiFi.mode(WIFI_AP);
520+
wifiSetApMode();
521521

522522
if (systemState != STATE_WIFI_CONFIG)
523523
{
@@ -589,23 +589,36 @@ void otaUpdate()
589589
bool previouslyConnected = wifiIsConnected();
590590

591591
bool wasInAPmode;
592-
uint8_t networkType;
593592

594-
networkType = networkGetType();
595-
if ((networkType != NETWORK_TYPE_WIFI)
596-
|| (wifiConnect(settings.wifiConnectTimeoutMs, true, &wasInAPmode)
597-
== true)) // Use WIFI_AP_STA if already in WIFI_AP mode
598-
overTheAirUpdate();
599-
600-
// Update failed. If we were in WIFI_AP mode, return to WIFI_AP mode
601-
if (networkType == NETWORK_TYPE_WIFI)
593+
uint8_t networkType = networkGetActiveType();
594+
if ((networkType == NETWORK_TYPE_WIFI) && (wifiNetworkCount() == 0))
595+
{
596+
systemPrintln("Error: Please enter at least one SSID before getting keys");
597+
}
598+
else
602599
{
603-
if (wasInAPmode)
604-
wifiSetApMode();
600+
if ((networkType != NETWORK_TYPE_WIFI)
601+
|| (wifiConnect(settings.wifiConnectTimeoutMs, true, &wasInAPmode)
602+
== true)) // Use WIFI_AP_STA if already in WIFI_AP mode
603+
overTheAirUpdate();
605604

606-
// Update failed. If WiFi was originally off, turn it off again
607-
if (previouslyConnected == false)
608-
WIFI_STOP();
605+
// Update failed. If we were in WIFI_AP mode, return to WIFI_AP mode
606+
if (networkType == NETWORK_TYPE_WIFI)
607+
{
608+
if (wasInAPmode)
609+
wifiSetApMode();
610+
611+
if (systemState != STATE_WIFI_CONFIG)
612+
{
613+
// WIFI_STOP() turns off the entire radio including the webserver. We need to turn off Station mode
614+
// only. For now, unit exits AP mode via reset so if we are in AP config mode, leave WiFi Station
615+
// running.
616+
617+
// If WiFi was originally off, turn it off again
618+
if (previouslyConnected == false)
619+
WIFI_STOP();
620+
}
621+
}
609622
}
610623
#endif // COMPILE_NETWORK
611624
}

0 commit comments

Comments
 (0)