3#if defined(USE_ETHERNET) && defined(USE_ESP32)
17#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)
18#ifdef USE_ETHERNET_LAN8720
19#include "esp_eth_phy_lan87xx.h"
21#ifdef USE_ETHERNET_RTL8201
22#include "esp_eth_phy_rtl8201.h"
24#ifdef USE_ETHERNET_DP83848
25#include "esp_eth_phy_dp83848.h"
27#ifdef USE_ETHERNET_IP101
28#include "esp_eth_phy_ip101.h"
30#ifdef USE_ETHERNET_KSZ8081
31#include "esp_eth_phy_ksz80xx.h"
33#ifdef USE_ETHERNET_W5500
34#include "esp_eth_mac_w5500.h"
35#include "esp_eth_phy_w5500.h"
37#ifdef USE_ETHERNET_DM9051
38#include "esp_eth_mac_dm9051.h"
39#include "esp_eth_phy_dm9051.h"
44#ifdef USE_ETHERNET_LAN8670
45#include "esp_eth_phy_lan867x.h"
49#ifdef USE_ETHERNET_ENC28J60
50#include "esp_eth_enc28j60.h"
54#ifdef USE_ETHERNET_CH390
55#include "esp_eth_mac_ch390.h"
56#include "esp_eth_phy_ch390.h"
59#ifdef USE_ETHERNET_SPI
60#include <driver/gpio.h>
61#include <driver/spi_master.h>
66static const char *
const TAG =
"ethernet";
69static constexpr size_t PHY_REG_SIZE = 2;
72 ESP_LOGE(TAG,
"%s: (%d) %s",
message, err, esp_err_to_name(err));
76#define ESPHL_ERROR_CHECK(err, message) \
77 if ((err) != ESP_OK) { \
78 this->log_error_and_mark_failed_(err, message); \
82#define ESPHL_ERROR_CHECK_RET(err, message, ret) \
83 if ((err) != ESP_OK) { \
84 this->log_error_and_mark_failed_(err, message); \
94 ESP_LOGI(TAG,
"Starting connection");
101 ESP_LOGI(TAG,
"Stopped connection");
105 ESP_LOGI(TAG,
"Connected");
110#ifdef USE_ETHERNET_CONNECT_TRIGGER
114 ESP_LOGW(TAG,
"Connecting failed; reconnecting");
120 ESP_LOGI(TAG,
"Stopped connection");
122#ifdef USE_ETHERNET_DISCONNECT_TRIGGER
126 ESP_LOGW(TAG,
"Connection lost; reconnecting");
129#ifdef USE_ETHERNET_DISCONNECT_TRIGGER
142 if (esp_reset_reason() != ESP_RST_DEEPSLEEP) {
154 ESPHL_ERROR_CHECK(err,
"ETH start error");
156 ESP_LOGCONFIG(TAG,
"Skipping init (enable_on_boot: false)");
167#ifdef USE_ETHERNET_SPI
169 gpio_install_isr_service(0);
171 spi_bus_config_t buscfg = {
181 .max_transfer_sz = 0,
188 err = spi_bus_initialize(host, &buscfg, SPI_DMA_CH_AUTO);
189 ESPHL_ERROR_CHECK(err,
"SPI bus initialize error");
193 esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH();
197 eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
198 eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
200#ifdef USE_ETHERNET_SPI
201 spi_device_interface_config_t devcfg = {
207 .cs_ena_pretrans = 0,
208 .cs_ena_posttrans = 0,
218#if defined(USE_ETHERNET_W5500)
219 eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(host, &devcfg);
220#elif defined(USE_ETHERNET_DM9051)
221 eth_dm9051_config_t dm9051_config = ETH_DM9051_DEFAULT_CONFIG(host, &devcfg);
222#elif defined(USE_ETHERNET_ENC28J60)
223 eth_enc28j60_config_t enc28j60_config = ETH_ENC28J60_DEFAULT_CONFIG(host, &devcfg);
224#elif defined(USE_ETHERNET_CH390)
225 eth_ch390_config_t ch390_config = ETH_CH390_DEFAULT_CONFIG(host, &devcfg);
228#if defined(USE_ETHERNET_W5500)
230#ifdef USE_ETHERNET_SPI_POLLING_SUPPORT
237#elif defined(USE_ETHERNET_DM9051)
239#ifdef USE_ETHERNET_SPI_POLLING_SUPPORT
242#elif defined(USE_ETHERNET_ENC28J60)
245 enc28j60_config.spi_devcfg->cs_ena_posttrans = enc28j60_cal_spi_cs_hold_time((this->
clock_speed_ + 999999) / 1000000);
247#elif defined(USE_ETHERNET_CH390)
249#ifdef USE_ETHERNET_SPI_POLLING_SUPPORT
257 esp_eth_mac_t *mac =
nullptr;
258#elif defined(USE_ETHERNET_OPENETH)
259 esp_eth_mac_t *mac = esp_eth_mac_new_openeth(&mac_config);
265#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
266 esp32_emac_config.smi_gpio.mdc_num = this->
mdc_pin_;
267 esp32_emac_config.smi_gpio.mdio_num = this->
mdio_pin_;
269 esp32_emac_config.smi_mdc_gpio_num = this->
mdc_pin_;
270 esp32_emac_config.smi_mdio_gpio_num = this->
mdio_pin_;
276 esp32_emac_config.clock_config.rmii.clock_mode = this->
clk_mode_;
277 esp32_emac_config.clock_config.rmii.clock_gpio =
278 static_cast<decltype(esp32_emac_config.clock_config.rmii.clock_gpio)
>(this->
clk_pin_);
281 esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config);
284 switch (this->
type_) {
285#ifdef USE_ETHERNET_OPENETH
287 phy_config.autonego_timeout_ms = 1000;
288#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)
289 this->
phy_ = esp_eth_phy_new_generic(&phy_config);
291 this->
phy_ = esp_eth_phy_new_dp83848(&phy_config);
296#if CONFIG_ETH_USE_ESP32_EMAC
297#ifdef USE_ETHERNET_LAN8720
299 this->
phy_ = esp_eth_phy_new_lan87xx(&phy_config);
303#ifdef USE_ETHERNET_RTL8201
305 this->
phy_ = esp_eth_phy_new_rtl8201(&phy_config);
309#ifdef USE_ETHERNET_DP83848
311 this->
phy_ = esp_eth_phy_new_dp83848(&phy_config);
315#ifdef USE_ETHERNET_IP101
317 this->
phy_ = esp_eth_phy_new_ip101(&phy_config);
321#ifdef USE_ETHERNET_JL1101
329#ifdef USE_ETHERNET_KSZ8081
332 this->
phy_ = esp_eth_phy_new_ksz80xx(&phy_config);
336#ifdef USE_ETHERNET_LAN8670
338 this->
phy_ = esp_eth_phy_new_lan867x(&phy_config);
342#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)
345#ifdef USE_ETHERNET_GENERIC
348#ifdef USE_ETHERNET_YT8531
351#if defined(USE_ETHERNET_GENERIC) || defined(USE_ETHERNET_YT8531)
352 this->
phy_ = esp_eth_phy_new_generic(&phy_config);
357#ifdef USE_ETHERNET_SPI
358#if defined(USE_ETHERNET_W5500)
360 mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
361 this->
phy_ = esp_eth_phy_new_w5500(&phy_config);
364#elif defined(USE_ETHERNET_DM9051)
366 mac = esp_eth_mac_new_dm9051(&dm9051_config, &mac_config);
367 this->
phy_ = esp_eth_phy_new_dm9051(&phy_config);
370#elif defined(USE_ETHERNET_ENC28J60)
372 mac = esp_eth_mac_new_enc28j60(&enc28j60_config, &mac_config);
373 this->
phy_ = esp_eth_phy_new_enc28j60(&phy_config);
376#elif defined(USE_ETHERNET_CH390)
378 mac = esp_eth_mac_new_ch390(&ch390_config, &mac_config);
379 this->
phy_ = esp_eth_phy_new_ch390(&phy_config);
390 esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, this->
phy_);
392 err = esp_eth_driver_install(ð_config, &this->
eth_handle_);
393 ESPHL_ERROR_CHECK(err,
"ETH driver install error");
395#ifndef USE_ETHERNET_SPI
396#ifdef USE_ETHERNET_KSZ8081
407#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)
408#ifdef USE_ETHERNET_GENERIC
416 bool autoneg_enable =
true;
417 err = esp_eth_ioctl(this->
eth_handle_, ETH_CMD_S_AUTONEGO, &autoneg_enable);
418 ESPHL_ERROR_CHECK(err,
"Enable auto-negotiation failed");
421#ifdef USE_ETHERNET_YT8531
432 uint8_t mac_addr[MAC_ADDRESS_SIZE];
434 memcpy(mac_addr, this->
fixed_mac_->data(), MAC_ADDRESS_SIZE);
436 esp_read_mac(mac_addr, ESP_MAC_ETH);
438 err = esp_eth_ioctl(this->
eth_handle_, ETH_CMD_S_MAC_ADDR, mac_addr);
439 ESPHL_ERROR_CHECK(err,
"set mac address error");
443 ESPHL_ERROR_CHECK(err,
"ETH netif attach error");
447 ESPHL_ERROR_CHECK(err,
"ETH event handler register error");
449 ESPHL_ERROR_CHECK(err,
"GOT IP event handler register error");
452 ESPHL_ERROR_CHECK(err,
"GOT IPv6 event handler register error");
462 ESP_LOGD(TAG,
"Enabling");
465 ESP_LOGE(TAG,
"Cannot enable - init failed");
470 ESP_LOGE(TAG,
"esp_eth_start failed: %s", esp_err_to_name(err));
483 ESP_LOGD(TAG,
"Disabling");
486 ESP_LOGW(TAG,
"esp_eth_stop failed: %s — disabling anyway", esp_err_to_name(err));
493 const char *eth_type;
494 switch (this->
type_) {
495#ifdef USE_ETHERNET_LAN8720
497 eth_type =
"LAN8720";
500#ifdef USE_ETHERNET_RTL8201
502 eth_type =
"RTL8201";
505#ifdef USE_ETHERNET_DP83848
507 eth_type =
"DP83848";
510#ifdef USE_ETHERNET_IP101
515#ifdef USE_ETHERNET_JL1101
520#ifdef USE_ETHERNET_KSZ8081
522 eth_type =
"KSZ8081";
526 eth_type =
"KSZ8081RNA";
529#if defined(USE_ETHERNET_W5500)
533#elif defined(USE_ETHERNET_DM9051)
537#elif defined(USE_ETHERNET_ENC28J60)
539 eth_type =
"ENC28J60";
541#elif defined(USE_ETHERNET_CH390)
546#ifdef USE_ETHERNET_OPENETH
548 eth_type =
"OPENETH";
551#ifdef USE_ETHERNET_LAN8670
553 eth_type =
"LAN8670";
556#ifdef USE_ETHERNET_GENERIC
558 eth_type =
"Generic (RGMII)";
561#ifdef USE_ETHERNET_YT8531
563 eth_type =
"YT8531 (RGMII)";
568 eth_type =
"Unknown";
577#ifdef USE_ETHERNET_SPI
584 const char *spi_interface =
"spi3";
586 spi_interface =
"spi2";
588 ESP_LOGCONFIG(TAG,
" Interface: %s", spi_interface);
589#ifdef USE_ETHERNET_SPI_POLLING_SUPPORT
591 ESP_LOGCONFIG(TAG,
" Polling Interval: %" PRIu32
" ms", this->
polling_interval_);
599 " Clock Speed: %d MHz",
603 ESP_LOGCONFIG(TAG,
" Power Pin: %u", this->
power_pin_);
612 ESP_LOGCONFIG(TAG,
" Type: %s", eth_type);
619 esp_netif_ip_info_t ip;
620 esp_err_t err = esp_netif_get_ip_info(this->
eth_netif_, &ip);
622 ESP_LOGV(TAG,
"esp_netif_get_ip_info failed: %s", esp_err_to_name(err));
629 struct esp_ip6_addr if_ip6s[CONFIG_LWIP_IPV6_NUM_ADDRESSES];
631 count = esp_netif_get_all_ip6(this->
eth_netif_, if_ip6s);
632 assert(count <= CONFIG_LWIP_IPV6_NUM_ADDRESSES);
633 assert(count < addresses.size());
634 for (
int i = 0; i < count; i++) {
644 const ip_addr_t *dns_ip = dns_getserver(num);
649 const char *event_name;
652 case ETHERNET_EVENT_START:
653 event_name =
"ETH started";
657 case ETHERNET_EVENT_STOP:
658 event_name =
"ETH stopped";
663 case ETHERNET_EVENT_CONNECTED:
664 event_name =
"ETH connected";
666#if defined(USE_ETHERNET_IP_STATE_LISTENERS) && defined(USE_ETHERNET_MANUAL_IP)
672 case ETHERNET_EVENT_DISCONNECTED:
673 event_name =
"ETH disconnected";
681 ESP_LOGV(TAG,
"[Ethernet event] %s (num=%" PRId32
")", event_name, event);
686 ip_event_got_ip_t *
event = (ip_event_got_ip_t *) event_data;
687 const esp_netif_ip_info_t *ip_info = &
event->ip_info;
688 ESP_LOGV(TAG,
"[Ethernet event] ETH Got IP " IPSTR, IP2STR(&ip_info->ip));
690#if USE_NETWORK_IPV6 && (USE_NETWORK_MIN_IPV6_ADDR_COUNT > 0)
697#ifdef USE_ETHERNET_IP_STATE_LISTENERS
705 ip_event_got_ip6_t *
event = (ip_event_got_ip6_t *) event_data;
706 ESP_LOGV(TAG,
"[Ethernet event] ETH Got IPv6: " IPV6STR, IPV62STR(event->ip6_info.ip));
708#if (USE_NETWORK_MIN_IPV6_ADDR_COUNT > 0)
716#ifdef USE_ETHERNET_IP_STATE_LISTENERS
732 esp_err_t err = esp_netif_create_ip6_linklocal(this->
eth_netif_);
734 ESP_LOGD(TAG,
"IPv6 link-local address created (retry succeeded)");
758 ESP_LOGW(TAG,
"esp_netif_set_hostname failed: %s", esp_err_to_name(err));
761 esp_netif_ip_info_t info;
762#ifdef USE_ETHERNET_MANUAL_IP
772 info.netmask.addr = 0;
775 esp_netif_dhcp_status_t
status = ESP_NETIF_DHCP_INIT;
777 err = esp_netif_dhcpc_get_status(this->
eth_netif_, &status);
778 ESPHL_ERROR_CHECK(err,
"DHCPC Get Status Failed!");
780 ESP_LOGV(TAG,
"DHCP Client Status: %d",
status);
783 if (err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
784 ESPHL_ERROR_CHECK(err,
"DHCPC stop error");
787 err = esp_netif_set_ip_info(this->
eth_netif_, &info);
788 ESPHL_ERROR_CHECK(err,
"DHCPC set IP info error");
790#ifdef USE_ETHERNET_MANUAL_IP
797 esp_netif_dns_info_t dns{};
800 err = esp_netif_set_dns_info(this->
eth_netif_, ESP_NETIF_DNS_MAIN, &dns);
802 ESP_LOGE(TAG,
"Set main DNS failed: %s", esp_err_to_name(err));
807 err = esp_netif_set_dns_info(this->
eth_netif_, ESP_NETIF_DNS_BACKUP, &dns);
809 ESP_LOGE(TAG,
"Set backup DNS failed: %s", esp_err_to_name(err));
815 err = esp_netif_dhcpc_start(this->
eth_netif_);
816 if (err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STARTED) {
817 ESPHL_ERROR_CHECK(err,
"DHCPC start error");
828 err = esp_netif_create_ip6_linklocal(this->
eth_netif_);
830 if (err == ESP_ERR_ESP_NETIF_INVALID_PARAMS) {
832 ESPHL_ERROR_CHECK(err,
"esp_netif_create_ip6_linklocal invalid parameters");
839 ESP_LOGW(TAG,
"esp_netif_create_ip6_linklocal failed: %s", esp_err_to_name(err));
851 ESP_LOGCONFIG(TAG,
" uninitialized/disabled");
854 esp_netif_ip_info_t ip;
860 dns_ip1 = dns_getserver(0);
861 dns_ip2 = dns_getserver(1);
865 char ip_buf[network::IP_ADDRESS_BUFFER_SIZE];
866 char subnet_buf[network::IP_ADDRESS_BUFFER_SIZE];
867 char gateway_buf[network::IP_ADDRESS_BUFFER_SIZE];
868 char dns1_buf[network::IP_ADDRESS_BUFFER_SIZE];
869 char dns2_buf[network::IP_ADDRESS_BUFFER_SIZE];
870 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
871 uint16_t link_speed = 10;
876#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 1, 0)
877 case ETH_SPEED_1000M:
892 " Is Full Duplex: %s\n"
897 this->get_eth_mac_address_pretty_into_buffer(mac_buf),
901 struct esp_ip6_addr if_ip6s[CONFIG_LWIP_IPV6_NUM_ADDRESSES];
903 count = esp_netif_get_all_ip6(this->
eth_netif_, if_ip6s);
904 assert(count <= CONFIG_LWIP_IPV6_NUM_ADDRESSES);
905 for (
int i = 0; i < count; i++) {
906 ESP_LOGCONFIG(TAG,
" IPv6: " IPV6STR, IPV62STR(if_ip6s[i]));
911#ifdef USE_ETHERNET_SPI
920#ifdef USE_ETHERNET_SPI_POLLING_SUPPORT
938 memcpy(mac, this->
fixed_mac_->data(), MAC_ADDRESS_SIZE);
940 esp_read_mac(mac, ESP_MAC_ETH);
945 err = esp_eth_ioctl(this->
eth_handle_, ETH_CMD_G_MAC_ADDR, mac);
946 ESPHL_ERROR_CHECK(err,
"ETH_CMD_G_MAC error");
949std::string EthernetComponent::get_eth_mac_address_pretty() {
950 char buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
955 std::span<char, MAC_ADDRESS_PRETTY_BUFFER_SIZE> buf) {
956 uint8_t mac[MAC_ADDRESS_SIZE];
967 err = esp_eth_ioctl(this->
eth_handle_, ETH_CMD_G_DUPLEX_MODE, &duplex_mode);
968 ESPHL_ERROR_CHECK_RET(err,
"ETH_CMD_G_DUPLEX_MODE error",
ETH_DUPLEX_HALF);
978 ESPHL_ERROR_CHECK_RET(err,
"ETH_CMD_G_SPEED error",
ETH_SPEED_10M);
983 ESP_LOGI(TAG,
"Powering down ethernet PHY");
984 if (this->
phy_ ==
nullptr) {
985 ESP_LOGE(TAG,
"Ethernet PHY not assigned");
991 if (this->
phy_->pwrctl(this->phy_,
false) != ESP_OK) {
992 ESP_LOGE(TAG,
"Error powering down ethernet PHY");
998#ifndef USE_ETHERNET_SPI
1000#ifdef USE_ETHERNET_KSZ8081
1007 err = mac->read_phy_reg(mac, this->
phy_addr_, KSZ80XX_PC2R_REG_ADDR, &(phy_control_2));
1008 ESPHL_ERROR_CHECK(err,
"Read PHY Control 2 failed");
1009#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERY_VERBOSE
1012 ESP_LOGVV(TAG,
"KSZ8081 PHY Control 2: %s",
format_hex_pretty_to(hex_buf, (uint8_t *) &phy_control_2, PHY_REG_SIZE));
1023 if ((phy_control_2 & (1 << 7)) != (1 << 7)) {
1024 phy_control_2 |= 1 << 7;
1025 err = mac->write_phy_reg(mac, this->
phy_addr_, KSZ80XX_PC2R_REG_ADDR, phy_control_2);
1026 ESPHL_ERROR_CHECK(err,
"Write PHY Control 2 failed");
1027 err = mac->read_phy_reg(mac, this->
phy_addr_, KSZ80XX_PC2R_REG_ADDR, &(phy_control_2));
1028 ESPHL_ERROR_CHECK(err,
"Read PHY Control 2 failed");
1029 ESP_LOGVV(TAG,
"KSZ8081 PHY Control 2: %s",
1038#ifdef USE_ETHERNET_RTL8201
1039 constexpr uint8_t eth_phy_psr_reg_addr = 0x1F;
1041 ESP_LOGD(TAG,
"Select PHY Register Page: 0x%02" PRIX32, register_data.
page);
1042 err = mac->write_phy_reg(mac, this->
phy_addr_, eth_phy_psr_reg_addr, register_data.
page);
1043 ESPHL_ERROR_CHECK(err,
"Select PHY Register page failed");
1047 ESP_LOGD(TAG,
"Writing PHY reg 0x%02" PRIX32
" = 0x%04" PRIX32, register_data.
address, register_data.
value);
1049 ESPHL_ERROR_CHECK(err,
"Writing PHY Register failed");
1051#ifdef USE_ETHERNET_RTL8201
1053 ESP_LOGD(TAG,
"Select PHY Register Page 0x00");
1054 err = mac->write_phy_reg(mac, this->
phy_addr_, eth_phy_psr_reg_addr, 0x0);
1055 ESPHL_ERROR_CHECK(err,
"Select PHY Register Page 0 failed");
1060#ifdef USE_ETHERNET_YT8531
1067 bool autoneg_enable =
true;
1068 err = esp_eth_ioctl(this->
eth_handle_, ETH_CMD_S_AUTONEGO, &autoneg_enable);
1069 ESPHL_ERROR_CHECK(err,
"YT8531 enable auto-negotiation failed");
1074 esp_eth_phy_reg_rw_data_t phy_reg;
1076 phy_reg.reg_value_p = ®_val;
1080 phy_reg.reg_addr = 0x1E;
1081 err = esp_eth_ioctl(this->
eth_handle_, ETH_CMD_WRITE_PHY_REG, &phy_reg);
1082 ESPHL_ERROR_CHECK(err,
"YT8531 select Chip_Config failed");
1083 phy_reg.reg_addr = 0x1F;
1084 err = esp_eth_ioctl(this->
eth_handle_, ETH_CMD_READ_PHY_REG, &phy_reg);
1085 ESPHL_ERROR_CHECK(err,
"YT8531 read Chip_Config failed");
1086 reg_val |= (1U << 8);
1087 err = esp_eth_ioctl(this->
eth_handle_, ETH_CMD_WRITE_PHY_REG, &phy_reg);
1088 ESPHL_ERROR_CHECK(err,
"YT8531 write Chip_Config failed");
1092 phy_reg.reg_addr = 0x1E;
1093 err = esp_eth_ioctl(this->
eth_handle_, ETH_CMD_WRITE_PHY_REG, &phy_reg);
1094 ESPHL_ERROR_CHECK(err,
"YT8531 select RGMII_Config1 failed");
1095 phy_reg.reg_addr = 0x1F;
1096 err = esp_eth_ioctl(this->
eth_handle_, ETH_CMD_READ_PHY_REG, &phy_reg);
1097 ESPHL_ERROR_CHECK(err,
"YT8531 read RGMII_Config1 failed");
1098 reg_val = (reg_val & ~0x00FFU) | (13U << 4) | (13U << 0);
1099 err = esp_eth_ioctl(this->
eth_handle_, ETH_CMD_WRITE_PHY_REG, &phy_reg);
1100 ESPHL_ERROR_CHECK(err,
"YT8531 write RGMII_Config1 failed");
const StringRef & get_name() const
Get the name of this Application set by pre_setup().
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
void mark_failed()
Mark this component as failed.
void status_set_warning()
void enable_loop_soon_any_context()
Thread and ISR-safe version of enable_loop() that can be called from any context.
void enable_loop()
Enable this component's loop.
void disable_loop()
Disable this component's loop.
void status_clear_warning()
Helper class to lock the lwIP TCPIP core when making lwIP API calls from non-TCPIP threads.
constexpr const char * c_str() const
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Inform the parent automation that the event has triggered.
void set_interface(spi_host_device_t interface)
Trigger disconnect_trigger_
void set_clk_pin(uint8_t clk_pin)
std::vector< PHYRegister > phy_registers_
void get_eth_mac_address_raw(uint8_t *mac)
esp_eth_handle_t eth_handle_
static void got_ip_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
void set_clock_speed(int clock_speed)
void set_polling_interval(uint32_t polling_interval)
eth_duplex_t get_duplex_mode()
void yt8531_phy_init_()
Apply YT8531-specific config: re-enable auto-negotiation (disabled on reset) and set the RGMII Tx/Rx ...
void notify_ip_state_listeners_()
void ethernet_lazy_init_()
network::IPAddresses get_ip_addresses()
void write_phy_register_(esp_eth_mac_t *mac, PHYRegister register_data)
Set arbitratry PHY registers from config.
void dump_connect_params_()
static void got_ip6_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
void log_error_and_mark_failed_(esp_err_t err, const char *message)
EthernetComponentState state_
void set_phy_addr(uint8_t phy_addr)
network::IPAddress get_dns_address(uint8_t num)
void set_reset_pin(uint8_t reset_pin)
void add_phy_register(PHYRegister register_value)
void ksz8081_set_clock_reference_(esp_eth_mac_t *mac)
Set RMII Reference Clock Select bit for KSZ8081.
optional< ManualIP > manual_ip_
eth_speed_t get_link_speed()
void dump_config() override
emac_rmii_clock_mode_t clk_mode_
optional< std::array< uint8_t, MAC_ADDRESS_SIZE > > fixed_mac_
void set_interrupt_pin(uint8_t interrupt_pin)
bool ethernet_initialized_
static void eth_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
void set_miso_pin(uint8_t miso_pin)
spi_host_device_t interface_
void set_cs_pin(uint8_t cs_pin)
void set_mdc_pin(uint8_t mdc_pin)
void set_power_pin(int power_pin)
uint32_t polling_interval_
void set_mdio_pin(uint8_t mdio_pin)
void set_mosi_pin(uint8_t mosi_pin)
void set_clk_mode(emac_rmii_clock_mode_t clk_mode)
ESPDEPRECATED("Use get_eth_mac_address_pretty_into_buffer() instead. Removed in 2026.9.0", "2026.3.0") std const char * get_eth_mac_address_pretty_into_buffer(std::span< char, MAC_ADDRESS_PRETTY_BUFFER_SIZE > buf)
const LogString * message
eth_esp32_emac_config_t eth_esp32_emac_default_config(void)
constexpr uint8_t KSZ80XX_PC2R_REG_ADDR
void install_w5500_async_spi(eth_w5500_config_t &config)
esp_eth_phy_t * esp_eth_phy_new_jl1101(const eth_phy_config_t *config)
EthernetComponent * global_eth_component
@ ETHERNET_TYPE_KSZ8081RNA
std::array< IPAddress, 5 > IPAddresses
char * format_hex_pretty_to(char *buffer, size_t buffer_size, const uint8_t *data, size_t length, char separator)
Format byte array as uppercase hex to buffer (base implementation).
constexpr size_t format_hex_pretty_size(size_t byte_count)
Calculate buffer size needed for format_hex_pretty_to with separator: "XX:XX:...:XX\0".
void HOT delay(uint32_t ms)
uint32_t IRAM_ATTR HOT millis()
Application App
Global storage of Application pointer - only one Application can exist.
char * format_mac_addr_upper(const uint8_t *mac, char *output)
Format MAC address as XX:XX:XX:XX:XX:XX (uppercase, colon separators)
char * str_to(char *buf) const