Compare commits

...
Author SHA1 Message Date
J. Nick Koston c8491e1e30 Merge ln882x-shutdown-disconnect; LN882x checks association before leaving the AP 2026-10-04 21:59:40 -05:00
J. Nick Koston 6dcfad1e44 [wifi] Leave the AP on LN882x powerdown whenever associated, even before DHCP 2026-10-04 21:59:07 -05:00
J. Nick Koston 07d7dfd0d1 Merge ln882x-shutdown-disconnect; shorten the powerdown comments and allow its delay 2026-10-04 21:55:49 -05:00
J. Nick Koston 14201bcbbc [wifi] Shorten the LN882x powerdown comments and allow its delay 2026-10-04 21:55:35 -05:00
J. Nick Koston 07c5203241 Merge branch 'ln882x-shutdown-disconnect' into wifi-disconnect-before-reboot
# Conflicts:
#	esphome/components/wifi/wifi_component_libretiny.cpp
2026-10-04 21:52:26 -05:00
J. Nick Koston c6f5b6dbd3 [wifi] Say powerdown, not reboot, in the LN882x disconnect log 2026-10-04 21:52:17 -05:00
J. Nick Koston a78316947b [wifi] Share one on_powerdown body; LN882x only swaps the disconnect call 2026-10-04 21:10:55 -05:00
J. Nick Koston 4b747f82fb [wifi] Leave the AP before a reboot on every platform 2026-10-04 21:06:51 -05:00
J. Nick Koston 671a165dcd [wifi] Disconnect LN882x in on_powerdown, after the API has said goodbye 2026-10-04 21:03:05 -05:00
J. Nick Koston f34847a92c [wifi] Call the SDK disconnect directly before an LN882x reboot 2026-10-04 20:57:51 -05:00
J. Nick Koston 515e15e6c0 Merge remote-tracking branch 'origin/dev' into ln882x-shutdown-disconnect 2026-10-04 20:57:25 -05:00
J. Nick Koston 97216aa4fa [wifi] Leave the AP before an LN882x reboots 2026-10-04 20:35:24 -05:00
3 changed files with 27 additions and 0 deletions
@@ -766,6 +766,20 @@ void WiFiComponent::restart_adapter() {
this->error_from_callback_ = false;
}
void WiFiComponent::on_powerdown() {
// Leave the AP so it no longer holds the association when we come back.
#ifdef USE_LN882X
if (!this->wifi_powerdown_disconnect_())
return;
#else
if (!this->is_connected())
return;
this->wifi_disconnect_();
#endif
ESP_LOGD(TAG, "Disconnected before powerdown");
delay(100); // NOLINT: once per reboot or deep sleep, lets the deauth go out
}
void WiFiComponent::loop() {
bool events_processed = this->wifi_loop_();
const uint32_t now = App.get_loop_component_start_time();
+4
View File
@@ -506,6 +506,7 @@ class WiFiComponent final : public Component {
// (In most use cases you won't need these)
/// Setup WiFi interface.
void setup() override;
void on_powerdown() override;
void start();
void dump_config() override;
void restart_adapter();
@@ -791,6 +792,9 @@ class WiFiComponent final : public Component {
#endif // USE_WIFI_AP
bool wifi_disconnect_();
#ifdef USE_LN882X
bool wifi_powerdown_disconnect_();
#endif
network::IPAddress wifi_subnet_mask_();
network::IPAddress wifi_gateway_ip_();
@@ -789,6 +789,15 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
network::IPAddress WiFiComponent::wifi_soft_ap_ip() { return {WiFi.softAPIP()}; }
#endif // USE_WIFI_AP
#ifdef USE_LN882X
bool WiFiComponent::wifi_powerdown_disconnect_() {
if (WiFi.status() != WL_CONNECTED) // associated, even before DHCP has finished
return false;
wifi_sta_disconnect(); // not WiFi.disconnect(): it frees the SSID its event handlers read
return true;
}
#endif
bool WiFiComponent::wifi_disconnect_() {
// Reset state first so disconnect events aren't ignored
// and wifi_sta_connect_status_() returns IDLE instead of CONNECTING