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:
1 parent
3719ebb980
commit
dec668386a
1 file changed
+12
-2
@@ -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];
|
||||
|
||||
Reference in new issue
Block a user