3#if defined(USE_ETHERNET) && defined(USE_RP2)
13#include <lwip/netif.h>
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
63 this->
eth_->config(IPAddress(manual_ip.static_ip), IPAddress(manual_ip.gateway), IPAddress(manual_ip.subnet),
64 IPAddress(manual_ip.dns1), IPAddress(manual_ip.dns2));
73 success = this->
eth_->begin();
77 ESP_LOGE(TAG,
"Failed to initialize Ethernet");
85 this->
eth_->setDefault(
true);
109#if defined(USE_ETHERNET_W5100)
114 bool link_up = this->
eth_->linkStatus() == LinkON;
116 bool has_ip = this->
eth_->connected();
130#ifdef USE_ETHERNET_IP_STATE_LISTENERS
141 ESP_LOGI(TAG,
"Starting connection");
148 ESP_LOGI(TAG,
"Stopped connection");
152 ESP_LOGI(TAG,
"Connected");
157#ifdef USE_ETHERNET_CONNECT_TRIGGER
161 ESP_LOGW(TAG,
"Connecting failed; reconnecting");
167 ESP_LOGI(TAG,
"Stopped connection");
169#ifdef USE_ETHERNET_DISCONNECT_TRIGGER
173 ESP_LOGW(TAG,
"Connection lost; reconnecting");
176#ifdef USE_ETHERNET_DISCONNECT_TRIGGER
187#if defined(USE_ETHERNET_W5500)
188 const char *type_str =
"W5500";
189#elif defined(USE_ETHERNET_W5100)
190 const char *type_str =
"W5100";
191#elif defined(USE_ETHERNET_W6100)
192 const char *type_str =
"W6100";
193#elif defined(USE_ETHERNET_W6300)
194 const char *type_str =
"W6300";
195#elif defined(USE_ETHERNET_ENC28J60)
196 const char *type_str =
"ENC28J60";
198 const char *type_str =
"Unknown";
200#if defined(USE_ETHERNET_W6300)
204 " Type: %s (PIO QSPI)\n"
228 if (this->
eth_ !=
nullptr) {
230 addresses[0] = network::IPAddress(this->
eth_->localIP());
237 const ip_addr_t *dns_ip = dns_getserver(num);
242 if (this->
eth_ !=
nullptr) {
243 this->
eth_->macAddress(mac);
245 memset(mac, 0, MAC_ADDRESS_SIZE);
250 std::span<char, MAC_ADDRESS_PRETTY_BUFFER_SIZE> buf) {
251 uint8_t mac[MAC_ADDRESS_SIZE];
263#ifdef USE_ETHERNET_ENC28J60
273 ESP_LOGI(TAG,
"Powering down ethernet");
274 if (this->
eth_ !=
nullptr) {
289#ifdef USE_ETHERNET_MANUAL_IP
294 if (manual_ip.dns1.is_set()) {
296 dns_setserver(0, &d);
298 if (manual_ip.dns2.is_set()) {
300 dns_setserver(1, &d);
311 if (this->
eth_ ==
nullptr) {
315 char ip_buf[network::IP_ADDRESS_BUFFER_SIZE];
316 char subnet_buf[network::IP_ADDRESS_BUFFER_SIZE];
317 char gateway_buf[network::IP_ADDRESS_BUFFER_SIZE];
318 char dns1_buf[network::IP_ADDRESS_BUFFER_SIZE];
319 char dns2_buf[network::IP_ADDRESS_BUFFER_SIZE];
320 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
326 auto *netif = this->
eth_->getNetIf();
327 ip_addr = netif->ip_addr;
328 netmask = netif->netmask;
330 dns1_addr = *dns_getserver(0);
331 dns2_addr = *dns_getserver(1);
342 network::IPAddress(&netmask).str_to(subnet_buf), network::IPAddress(&gw).str_to(gateway_buf),
343 network::IPAddress(&dns1_addr).str_to(dns1_buf), network::IPAddress(&dns2_addr).str_to(dns2_buf),
344 this->get_eth_mac_address_pretty_into_buffer(mac_buf));
353 ESP_LOGW(TAG,
"enable_on_boot/disable not supported");
360 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 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)
eth_speed_t get_link_speed()
void dump_config() override
uint32_t last_link_check_
optional< std::array< uint8_t, MAC_ADDRESS_SIZE > > fixed_mac_
static constexpr uint32_t RESET_DELAY_MS
const char * get_eth_mac_address_pretty_into_buffer(std::span< char, MAC_ADDRESS_PRETTY_BUFFER_SIZE > buf)
LwipIntfDev< Wiznet6300NoSPI > Wiznet6300lwIPFixed
ESPHOME_LOG_TAG(TAG, "ethernet")
ManualIP load_manual_ip()
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)