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);
248 memset(mac, 0, MAC_ADDRESS_SIZE);
253 std::span<char, MAC_ADDRESS_PRETTY_BUFFER_SIZE> buf) {
254 uint8_t mac[MAC_ADDRESS_SIZE];
266#ifdef USE_ETHERNET_ENC28J60
276 ESP_LOGI(TAG,
"Powering down ethernet");
277 if (this->
eth_ !=
nullptr) {
292#ifdef USE_ETHERNET_MANUAL_IP
300 dns_setserver(0, &d);
305 dns_setserver(1, &d);
317 if (this->
eth_ ==
nullptr) {
321 char ip_buf[network::IP_ADDRESS_BUFFER_SIZE];
322 char subnet_buf[network::IP_ADDRESS_BUFFER_SIZE];
323 char gateway_buf[network::IP_ADDRESS_BUFFER_SIZE];
324 char dns1_buf[network::IP_ADDRESS_BUFFER_SIZE];
325 char dns2_buf[network::IP_ADDRESS_BUFFER_SIZE];
326 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
332 auto *netif = this->
eth_->getNetIf();
333 ip_addr = netif->ip_addr;
334 netmask = netif->netmask;
336 dns1_addr = *dns_getserver(0);
337 dns2_addr = *dns_getserver(1);
348 network::IPAddress(&netmask).str_to(subnet_buf), network::IPAddress(&gw).str_to(gateway_buf),
349 network::IPAddress(&dns1_addr).str_to(dns1_buf), network::IPAddress(&dns2_addr).str_to(dns2_buf),
350 this->get_eth_mac_address_pretty_into_buffer(mac_buf));
359 ESP_LOGW(TAG,
"enable_on_boot/disable not supported");
366 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)
optional< ManualIP > manual_ip_
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
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)