[mdns] Inline MDNS.update() as a lambda in each platform's start_polling_window_

Drops the mdns_pump_update() trampoline. It existed because start_polling_window_
lived in mdns_component.cpp which can't see the platform's MDNS global. Moving
start_polling_window_ into each platform cpp lets the set_interval lambda call
MDNS.update() directly — no forward decl, no ODR comment, no indirection.
This commit is contained in:
J. Nick Koston
2026-04-23 20:40:38 -05:00
parent 4f8cfff4ac
commit d32db7904a
4 changed files with 10 additions and 17 deletions
@@ -190,15 +190,6 @@ void MDNSComponent::compile_records_(StaticVector<MDNSService, MDNS_SERVICE_COUN
#endif
}
#ifdef USE_MDNS_EVENT_DRIVEN_POLLING
void MDNSComponent::start_polling_window_() {
// uint32_t-ID set_interval/set_timeout already does atomic cancel-and-add, so
// re-arming replaces the previous window implicitly.
this->set_interval(MDNS_POLL_ID, MDNS_UPDATE_INTERVAL_MS, mdns_pump_update);
this->set_timeout(MDNS_POLL_STOP_ID, MDNS_POLL_WINDOW_MS, [this]() { this->cancel_interval(MDNS_POLL_ID); });
}
#endif
void MDNSComponent::dump_config() {
ESP_LOGCONFIG(TAG,
"mDNS:\n"
-6
View File
@@ -24,12 +24,6 @@
namespace esphome::mdns {
#ifdef USE_MDNS_EVENT_DRIVEN_POLLING
/// MDNS.update() trampoline. Defined in exactly one mdns_<platform>.cpp per build
/// (FILTER_SOURCE_FILES in __init__.py enforces this), so ODR is preserved.
void mdns_pump_update();
#endif
// Helper struct that identifies strings that may be stored in flash storage (similar to LogString)
struct MDNSString;
+5 -1
View File
@@ -39,7 +39,11 @@ static void register_esp8266(MDNSComponent *, StaticVector<MDNSService, MDNS_SER
}
#ifdef USE_MDNS_EVENT_DRIVEN_POLLING
void mdns_pump_update() { MDNS.update(); }
void MDNSComponent::start_polling_window_() {
// uint32_t-ID set_interval/set_timeout already does atomic cancel-and-add.
this->set_interval(MDNS_POLL_ID, MDNS_UPDATE_INTERVAL_MS, []() { MDNS.update(); });
this->set_timeout(MDNS_POLL_STOP_ID, MDNS_POLL_WINDOW_MS, [this]() { this->cancel_interval(MDNS_POLL_ID); });
}
#endif
void MDNSComponent::setup() {
+5 -1
View File
@@ -39,7 +39,11 @@ static void register_rp2040(MDNSComponent *, StaticVector<MDNSService, MDNS_SERV
}
#ifdef USE_MDNS_EVENT_DRIVEN_POLLING
void mdns_pump_update() { MDNS.update(); }
void MDNSComponent::start_polling_window_() {
// uint32_t-ID set_interval/set_timeout already does atomic cancel-and-add.
this->set_interval(MDNS_POLL_ID, MDNS_UPDATE_INTERVAL_MS, []() { MDNS.update(); });
this->set_timeout(MDNS_POLL_STOP_ID, MDNS_POLL_WINDOW_MS, [this]() { this->cancel_interval(MDNS_POLL_ID); });
}
#endif
void MDNSComponent::setup() {