[wifi] Leave the AP before a reboot on every platform

This commit is contained in:
J. Nick Koston
2026-10-04 21:06:51 -05:00
parent 671a165dcd
commit 4b747f82fb
2 changed files with 13 additions and 2 deletions
@@ -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();
-2
View File
@@ -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();