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.
This commit is contained in:
agessaman committed 2026-06-22 21:28:18 -07:00
1 parent 3719ebb980
commit dec668386a
1 file changed
+12 -2
+12 -2
View File
@@ -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];