Skip to content

Commit 56c100f

Browse files
committed
Allow firmware update checks over ethernet
Fix #369
1 parent 8ef7481 commit 56c100f

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

Firmware/RTK_Everywhere/Network.ino

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ Network.ino
143143
// Constants
144144
//----------------------------------------
145145

146-
#define NETWORK_CONNECTION_TIMEOUT (30 * 1000) // Timeout for network media connection - allow extra time for WiFiMulti scan
146+
#define NETWORK_CONNECTION_TIMEOUT \
147+
(30 * 1000) // Timeout for network media connection - allow extra time for WiFiMulti scan
147148
#define NETWORK_DELAY_BEFORE_RETRY (75 * 100) // Delay between network connection retries
148149
#define NETWORK_IP_ADDRESS_DISPLAY (12 * 1000) // Delay in milliseconds between display of IP address
149150
#define NETWORK_MAX_IDLE_TIME 500 // Maximum network idle time before shutdown
@@ -1390,4 +1391,19 @@ void networkVerifyTables()
13901391
reportFatalError("Fix networkUser table to match NetworkUsers");
13911392
}
13921393

1394+
// Returns true if this platform has the potential to connect to the internet
1395+
// Useful for testing if platform doesn't have ethernet, and doesn't have SSIDs
1396+
bool networkCanConnect()
1397+
{
1398+
// If the platform has ethernet, return true
1399+
if(present.ethernet_ws5500 == true)
1400+
return (true);
1401+
1402+
// If the platform does not have ethernet, check if we have SSIDs
1403+
if (wifiNetworkCount() > 0)
1404+
return (true);
1405+
1406+
return (false);
1407+
}
1408+
13931409
#endif // COMPILE_NETWORK

Firmware/RTK_Everywhere/menuFirmware.ino

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void menuFirmware()
9191

9292
else if (incoming == 'c')
9393
{
94-
if (wifiNetworkCount() == 0)
94+
if (networkCanConnect() == false)
9595
{
9696
systemPrintln("Error: Please enter at least one SSID before updating firmware");
9797
}
@@ -474,15 +474,14 @@ bool otaCheckVersion(char *versionAvailable, uint8_t versionAvailableLength)
474474
bool wasInAPmode;
475475

476476
uint8_t networkType = networkGetActiveType();
477-
if ((networkType == NETWORK_TYPE_WIFI)
478-
&& (wifiNetworkCount() == 0))
477+
if ((networkType == NETWORK_TYPE_WIFI) && (wifiNetworkCount() == 0))
479478
{
480479
systemPrintln("Error: Please enter at least one SSID before getting keys");
481480
}
482481
else
483482
{
484-
if ((networkType != NETWORK_TYPE_WIFI)
485-
|| (wifiConnect(settings.wifiConnectTimeoutMs, true, &wasInAPmode) == true)) // Use WIFI_AP_STA if already in WIFI_AP mode
483+
if ((networkType != NETWORK_TYPE_WIFI) || (wifiConnect(settings.wifiConnectTimeoutMs, true, &wasInAPmode) ==
484+
true)) // Use WIFI_AP_STA if already in WIFI_AP mode
486485
{
487486
char versionString[21];
488487
getFirmwareVersion(versionString, sizeof(versionString), enableRCFirmware);
@@ -522,8 +521,9 @@ bool otaCheckVersion(char *versionAvailable, uint8_t versionAvailableLength)
522521

523522
if (systemState != STATE_WIFI_CONFIG)
524523
{
525-
// WIFI_STOP() turns off the entire radio including the webserver. We need to turn off Station mode only.
526-
// For now, unit exits AP mode via reset so if we are in AP config mode, leave WiFi Station running.
524+
// WIFI_STOP() turns off the entire radio including the webserver. We need to turn off Station mode
525+
// only. For now, unit exits AP mode via reset so if we are in AP config mode, leave WiFi Station
526+
// running.
527527

528528
// If WiFi was originally off, turn it off again
529529
if (previouslyConnected == false)
@@ -579,7 +579,7 @@ void overTheAirUpdate()
579579
systemPrintln("OTA Update: Firmware server not available");
580580
else
581581
systemPrintln("OTA Update: OTA failed");
582-
#endif // COMPILE_NETWORK
582+
#endif // COMPILE_NETWORK
583583
}
584584

585585
// Start WiFi and perform the over-the-air update
@@ -590,7 +590,8 @@ void otaUpdate()
590590

591591
bool wasInAPmode;
592592

593-
if (wifiConnect(settings.wifiConnectTimeoutMs, true, &wasInAPmode) == true) // Use WIFI_AP_STA if already in WIFI_AP mode
593+
if (wifiConnect(settings.wifiConnectTimeoutMs, true, &wasInAPmode) ==
594+
true) // Use WIFI_AP_STA if already in WIFI_AP mode
594595
overTheAirUpdate();
595596

596597
// Update failed. If we were in WIFI_AP mode, return to WIFI_AP mode

0 commit comments

Comments
 (0)