From 66eec7af15eba41697eca4eb33c0508ab818e295 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 4 Oct 2026 19:58:35 -0500 Subject: [PATCH] [wifi] Keep a second fallback AP start from resetting the LN882x (#20168) --- esphome/components/wifi/wifi_component_libretiny.cpp | 12 ++++++++++++ tests/components/wifi/test-ap.ln882x-ard.yaml | 9 +++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/components/wifi/test-ap.ln882x-ard.yaml diff --git a/esphome/components/wifi/wifi_component_libretiny.cpp b/esphome/components/wifi/wifi_component_libretiny.cpp index 940f2a0783..1d9fda6d2f 100644 --- a/esphome/components/wifi/wifi_component_libretiny.cpp +++ b/esphome/components/wifi/wifi_component_libretiny.cpp @@ -28,6 +28,11 @@ extern "C" { } #endif +#ifdef USE_LN882X +#include +#undef DATA // clashes with setup_priority::DATA +#endif + #include "esphome/core/application.h" #include "esphome/core/hal.h" #include "esphome/core/helpers.h" @@ -770,6 +775,13 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) { yield(); +#ifdef USE_LN882X + // LibreTiny's LN882H softAP() points ap.bssid at a static array and frees it + // on the next call, tripping FreeRTOS's configASSERT until the watchdog + // resets the chip. Clear it so that a second AP start frees nothing. + static_cast(WiFi.data)->ap.bssid = nullptr; +#endif + return WiFi.softAP(ap.ssid_.c_str(), ap.password_.empty() ? NULL : ap.password_.c_str(), ap.has_channel() ? ap.get_channel() : 1, ap.get_hidden()); } diff --git a/tests/components/wifi/test-ap.ln882x-ard.yaml b/tests/components/wifi/test-ap.ln882x-ard.yaml new file mode 100644 index 0000000000..6a38eb5f27 --- /dev/null +++ b/tests/components/wifi/test-ap.ln882x-ard.yaml @@ -0,0 +1,9 @@ +wifi: + networks: + - ssid: MySSID + password: password1 + ap: + ssid: Fallback Hotspot + password: password2 + +captive_portal: