ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
ethernet_component.cpp
Go to the documentation of this file.
2
3#ifdef USE_ETHERNET
4
5#include "esphome/core/log.h"
6
8
9EthernetComponent *global_eth_component; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
10
12
13#ifdef USE_ETHERNET_MANUAL_IP
15 uint8_t b[ETHERNET_MANUAL_IP_SIZE];
16 progmem_memcpy(b, ETHERNET_MANUAL_IP, sizeof(b));
17 auto ip = [&b](size_t i) { return network::IPAddress(b[i], b[i + 1], b[i + 2], b[i + 3]); };
18 return ManualIP{ip(0), ip(4), ip(8), ip(12), ip(16)};
19}
20#endif
21
22#ifdef USE_ETHERNET_IP_STATE_LISTENERS
24 auto ips = this->get_ip_addresses();
25 auto dns1 = this->get_dns_address(0);
26 auto dns2 = this->get_dns_address(1);
27 for (auto *listener : this->ip_state_listeners_) {
28 listener->on_ip_state(ips, dns1, dns2);
29 }
30}
31#endif // USE_ETHERNET_IP_STATE_LISTENERS
32
33} // namespace esphome::ethernet
34
35#endif // USE_ETHERNET
network::IPAddress get_dns_address(uint8_t num)
StaticVector< EthernetIPStateListener *, ESPHOME_ETHERNET_IP_STATE_LISTENERS > ip_state_listeners_
EthernetComponent * global_eth_component
void progmem_memcpy(void *dst, const void *src, size_t len)
Definition hal.h:56