ESPHome
2026.11.0b6
Loading...
Searching...
No Matches
esphome
components
ethernet
ethernet_component.cpp
Go to the documentation of this file.
1
#include "
ethernet_component.h
"
2
3
#ifdef USE_ETHERNET
4
5
#include "
esphome/core/log.h
"
6
7
namespace
esphome::ethernet
{
8
9
EthernetComponent
*
global_eth_component
;
// NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
10
11
EthernetComponent::EthernetComponent
() {
global_eth_component
=
this
; }
12
13
#ifdef USE_ETHERNET_MANUAL_IP
14
ManualIP
load_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
23
void
EthernetComponent::notify_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
esphome::ethernet::EthernetComponent
Definition
ethernet_component.h:136
esphome::ethernet::EthernetComponent::notify_ip_state_listeners_
void notify_ip_state_listeners_()
Definition
ethernet_component.cpp:23
esphome::ethernet::EthernetComponent::get_ip_addresses
network::IPAddresses get_ip_addresses()
Definition
ethernet_component_esp32.cpp:736
esphome::ethernet::EthernetComponent::get_dns_address
network::IPAddress get_dns_address(uint8_t num)
Definition
ethernet_component_esp32.cpp:756
esphome::ethernet::EthernetComponent::ip_state_listeners_
StaticVector< EthernetIPStateListener *, ESPHOME_ETHERNET_IP_STATE_LISTENERS > ip_state_listeners_
Definition
ethernet_component.h:370
esphome::ethernet::EthernetComponent::EthernetComponent
EthernetComponent()
Definition
ethernet_component.cpp:11
ethernet_component.h
log.h
esphome::ethernet
Definition
ethernet_component.cpp:7
esphome::ethernet::load_manual_ip
ManualIP load_manual_ip()
Definition
ethernet_component.cpp:14
esphome::ethernet::global_eth_component
EthernetComponent * global_eth_component
Definition
ethernet_component.cpp:9
esphome::progmem_memcpy
void progmem_memcpy(void *dst, const void *src, size_t len)
Definition
hal.h:56
esphome::ethernet::ManualIP
Definition
ethernet_component.h:100
esphome::network::IPAddress
Definition
ip_address.h:108
Generated by
1.12.0