11#if (defined(USE_ESP8266) || defined(USE_RP2)) && \
12 ((defined(USE_WIFI) && defined(USE_WIFI_IP_STATE_LISTENERS)) || \
13 (defined(USE_ETHERNET) && defined(USE_ETHERNET_IP_STATE_LISTENERS)))
15#define USE_MDNS_EVENT_DRIVEN_POLLING
16#if defined(USE_WIFI) && defined(USE_WIFI_IP_STATE_LISTENERS)
18#define USE_MDNS_WIFI_LISTENER
20#if defined(USE_ETHERNET) && defined(USE_ETHERNET_IP_STATE_LISTENERS)
22#define USE_MDNS_ETHERNET_LISTENER
30#if defined(USE_API) || defined(USE_WEBSERVER) || \
31 (!defined(USE_PROMETHEUS) && !defined(USE_SENDSPIN) && !defined(USE_MDNS_EXTRA_SERVICES))
32#define USE_MDNS_DEVICE_INFO_TXT
38#ifdef USE_MDNS_ACTIVE_INTERFACE_LISTENER
48#define MDNS_STR(name) (reinterpret_cast<const esphome::mdns::MDNSString *>(name))
50#define MDNS_STR_ARG(s) (reinterpret_cast<ESPHOME_PGM_P>(s))
56 const MDNSString *
key;
69#ifdef USE_MDNS_SUPPORTS_ENABLE_DISABLE
75#ifdef USE_MDNS_WIFI_LISTENER
79#ifdef USE_MDNS_ETHERNET_LISTENER
83#ifdef USE_MDNS_ACTIVE_INTERFACE_LISTENER
89 void setup()
override;
95#ifdef USE_MDNS_EVENT_DRIVEN_POLLING
117#ifdef USE_MDNS_EXTRA_SERVICES
121#ifdef USE_MDNS_STORE_SERVICES
125#ifdef USE_MDNS_SUPPORTS_ENABLE_DISABLE
126#ifndef USE_MDNS_STORE_SERVICES
127#error "USE_MDNS_SUPPORTS_ENABLE_DISABLE requires USE_MDNS_STORE_SERVICES"
129#ifdef USE_OPENTHREAD_SRP
130#error "USE_MDNS_SUPPORTS_ENABLE_DISABLE is not supported with the OpenThread SRP client"
140#ifdef USE_MDNS_DYNAMIC_TXT
148#ifdef USE_MDNS_ACTIVE_INTERFACE_LISTENER
152#ifdef USE_MDNS_EVENT_DRIVEN_POLLING
158#ifdef USE_MDNS_EVENT_DRIVEN_POLLING
168#ifdef USE_MDNS_DYNAMIC_NETWORK_TXT
178#ifdef USE_MDNS_STORE_SERVICES
184#ifdef USE_MDNS_DYNAMIC_TXT
191#if defined(USE_MDNS_DEVICE_INFO_TXT) && defined(USE_MDNS_STORE_SERVICES)
197#ifdef USE_MDNS_STORE_SERVICES
200#if defined(USE_RP2) && defined(USE_MDNS_EVENT_DRIVEN_POLLING)
205 const char *config_hash_buf);
Fixed-capacity vector - sized once through init() or try_init(); push_back never reallocates This avo...
Minimal static vector - saves memory by avoiding std::vector overhead.
void push_back(const T &value)
Function-pointer-only templatable storage (4 bytes on 32-bit).
Listener interface for Ethernet IP state changes.
void on_shutdown() override
const char * connected_network_() const
The first connected interface in network: priority order ("ethernet" or "wifi"), else nullptr.
const char * network_txt_
Advertised value; nullptr until the _esphomelib service is registered, and after a failed publish.
StaticVector< std::string, MDNS_DYNAMIC_TXT_COUNT > dynamic_txt_values_
Storage for runtime-generated TXT values from user lambdas Pre-sized at compile time via MDNS_DYNAMIC...
static constexpr uint32_t MDNS_POLL_STOP_ID
void on_active_interface(network::NetworkInterface interface) override
void dump_config() override
void start_polling_window_()
Arm a fresh MDNS_POLL_WINDOW_MS polling window.
float get_setup_priority() const override
void on_ip_state(const network::IPAddresses &ips, const network::IPAddress &dns1, const network::IPAddress &dns2) override
const char * add_dynamic_txt_value(const std::string &value)
Add a dynamic TXT value and return pointer to it for use in MDNSTXTRecord.
char config_hash_str_[CONFIG_HASH_STR_SIZE]
Fixed buffer for config hash hex string (only needed when services are stored)
static constexpr size_t CONFIG_HASH_STR_SIZE
Size of buffer required for config hash hex string (8 hex chars + null terminator)
bool set_service_enabled(const char *service_type, const char *proto, bool enabled)
Enable or disable a compiled-in service, matched by type and proto (e.g.
void compile_records_(StaticVector< MDNSService, MDNS_SERVICE_COUNT > &services, const char *mac_address_buf, const char *config_hash_buf)
static constexpr uint32_t MDNS_POLL_WINDOW_MS
void setup_buffers_and_register_(PlatformRegisterFn platform_register)
void update_network_txt_(const char *network)
Publish network as the "network" TXT value if it changed; nullptr keeps the current value.
char mac_address_[MAC_ADDRESS_BUFFER_SIZE]
Fixed buffer for MAC address (only needed when services are stored)
void(*)(MDNSComponent *, StaticVector< MDNSService, MDNS_SERVICE_COUNT > &) PlatformRegisterFn
Helper to set up services and MAC buffers, then call platform-specific registration.
void add_extra_service(MDNSService service)
static constexpr uint32_t MDNS_POLL_ID
MDNSTXTRecord * network_record_
The "network" record in services_, kept in step with network_txt_.
static constexpr uint32_t MDNS_UPDATE_INTERVAL_MS
static constexpr uint32_t NETWORK_TXT_CHECK_INTERVAL_MS
const StaticVector< MDNSService, MDNS_SERVICE_COUNT > & get_services() const
bool publish_network_txt_(const char *network)
Platform-specific: replace the "network" TXT value of the registered _esphomelib service.
StaticVector< MDNSService, MDNS_SERVICE_COUNT > services_
Notified from the main loop when the interface holding the default route changes.
Listener interface for WiFi IP state changes.
std::array< IPAddress, 5 > IPAddresses
NetworkInterface
The interface holding the default route.
constexpr float AFTER_CONNECTION
For components that should be initialized after a data connection (API/MQTT) is connected.
constexpr size_t format_hex_size(size_t byte_count)
Calculate buffer size needed for format_hex_to: "XXXXXXXX...\0" = bytes * 2 + 1.
FixedVector< MDNSTXTRecord > txt_records
TemplatableFn< uint16_t > port
const MDNSString * service_type