esp_wifi: Add APIs to check BTM and RRM support of connected AP

This commit is contained in:
Kapil Gupta 2022-05-13 12:21:57 +05:30
parent 972aa9a9a9
commit f05d741c03
5 changed files with 106 additions and 21 deletions

View File

@ -1,17 +1,7 @@
/**
* Copyright 2020 Espressif Systems (Shanghai) PTE LTD
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _ESP_RRM_H
@ -41,11 +31,22 @@ typedef void (*neighbor_rep_request_cb)(void *ctx, const uint8_t *report, size_t
* @param cb_ctx: callback context
*
* @return
* - 0: success else failure
* - 0: success
* - -1: AP does not support RRM
* - -2: station not connected to AP
*/
int esp_rrm_send_neighbor_rep_request(neighbor_rep_request_cb cb,
void *cb_ctx);
/**
* @brief Check RRM capability of connected AP
*
* @return
* - true: AP supports RRM
* - false: AP does not support RRM or station not connected to AP
*/
bool esp_rrm_is_rrm_supported_connection(void);
#ifdef __cplusplus
}
#endif

View File

@ -36,12 +36,23 @@ enum btm_query_reason {
* @param cand_list: whether candidate list to be included from scan results available in supplicant's cache.
*
* @return
* - 0: success else failure
* - 0: success
* - -1: AP does not support BTM
* - -2: station not connected to AP
*/
int esp_wnm_send_bss_transition_mgmt_query(enum btm_query_reason query_reason,
const char *btm_candidates,
int cand_list);
/**
* @brief Check bss trasition capability of connected AP
*
* @return
* - true: AP supports BTM
* - false: AP does not support BTM or station not connected to AP
*/
bool esp_wnm_is_btm_supported_connection(void);
#ifdef __cplusplus
}
#endif

View File

@ -343,23 +343,83 @@ void esp_supplicant_common_deinit(void)
}
}
bool esp_rrm_is_rrm_supported_connection(void)
{
struct wpa_supplicant *wpa_s = &g_wpa_supp;
if (!wpa_s->current_bss) {
wpa_printf(MSG_DEBUG, "STA not associated, return");
return false;
}
if (!(wpa_s->rrm_ie[0] & WLAN_RRM_CAPS_NEIGHBOR_REPORT)) {
wpa_printf(MSG_DEBUG,
"RRM: No network support for Neighbor Report.");
return false;
}
return true;
}
int esp_rrm_send_neighbor_rep_request(neighbor_rep_request_cb cb,
void *cb_ctx)
{
struct wpa_supplicant *wpa_s = &g_wpa_supp;
struct wpa_ssid_value wpa_ssid = {0};
struct wifi_ssid *ssid = esp_wifi_sta_get_prof_ssid_internal();
struct wifi_ssid *ssid;
if (!wpa_s->current_bss) {
wpa_printf(MSG_ERROR, "STA not associated, return");
return -2;
}
if (!(wpa_s->rrm_ie[0] & WLAN_RRM_CAPS_NEIGHBOR_REPORT)) {
wpa_printf(MSG_ERROR,
"RRM: No network support for Neighbor Report.");
return -1;
}
ssid = esp_wifi_sta_get_prof_ssid_internal();
os_memcpy(wpa_ssid.ssid, ssid->ssid, ssid->len);
wpa_ssid.ssid_len = ssid->len;
return wpas_rrm_send_neighbor_rep_request(&g_wpa_supp, &wpa_ssid, 0, 0, cb, cb_ctx);
return wpas_rrm_send_neighbor_rep_request(wpa_s, &wpa_ssid, 0, 0, cb, cb_ctx);
}
bool esp_wnm_is_btm_supported_connection(void)
{
struct wpa_supplicant *wpa_s = &g_wpa_supp;
if (!wpa_s->current_bss) {
wpa_printf(MSG_DEBUG, "STA not associated, return");
return false;
}
if (!wpa_bss_ext_capab(wpa_s->current_bss, WLAN_EXT_CAPAB_BSS_TRANSITION)) {
wpa_printf(MSG_DEBUG, "AP doesn't support BTM, return");
return false;
}
return true;
}
int esp_wnm_send_bss_transition_mgmt_query(enum btm_query_reason query_reason,
const char *btm_candidates,
int cand_list)
{
return wnm_send_bss_transition_mgmt_query(&g_wpa_supp, query_reason, btm_candidates, cand_list);
struct wpa_supplicant *wpa_s = &g_wpa_supp;
if (!wpa_s->current_bss) {
wpa_printf(MSG_ERROR, "STA not associated, return");
return -2;
}
if (!wpa_bss_ext_capab(wpa_s->current_bss, WLAN_EXT_CAPAB_BSS_TRANSITION)) {
wpa_printf(MSG_ERROR, "AP doesn't support BTM, return");
return -1;
}
return wnm_send_bss_transition_mgmt_query(wpa_s, query_reason, btm_candidates, cand_list);
}
int esp_mbo_update_non_pref_chan(struct non_pref_chan_s *non_pref_chan)
@ -471,9 +531,9 @@ static uint8_t get_extended_caps_ie(uint8_t *ie, size_t len)
*pos++ = ext_caps_ie_len;
*pos++ = 0;
*pos++ = 0;
#define WLAN_EXT_CAPAB_BSS_TRANSITION BIT(3)
*pos |= WLAN_EXT_CAPAB_BSS_TRANSITION;
#undef WLAN_EXT_CAPAB_BSS_TRANSITION
#define CAPAB_BSS_TRANSITION BIT(3)
*pos |= CAPAB_BSS_TRANSITION;
#undef CAPAB_BSS_TRANSITION
os_memcpy(ie, ext_caps_ie, sizeof(ext_caps_ie));
return ext_caps_ie_len + 2;

View File

@ -250,6 +250,8 @@
#define WLAN_EID_EXT_HE_CAPABILITIES 35
#define WLAN_EID_EXT_HE_OPERATION 36
#define WLAN_EXT_CAPAB_BSS_TRANSITION 19
/* Action frame categories (IEEE Std 802.11-2016, 9.4.1.11, Table 9-76) */
#define WLAN_ACTION_SPECTRUM_MGMT 0
#define WLAN_ACTION_QOS 1

View File

@ -54,6 +54,17 @@ static void event_handler(void* arg, esp_event_base_t event_base,
esp_wifi_set_rssi_threshold(EXAMPLE_WIFI_RSSI_THRESHOLD);
}
#endif
if (esp_rrm_is_rrm_supported_connection()) {
ESP_LOGI(TAG,"RRM supported");
} else {
ESP_LOGI(TAG,"RRM not supported");
}
if (esp_wnm_is_btm_supported_connection()) {
ESP_LOGI(TAG,"BTM supported");
} else {
ESP_LOGI(TAG,"BTM not supported");
}
}
}