feat: keep Ethernet settings independent of the framework

Prepares the move to Arduino 3.x / ESP-IDF 5.5, which renumbers
eth_phy_type_t (ETH_PHY_GENERIC is now 0) and only has the RMII MAC
API on the original ESP32.

- Store the PHY chip as our own id (eth_phy_id_t, the 2.x values) and
  translate it by name at ETH.begin(), so NVS, backups and the web UI
  keep their numbers on either framework.
- Build Ethernet only where CONFIG_ETH_USE_ESP32_EMAC is set instead of
  everywhere but the C6.  C3 and S3 could never use it.  A stored
  Ethernet connection falls back to Wi-Fi on those chips.
- /networksettings reports hasEthernet; the UI hides the Ethernet
  options without it.
- Fix the UI PHY list: 5 is the KSZ8041, add the KSZ8081 (6), drop the
  DM9051, an SPI chip the MAC can't drive.
- SSDP takes its address from WiFi/ETH.localIP() instead of the
  tcpip_adapter API IDF 5 removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-19 21:13:49 +02:00
parent b74f382650
commit e1a62fe5be
12 changed files with 190 additions and 64 deletions

View file

@ -1,7 +1,5 @@
#include <ArduinoJson.h>
#ifndef CONFIG_IDF_TARGET_ESP32C6
#include <ETH.h>
#endif
#include "EthPhy.h"
#ifndef configsettings_h
#define configsettings_h
#include "WResp.h"
@ -94,17 +92,18 @@ class WifiSettings: BaseSettings {
void print();
};
#ifndef CONFIG_IDF_TARGET_ESP32C6
#if HAS_ETHERNET
class EthernetSettings: BaseSettings {
public:
EthernetSettings();
uint8_t boardType = 0; // These board types are enumerated in the ui and used to set the chip settings.
eth_phy_type_t phyType = ETH_PHY_LAN8720;
uint8_t phyType = static_cast<uint8_t>(eth_phy_id_t::LAN8720); // An eth_phy_id_t, see EthPhy.h.
eth_clock_mode_t CLKMode = ETH_CLOCK_GPIO0_IN;
int8_t phyAddress = ETH_PHY_ADDR;
int8_t PWRPin = ETH_PHY_POWER;
int8_t MDCPin = ETH_PHY_MDC;
int8_t MDIOPin = ETH_PHY_MDIO;
// The LAN8720 wiring Arduino 2.x defaulted to. 3.x has no defaults.
int8_t phyAddress = 0;
int8_t PWRPin = -1;
int8_t MDCPin = 23;
int8_t MDIOPin = 18;
bool begin();
bool fromJSON(JsonObject &obj);
@ -188,7 +187,7 @@ class ConfigSettings: BaseSettings {
uint8_t status;
IPSettings IP;
WifiSettings WIFI;
#ifndef CONFIG_IDF_TARGET_ESP32C6
#if HAS_ETHERNET
EthernetSettings Ethernet;
#endif
NTPSettings NTP;