mirror of
https://github.com/esphome/esphome.git
synced 2026-10-14 10:12:52 +00:00
[wifi] Leave the AP before a reboot on every platform
This commit is contained in:
@@ -766,6 +766,19 @@ void WiFiComponent::restart_adapter() {
|
||||
this->error_from_callback_ = false;
|
||||
}
|
||||
|
||||
#ifndef USE_LN882X // LN882x leaves through the SDK directly; see wifi_component_libretiny.cpp
|
||||
void WiFiComponent::on_powerdown() {
|
||||
// Leave the AP before a reboot or deep sleep, after teardown has let the
|
||||
// API say goodbye: otherwise the AP still holds the association when the
|
||||
// device comes back and the first connects can stall or fail.
|
||||
if (!this->is_connected())
|
||||
return;
|
||||
ESP_LOGD(TAG, "Disconnecting before reboot");
|
||||
this->wifi_disconnect_();
|
||||
delay(100); // let the deauth go out before the reset
|
||||
}
|
||||
#endif
|
||||
|
||||
void WiFiComponent::loop() {
|
||||
bool events_processed = this->wifi_loop_();
|
||||
const uint32_t now = App.get_loop_component_start_time();
|
||||
|
||||
@@ -506,9 +506,7 @@ class WiFiComponent final : public Component {
|
||||
// (In most use cases you won't need these)
|
||||
/// Setup WiFi interface.
|
||||
void setup() override;
|
||||
#ifdef USE_LN882X
|
||||
void on_powerdown() override;
|
||||
#endif
|
||||
void start();
|
||||
void dump_config() override;
|
||||
void restart_adapter();
|
||||
|
||||
Reference in New Issue
Block a user