mirror of
https://github.com/esphome/esphome.git
synced 2026-09-03 19:46:02 +00:00
bf7083c50100b2b1ba83d980e7be6d34fb549b8c
The Arduino LEAmDNS library only has meaningful timer-driven work during the ~9 s probe+announce phase following MDNS.begin() or _restart(): 3 probes at 250 ms + 8 announcements at 1000 ms, then all internal timeouts are set to resetToNeverExpires(). Incoming packets are handled via the lwIP UDP RX callback independently of update(). ESPHome does not issue service queries, so the query cache path is always a no-op. The previous implementation ran set_interval(50) forever — ~20 dispatches/sec, 1200+ scheduler calls per minute of pure overhead once probing completed. This PR arms a bounded MDNS_POLL_WINDOW_MS (12 s) polling window driven by WiFiIPStateListener events. A fresh window covers each probe/announce cycle (boot, wifi reconnect, or internal _restart() triggered by netif changes); outside the window there are zero scheduler dispatches and the scheduler heap contains no mDNS items. ESP8266 is WiFi-only in the Arduino build so the path is unconditional. RP2040 supports W5500 ethernet without WiFi, so the listener is requested only when WiFi is in the config; ethernet-only RP2040 builds keep the legacy polling loop. Scheduler IDs use uint32_t (MDNS_POLL_ID / MDNS_POLL_STOP_ID) to avoid the name-hash/strcmp cost of string-named timers on the cancel + re-arm paths.
Description
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Readme
Multiple Licenses
582 MiB
Languages
C++
56%
Python
43.4%
C
0.3%
JavaScript
0.2%
