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()
493
493
// ----------------------------------------
494
494
// Get the network type
495
495
// ----------------------------------------
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
+ // ----------------------------------------
496
521
uint8_t networkGetType (uint8_t user)
497
522
{
498
523
NETWORK_DATA *network;
Original file line number Diff line number Diff line change @@ -589,19 +589,24 @@ void otaUpdate()
589
589
bool previouslyConnected = wifiIsConnected ();
590
590
591
591
bool wasInAPmode;
592
+ uint8_t networkType;
592
593
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
595
598
overTheAirUpdate ();
596
599
597
600
// 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 ();
604
605
606
+ // Update failed. If WiFi was originally off, turn it off again
607
+ if (previouslyConnected == false )
608
+ WIFI_STOP ();
609
+ }
605
610
#endif // COMPILE_NETWORK
606
611
}
607
612
You can’t perform that action at this time.
0 commit comments