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.
This commit is contained in:
tarun.kumar
2026-09-10 11:52:25 +08:00
committed by BOT
parent 764a0c442e
commit ce30446c3d
2 changed files with 18 additions and 12 deletions
@@ -33,6 +33,8 @@
#include "common/wpa_common.h" #include "common/wpa_common.h"
#include "esp_wpas_glue.h" #include "esp_wpas_glue.h"
#define BTM_QUERY_REASON_LOW_RSSI 16
static struct roaming_app g_roaming_app; static struct roaming_app g_roaming_app;
extern bool current_task_is_wifi_task(void); extern bool current_task_is_wifi_task(void);
@@ -1442,7 +1444,8 @@ static bool trigger_network_assisted_roam(struct cand_bss *bss)
btm_candidates = query_list; 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"); ESP_LOGD(ROAMING_TAG, "failed to send btm query");
os_free(query_list); os_free(query_list);
return false; return false;
@@ -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 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -20,6 +20,8 @@
#include "esp_netif.h" #include "esp_netif.h"
#include <sys/time.h> #include <sys/time.h>
#define BTM_QUERY_REASON_LOW_RSSI 16
/* Configuration */ /* Configuration */
#define EXAMPLE_WIFI_SSID CONFIG_EXAMPLE_WIFI_SSID #define EXAMPLE_WIFI_SSID CONFIG_EXAMPLE_WIFI_SSID
#define EXAMPLE_WIFI_PASSWORD CONFIG_EXAMPLE_WIFI_PASSWORD #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; wifi_scan_config_t params;
memset(&params, 0, sizeof(wifi_scan_config_t)); memset(&params, 0, sizeof(wifi_scan_config_t));
if (esp_wifi_scan_start(&params, true) != ESP_OK) { if (esp_wifi_scan_start(&params, true) != ESP_OK) {
goto cleanup; goto cleanup;
} }
/* cleanup from net802.11 */ /* cleanup from net802.11 */
esp_wifi_clear_ap_list(); esp_wifi_clear_ap_list();
cand_list = 1; cand_list = 1;
} }
/* send AP btm query, this will cause STA to roam as well */ /* 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); esp_wnm_send_bss_transition_mgmt_query(REASON_FRAME_LOSS, neighbor_list, cand_list);
cleanup: cleanup:
if (neighbor_list) if (neighbor_list) {
free(neighbor_list); free(neighbor_list);
}
} }
#if EXAMPLE_WIFI_RSSI_THRESHOLD #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) { if (esp_rrm_send_neighbor_report_request() < 0) {
/* failed to send neighbor report request */ /* failed to send neighbor report request */
ESP_LOGI(TAG, "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"); ESP_LOGI(TAG, "failed to send btm query");
} }
} else { } else {