5#if defined(CONFIG_IDF_TARGET_ESP32P4)
11EthernetProvisioner::EthernetProvisioner(
const EthernetConfig& config)
13 ESP_LOGI(__FILENAME__,
14 "Bringing up Ethernet (PHY type=%d addr=%d MDC=%d MDIO=%d "
15 "PWR=%d clk_mode=%d)",
16 (
int)config_.phy_type, (
int)config_.phy_addr, config_.mdc_pin,
17 config_.mdio_pin, config_.power_pin, (
int)config_.clock_mode);
44 String hostname = SensESPBaseApp::get_hostname();
46 [hostname](arduino_event_id_t, arduino_event_info_t) {
47 if (!ETH.setHostname(hostname.c_str())) {
49 "ETH.setHostname(\"%s\") failed in ETH_START handler",
53 "Ethernet hostname set to \"%s\" before DHCP DISCOVER",
57 ARDUINO_EVENT_ETH_START);
62 bool started = ETH.begin(config_.phy_type, config_.phy_addr, config_.mdc_pin,
63 config_.mdio_pin, config_.power_pin,
66 ESP_LOGE(__FILENAME__,
67 "ETH.begin() failed — check pin mapping and PHY power.");
71 ESP_LOGI(__FILENAME__,
72 "Ethernet driver started; waiting for PHY link + DHCP lease.");
75EthernetProvisioner::~EthernetProvisioner() {
81IPAddress EthernetProvisioner::local_ip()
const {
return ETH.localIP(); }
83IPAddress EthernetProvisioner::gateway_ip()
const {
return ETH.gatewayIP(); }
85String EthernetProvisioner::mac_address()
const {
return ETH.macAddress(); }
87bool EthernetProvisioner::is_connected()
const {
91 return ETH.linkUp() && ETH.hasIP();
94int EthernetProvisioner::link_speed_mbps()
const {
95 return ETH.linkUp() ? ETH.linkSpeed() : 0;
98bool EthernetProvisioner::is_full_duplex()
const {
99 return ETH.linkUp() && ETH.fullDuplex();