From 6aae7e9c3d9e09ee7471010dbe81cce10a635556 Mon Sep 17 00:00:00 2001 From: "tarun.kumar" Date: Wed, 9 Sep 2026 12:51:14 +0530 Subject: [PATCH 1/3] fix(wifi) : Preserve SSID and authmode across disconnect for blacklist recovery --- components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c b/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c index 29b331a464e..fe28e21f977 100644 --- a/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c +++ b/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c @@ -608,8 +608,6 @@ static void roaming_app_set_disconnected_state(const wifi_event_sta_disconnected g_roaming_app.current_bss.btm_support = false; g_roaming_app.current_bss.rrm_support = false; g_roaming_app.current_bss.ap.rssi = -128; - g_roaming_app.current_bss.ap.authmode = WIFI_AUTH_OPEN; - memset(g_roaming_app.current_bss.ap.ssid, 0, sizeof(g_roaming_app.current_bss.ap.ssid)); if (disconn) { memcpy(g_roaming_app.current_bss.ap.bssid, disconn->bssid, ETH_ALEN); From dd6a87a73445584bd3e5713d781c5684e2f2c544 Mon Sep 17 00:00:00 2001 From: "tarun.kumar" Date: Wed, 2 Sep 2026 12:44:03 +0530 Subject: [PATCH 2/3] fix(wifi) : Roam handle unregister issue --- .../esp_wifi/wifi_apps/roaming_app/src/roaming_app.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c b/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c index fe28e21f977..bb9b8d4e2cf 100644 --- a/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c +++ b/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c @@ -2198,8 +2198,11 @@ void roam_init_app(void) ESP_LOGE(ROAMING_TAG, "No roaming method enabled. Roaming app cannot be initialized"); return; #endif + if (g_roaming_app.app_active) { + ESP_LOGD(ROAMING_TAG, "Roaming app already initialized"); + return; + } memset(&g_roaming_app, 0, sizeof(g_roaming_app)); - g_roaming_app.app_active = true; #if LOW_RSSI_ROAMING_ENABLED ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_BSS_RSSI_LOW, &roaming_app_rssi_low_handler, NULL)); @@ -2210,6 +2213,7 @@ void roam_init_app(void) ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_NEIGHBOR_REP, &roaming_app_neighbor_report_recv_handler, NULL)); #endif /*PERIODIC_RRM_MONITORING*/ + g_roaming_app.app_active = true; ESP_LOGI(ROAMING_TAG, "Roaming app initialization done"); } @@ -2243,7 +2247,6 @@ static int roaming_app_deinit_internal(void *ctx, void *data) { (void) ctx; (void) data; - g_roaming_app.app_active = false; roaming_app_cancel_pending_events(); roaming_app_stop_periodic_monitors(); roaming_app_reset_connect_hint_state(); @@ -2285,6 +2288,7 @@ void roam_deinit_app(void) ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_NEIGHBOR_REP, &roaming_app_neighbor_report_recv_handler)); #endif /*PERIODIC_RRM_MONITORING*/ + g_roaming_app.app_active = false; } #if CONFIG_ESP_WIFI_ROAMING_BSSID_BLACKLIST From bc20f7e76e83f807ab54232b84cb13a20eacb8a8 Mon Sep 17 00:00:00 2001 From: "tarun.kumar" Date: Wed, 26 Aug 2026 14:46:09 +0530 Subject: [PATCH 3/3] fix(wifi): Send Low RSSI reason in BTM Query for roaming Roaming previously used REASON_RSSI (5), which APs decode as Load Balancing. Send Low RSSI (16) from RoamingApp and the example without changing the public btm_query_reason enum. --- .../wifi_apps/roaming_app/src/roaming_app.c | 5 +++- .../roaming_11kvr/main/roaming_example.c | 25 +++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c b/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c index bb9b8d4e2cf..bc2b731a006 100644 --- a/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c +++ b/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c @@ -33,6 +33,8 @@ #include "common/wpa_common.h" #include "esp_wpas_glue.h" +#define BTM_QUERY_REASON_LOW_RSSI 16 + static struct roaming_app g_roaming_app; extern bool current_task_is_wifi_task(void); @@ -1440,7 +1442,8 @@ static bool trigger_network_assisted_roam(struct cand_bss *bss) btm_candidates = query_list; } - if (esp_wnm_send_bss_transition_mgmt_query(REASON_RSSI, btm_candidates, 1) < 0) { + if (esp_wnm_send_bss_transition_mgmt_query((enum btm_query_reason)BTM_QUERY_REASON_LOW_RSSI, + btm_candidates, 1) < 0) { ESP_LOGD(ROAMING_TAG, "failed to send btm query"); os_free(query_list); return false; diff --git a/examples/wifi/roaming/roaming_11kvr/main/roaming_example.c b/examples/wifi/roaming/roaming_11kvr/main/roaming_example.c index 35a201b8ed5..cd7b3c3efe7 100644 --- a/examples/wifi/roaming/roaming_11kvr/main/roaming_example.c +++ b/examples/wifi/roaming/roaming_11kvr/main/roaming_example.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -20,6 +20,8 @@ #include "esp_netif.h" #include +#define BTM_QUERY_REASON_LOW_RSSI 16 + /* Configuration */ #define EXAMPLE_WIFI_SSID CONFIG_EXAMPLE_WIFI_SSID #define EXAMPLE_WIFI_PASSWORD CONFIG_EXAMPLE_WIFI_PASSWORD @@ -344,18 +346,18 @@ static void esp_neighbor_report_recv_handler(void* arg, esp_event_base_t event_b wifi_scan_config_t params; memset(¶ms, 0, sizeof(wifi_scan_config_t)); if (esp_wifi_scan_start(¶ms, true) != ESP_OK) { - goto cleanup; - } - /* cleanup from net802.11 */ + goto cleanup; + } + /* cleanup from net802.11 */ esp_wifi_clear_ap_list(); cand_list = 1; - } - /* send AP btm query, this will cause STA to roam as well */ - esp_wnm_send_bss_transition_mgmt_query(REASON_FRAME_LOSS, neighbor_list, cand_list); + } + /* send AP btm query, this will cause STA to roam as well */ + esp_wnm_send_bss_transition_mgmt_query(REASON_FRAME_LOSS, neighbor_list, cand_list); cleanup: - if (neighbor_list) - free(neighbor_list); - + if (neighbor_list) { + free(neighbor_list); + } } #if EXAMPLE_WIFI_RSSI_THRESHOLD @@ -369,7 +371,8 @@ static void esp_bss_rssi_low_handler(void* arg, esp_event_base_t event_base, if (esp_rrm_send_neighbor_report_request() < 0) { /* failed to send neighbor report request */ ESP_LOGI(TAG, "failed to send neighbor report request"); - if (esp_wnm_send_bss_transition_mgmt_query(REASON_FRAME_LOSS, NULL, 0) < 0) { + if (esp_wnm_send_bss_transition_mgmt_query((enum btm_query_reason)BTM_QUERY_REASON_LOW_RSSI, + NULL, 0) < 0) { ESP_LOGI(TAG, "failed to send btm query"); } } else {