From dec668386a5a7fdc993f9a9414852af85db1ec14 Mon Sep 17 00:00:00 2001 From: agessaman Date: Mon, 22 Jun 2026 21:28:18 -0700 Subject: [PATCH] fix(ota): improve OTA update handling for connected WiFi networks Updated the startOTAUpdate method to serve the ElegantOTA on the station IP when connected to a WiFi network, enhancing accessibility for OTA updates. If not connected, it defaults to the MeshCore-OTA SoftAP. This change improves the user experience by allowing easier access to OTA updates without needing to switch networks. --- src/helpers/ESP32Board.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/helpers/ESP32Board.cpp b/src/helpers/ESP32Board.cpp index 5eaa06c7..2306db15 100644 --- a/src/helpers/ESP32Board.cpp +++ b/src/helpers/ESP32Board.cpp @@ -12,9 +12,19 @@ bool ESP32Board::startOTAUpdate(const char* id, char reply[]) { inhibit_sleep = true; // prevent sleep during OTA - WiFi.softAP("MeshCore-OTA", NULL); - sprintf(reply, "Started: http://%s/update", WiFi.softAPIP().toString().c_str()); + // If the device is already on a WiFi network (e.g. an observer joined in STA + // mode), serve ElegantOTA on the station IP so it's reachable from the LAN + // without joining a separate AP. Otherwise raise the MeshCore-OTA SoftAP. + IPAddress ip; + if (WiFi.status() == WL_CONNECTED) { + ip = WiFi.localIP(); + } else { + WiFi.softAP("MeshCore-OTA", NULL); + ip = WiFi.softAPIP(); + } + + sprintf(reply, "Started: http://%s/update", ip.toString().c_str()); MESH_DEBUG_PRINTLN("startOTAUpdate: %s", reply); static char id_buf[60];