diff --git a/src/helpers/ESP32Board.cpp b/src/helpers/ESP32Board.cpp index e0ca1d0e..de09e0f9 100644 --- a/src/helpers/ESP32Board.cpp +++ b/src/helpers/ESP32Board.cpp @@ -3,18 +3,29 @@ #include "ESP32Board.h" #if defined(ADMIN_PASSWORD) && !defined(DISABLE_WIFI_OTA) // Repeater or Room Server only -#include #include #include #include - #include -bool ESP32Board::startOTAUpdate(const char* id, char reply[]) { - inhibit_sleep = true; // prevent sleep during OTA - WiFi.softAP("MeshCore-OTA", NULL); +#if defined(USE_ETHERNET) + extern String eth_local_ip; // defined in TEthEliteBoard.cpp +#else + #include +#endif +bool ESP32Board::startOTAUpdate(const char* id, char reply[]) { + inhibit_sleep = true; + +#if defined(USE_ETHERNET) + Serial.println("OTA: using ETH"); + sprintf(reply, "Started: http://%s/update", eth_local_ip.c_str()); +#else + Serial.println("OTA: using WiFi SoftAP"); + WiFi.softAP("MeshCore-OTA", NULL); sprintf(reply, "Started: http://%s/update", WiFi.softAPIP().toString().c_str()); +#endif + MESH_DEBUG_PRINTLN("startOTAUpdate: %s", reply); static char id_buf[60]; @@ -32,7 +43,7 @@ bool ESP32Board::startOTAUpdate(const char* id, char reply[]) { }); AsyncElegantOTA.setID(id_buf); - AsyncElegantOTA.begin(server); // Start ElegantOTA + AsyncElegantOTA.begin(server); server->begin(); return true; @@ -44,4 +55,4 @@ bool ESP32Board::startOTAUpdate(const char* id, char reply[]) { } #endif -#endif +#endif // ESP_PLATFORM diff --git a/src/helpers/esp32/TEthEliteBoard.cpp b/src/helpers/esp32/TEthEliteBoard.cpp index 42c669a5..0e508ea6 100644 --- a/src/helpers/esp32/TEthEliteBoard.cpp +++ b/src/helpers/esp32/TEthEliteBoard.cpp @@ -14,6 +14,7 @@ extern MomentaryButton user_btn; uint32_t deviceOnline = 0x00; static SPIClass spi_eth(FSPI); static ETHClass2 ETH; +String eth_local_ip; // global, accessible from ESP32Board.cpp via extern void TEthEliteBoard::begin() { ESP32Board::begin(); @@ -152,6 +153,8 @@ void TEthEliteBoard::startEthernet() { ETH.config(IPAddress(192, 168, 4, 2), IPAddress(192, 168, 4, 1), IPAddress(255, 255, 255, 0)); } + eth_local_ip = ETH.localIP().toString(); // save IP for OTA use + uint8_t mac[6]; ETH.macAddress(mac); Serial.printf("ETH MAC %02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);