Add OTA support via Ethernet for T-ETH-Elite

This commit is contained in:
Piero Andreini 2026-03-30 14:53:20 +02:00
parent add48e5cbe
commit b2be547c33
2 changed files with 21 additions and 7 deletions

View file

@ -3,18 +3,29 @@
#include "ESP32Board.h"
#if defined(ADMIN_PASSWORD) && !defined(DISABLE_WIFI_OTA) // Repeater or Room Server only
#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <AsyncElegantOTA.h>
#include <SPIFFS.h>
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 <WiFi.h>
#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

View file

@ -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]);