@@ -517,7 +517,7 @@ bool otaCheckVersion(char *versionAvailable, uint8_t versionAvailableLength)
517
517
// If we were in WIFI_AP mode, return to WIFI_AP mode
518
518
// There may be some overlap with systemState STATE_WIFI_CONFIG ? Not sure...
519
519
if (wasInAPmode)
520
- WiFi. mode (WIFI_AP );
520
+ wifiSetApMode ( );
521
521
522
522
if (systemState != STATE_WIFI_CONFIG)
523
523
{
@@ -589,23 +589,36 @@ void otaUpdate()
589
589
bool previouslyConnected = wifiIsConnected ();
590
590
591
591
bool wasInAPmode;
592
- uint8_t networkType;
593
592
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
602
599
{
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 ();
605
604
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
+ }
609
622
}
610
623
#endif // COMPILE_NETWORK
611
624
}
0 commit comments