mirror of
https://github.com/esphome/esphome.git
synced 2026-09-22 04:28:43 +00:00
[mdns] Keep the roaming tick skip as a performance guard
Each failing send spins sendTimeout() for 50 ms while the radio is off channel, so skip the tick on is_roaming_scan_active() instead of stalling the loop; the wifi accessor removal is no longer needed.
This commit is contained in:
@@ -89,7 +89,16 @@ static void register_esp8266(MDNSComponent *, StaticVector<MDNSService, MDNS_SER
|
||||
#ifdef USE_MDNS_EVENT_DRIVEN_POLLING
|
||||
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_responder.update_guarded(); });
|
||||
this->set_interval(MDNS_POLL_ID, MDNS_UPDATE_INTERVAL_MS, []() {
|
||||
#ifdef USE_MDNS_WIFI_LISTENER
|
||||
// Every send fails while the radio is off channel or no interface is up, and each one
|
||||
// spins sendTimeout() for 50 ms; skip the tick rather than stall the loop for nothing.
|
||||
auto *wifi = wifi::global_wifi_component;
|
||||
if (wifi->is_roaming_scan_active() || (!wifi->is_connected() && !wifi->is_ap_active()))
|
||||
return;
|
||||
#endif
|
||||
mdns_responder.update_guarded();
|
||||
});
|
||||
this->set_timeout(MDNS_POLL_STOP_ID, MDNS_POLL_WINDOW_MS, [this]() { this->cancel_interval(MDNS_POLL_ID); });
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -476,6 +476,10 @@ class WiFiComponent final : public Component {
|
||||
/// True while a post-connect roaming scan holds the radio off-channel.
|
||||
bool is_roaming_scan_active() const { return this->roaming_state_ == RoamingState::SCANNING; }
|
||||
|
||||
/// True while a post-connect roam is in progress (scanning off-channel, reassociating,
|
||||
/// or recovering from a failed roam).
|
||||
bool is_roaming() const { return this->roaming_state_ != RoamingState::IDLE; }
|
||||
|
||||
#ifdef USE_ESP32
|
||||
/// esp_netif handle of the station interface, used by network for default-route
|
||||
/// arbitration. nullptr until wifi_lazy_init_() has run.
|
||||
|
||||
Reference in New Issue
Block a user