ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
esphome::network Namespace Reference

Data Structures

class  ActiveInterfaceListener
 Notified from the main loop when the interface holding the default route changes. More...
 
struct  IPAddress
 
class  NetworkComponent
 

Typedefs

using IPAddresses = std::array<IPAddress, 5>
 

Enumerations

enum class  NetworkInterface : uint8_t { NETWORK_INTERFACE_NONE , NETWORK_INTERFACE_ETHERNET , NETWORK_INTERFACE_WIFI }
 The interface holding the default route. More...
 

Functions

void lowercase_ip_str (char *buf)
 Lowercase hex digits in IP address string (A-F -> a-f for IPv6 per RFC 5952)
 
 ESPHOME_LOG_TAG (TAG, "network")
 
void fill_ip6_addresses (esp_netif_t *netif, IPAddresses &addresses)
 Copies the IPv6 addresses of an esp_netif into addresses[1..], warning once when some do not fit.
 
bool is_disabled ()
 Return whether the network is disabled: every configured interface with a disable() lifecycle (modem, wifi, ethernet) is disabled.
 
const char * get_use_address_to (std::span< char, USE_ADDRESS_BUFFER_SIZE > buf)
 Get the active network address for logging.
 
network::IPAddresses get_ip_addresses ()
 
ESPHOME_ALWAYS_INLINE bool is_connected ()
 Return whether the node is connected to the network (through wifi, eth, ...)
 

Typedef Documentation

◆ IPAddresses

using esphome::network::IPAddresses = std::array<IPAddress, 5>

Definition at line 369 of file ip_address.h.

Enumeration Type Documentation

◆ NetworkInterface

enum class esphome::network::NetworkInterface : uint8_t
strong

The interface holding the default route.

Lists only the interfaces loop() arbitrates (ARBITRATED_NETWORK_TYPES in init.py); extend both together.

Enumerator
NETWORK_INTERFACE_NONE 
NETWORK_INTERFACE_ETHERNET 
NETWORK_INTERFACE_WIFI 

Definition at line 18 of file network_component.h.

Function Documentation

◆ ESPHOME_LOG_TAG()

esphome::network::ESPHOME_LOG_TAG ( TAG ,
"network"  )

◆ fill_ip6_addresses()

void esphome::network::fill_ip6_addresses ( esp_netif_t * netif,
IPAddresses & addresses )

Copies the IPv6 addresses of an esp_netif into addresses[1..], warning once when some do not fit.

Definition at line 13 of file util.cpp.

◆ get_ip_addresses()

IPAddresses esphome::network::get_ip_addresses ( )

Definition at line 98 of file util.cpp.

◆ get_use_address_to()

const char * esphome::network::get_use_address_to ( std::span< char, USE_ADDRESS_BUFFER_SIZE > buf)

Get the active network address for logging.

Returns the explicitly configured use_address when one was set (from the highest-priority interface when network: priority: is configured), otherwise formats "<name>.local" from the runtime device name into buf (so it includes the MAC suffix from name_add_mac_suffix).

Definition at line 72 of file util.cpp.

◆ is_connected()

ESPHOME_ALWAYS_INLINE bool esphome::network::is_connected ( )
inline

Return whether the node is connected to the network (through wifi, eth, ...)

Definition at line 36 of file util.h.

◆ is_disabled()

bool esphome::network::is_disabled ( )

Return whether the network is disabled: every configured interface with a disable() lifecycle (modem, wifi, ethernet) is disabled.

Definition at line 42 of file util.cpp.

◆ lowercase_ip_str()

void esphome::network::lowercase_ip_str ( char * buf)
inline

Lowercase hex digits in IP address string (A-F -> a-f for IPv6 per RFC 5952)

Definition at line 102 of file ip_address.h.