Skip to content

Commit 3db3ce1

Browse files
committed
Firmware menu now does OTA over Ethernet
1 parent da88ba5 commit 3db3ce1

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

Firmware/RTK_Everywhere/Network.ino

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
//----------------------------------------
496521
uint8_t networkGetType(uint8_t user)
497522
{
498523
NETWORK_DATA *network;

Firmware/RTK_Everywhere/menuFirmware.ino

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)