3#if defined(USE_ETHERNET) && defined(USE_RP2)
13#include <lwip/netif.h>
17static const char *
const TAG =
"ethernet";
21#if !defined(USE_ETHERNET_W6300)
32 rp2::RP2GPIOPin reset_pin;
36 reset_pin.digital_write(
false);
38 reset_pin.digital_write(
true);
44#if defined(USE_ETHERNET_W5500)
46#elif defined(USE_ETHERNET_W5100)
48#elif defined(USE_ETHERNET_W6100)
50#elif defined(USE_ETHERNET_W6300)
52#elif defined(USE_ETHERNET_ENC28J60)
60#ifdef USE_ETHERNET_MANUAL_IP
67 this->
eth_->config(ip, gateway, subnet, dns1, dns2);
76 success = this->
eth_->begin();
80 ESP_LOGE(TAG,
"Failed to initialize Ethernet");
88 this->
eth_->setDefault(
true);
112#if defined(USE_ETHERNET_W5100)
117 bool link_up = this->
eth_->linkStatus() == LinkON;
119 bool has_ip = this->
eth_->connected();
133#ifdef USE_ETHERNET_IP_STATE_LISTENERS
144 ESP_LOGI(TAG,
"Starting connection");
151 ESP_LOGI(TAG,
"Stopped connection");
155 ESP_LOGI(TAG,
"Connected");
160#ifdef USE_ETHERNET_CONNECT_TRIGGER
164 ESP_LOGW(TAG,
"Connecting failed; reconnecting");
170 ESP_LOGI(TAG,
"Stopped connection");
172#ifdef USE_ETHERNET_DISCONNECT_TRIGGER
176 ESP_LOGW(TAG,
"Connection lost; reconnecting");
179#ifdef USE_ETHERNET_DISCONNECT_TRIGGER
190#if defined(USE_ETHERNET_W5500)
191 const char *type_str =
"W5500";
192#elif defined(USE_ETHERNET_W5100)
193 const char *type_str =
"W5100";
194#elif defined(USE_ETHERNET_W6100)
195 const char *type_str =
"W6100";
196#elif defined(USE_ETHERNET_W6300)
197 const char *type_str =
"W6300";
198#elif defined(USE_ETHERNET_ENC28J60)
199 const char *type_str =
"ENC28J60";
201 const char *type_str =
"Unknown";
203#if defined(USE_ETHERNET_W6300)
207 " Type: %s (PIO QSPI)\n"
231 if (this->
eth_ !=
nullptr) {
233 addresses[0] = network::IPAddress(this->
eth_->localIP());
240 const ip_addr_t *dns_ip = dns_getserver(num);
245 if (this->
eth_ !=
nullptr) {
246 this->
eth_->macAddress(mac);
252std::string EthernetComponent::get_eth_mac_address_pretty() {
253 char buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
258 std::span<char, MAC_ADDRESS_PRETTY_BUFFER_SIZE> buf) {
271#ifdef USE_ETHERNET_ENC28J60
281 ESP_LOGI(TAG,
"Powering down ethernet");
282 if (this->
eth_ !=
nullptr) {
297#ifdef USE_ETHERNET_MANUAL_IP
305 dns_setserver(0, &d);
310 dns_setserver(1, &d);
322 if (this->
eth_ ==
nullptr) {
326 char ip_buf[network::IP_ADDRESS_BUFFER_SIZE];
327 char subnet_buf[network::IP_ADDRESS_BUFFER_SIZE];
328 char gateway_buf[network::IP_ADDRESS_BUFFER_SIZE];
329 char dns1_buf[network::IP_ADDRESS_BUFFER_SIZE];
330 char dns2_buf[network::IP_ADDRESS_BUFFER_SIZE];
331 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
337 auto *netif = this->
eth_->getNetIf();
338 ip_addr = netif->ip_addr;
339 netmask = netif->netmask;
341 dns1_addr = *dns_getserver(0);
342 dns2_addr = *dns_getserver(1);
353 network::IPAddress(&netmask).str_to(subnet_buf), network::IPAddress(&gw).str_to(gateway_buf),
354 network::IPAddress(&dns1_addr).str_to(dns1_buf), network::IPAddress(&dns2_addr).str_to(dns2_buf),
355 this->get_eth_mac_address_pretty_into_buffer(mac_buf));
371 ESP_LOGW(TAG,
"enable_on_boot/disable not supported");
378 ESP_LOGW(TAG,
"enable_on_boot/disable not supported");
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 status_clear_warning()
constexpr const char * c_str() const
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Inform the parent automation that the event has triggered.
Trigger disconnect_trigger_
void set_clk_pin(uint8_t clk_pin)
void get_eth_mac_address_raw(uint8_t *mac)
eth_duplex_t get_duplex_mode()
void notify_ip_state_listeners_()
static constexpr uint32_t LINK_CHECK_INTERVAL
network::IPAddresses get_ip_addresses()
void dump_connect_params_()
EthernetComponentState state_
network::IPAddress get_dns_address(uint8_t num)
void set_reset_pin(uint8_t reset_pin)
optional< ManualIP > manual_ip_
eth_speed_t get_link_speed()
void dump_config() override
uint32_t last_link_check_
void set_interrupt_pin(uint8_t interrupt_pin)
static constexpr uint32_t RESET_DELAY_MS
void set_miso_pin(uint8_t miso_pin)
optional< std::array< uint8_t, 6 > > fixed_mac_
void set_cs_pin(uint8_t cs_pin)
void set_mosi_pin(uint8_t mosi_pin)
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)
LwipIntfDev< Wiznet6300NoSPI > Wiznet6300lwIPFixed
std::array< IPAddress, 5 > IPAddresses
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)