File tree Expand file tree Collapse file tree 2 files changed +38
-8
lines changed
Expand file tree Collapse file tree 2 files changed +38
-8
lines changed Original file line number Diff line number Diff line change @@ -493,6 +493,31 @@ uint8_t networkGetActiveType()
493493// ----------------------------------------
494494// Get the network type
495495// ----------------------------------------
496+ uint8_t networkGetType ()
497+ {
498+ NETWORK_DATA *network;
499+
500+ // Return the current type if known
501+ network = networkGet (NETWORK_TYPE_ACTIVE, false );
502+ if (network && (network->type < NETWORK_TYPE_MAX))
503+ return network->type ;
504+
505+ // Network type not determined yet
506+ // Determine if this type will be Ethernet
507+ if (present.ethernet_ws5500 )
508+ {
509+ if ((settings.defaultNetworkType == NETWORK_TYPE_USE_DEFAULT)
510+ || (settings.defaultNetworkType == NETWORK_TYPE_ETHERNET))
511+ return NETWORK_TYPE_ETHERNET;
512+ }
513+
514+ // Type will be WiFi
515+ return NETWORK_TYPE_WIFI;
516+ }
517+
518+ // ----------------------------------------
519+ // Get the network type for a network user
520+ // ----------------------------------------
496521uint8_t networkGetType (uint8_t user)
497522{
498523 NETWORK_DATA *network;
Original file line number Diff line number Diff line change @@ -589,19 +589,24 @@ void otaUpdate()
589589 bool previouslyConnected = wifiIsConnected ();
590590
591591 bool wasInAPmode;
592+ uint8_t networkType;
592593
593- if (wifiConnect (settings.wifiConnectTimeoutMs , true , &wasInAPmode) ==
594- true ) // Use WIFI_AP_STA if already in WIFI_AP mode
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
595598 overTheAirUpdate ();
596599
597600 // Update failed. If we were in WIFI_AP mode, return to WIFI_AP mode
598- if (wasInAPmode)
599- wifiSetApMode ();
600-
601- // Update failed. If WiFi was originally off, turn it off again
602- if (previouslyConnected == false )
603- WIFI_STOP ();
601+ if (networkType == NETWORK_TYPE_WIFI)
602+ {
603+ if (wasInAPmode)
604+ wifiSetApMode ();
604605
606+ // Update failed. If WiFi was originally off, turn it off again
607+ if (previouslyConnected == false )
608+ WIFI_STOP ();
609+ }
605610#endif // COMPILE_NETWORK
606611}
607612
You can’t perform that action at this time.
0 commit comments