mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
esp_wifi: Add APIs to check BTM and RRM support of connected AP
This commit is contained in:
@ -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");
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ESP_RRM_H
|
#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
|
* @param cb_ctx: callback context
|
||||||
*
|
*
|
||||||
* @return
|
* @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,
|
int esp_rrm_send_neighbor_rep_request(neighbor_rep_request_cb cb,
|
||||||
void *cb_ctx);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -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.
|
* @param cand_list: whether candidate list to be included from scan results available in supplicant's cache.
|
||||||
*
|
*
|
||||||
* @return
|
* @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,
|
int esp_wnm_send_bss_transition_mgmt_query(enum btm_query_reason query_reason,
|
||||||
const char *btm_candidates,
|
const char *btm_candidates,
|
||||||
int cand_list);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -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,
|
int esp_rrm_send_neighbor_rep_request(neighbor_rep_request_cb cb,
|
||||||
void *cb_ctx)
|
void *cb_ctx)
|
||||||
{
|
{
|
||||||
|
struct wpa_supplicant *wpa_s = &g_wpa_supp;
|
||||||
struct wpa_ssid_value wpa_ssid = {0};
|
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);
|
os_memcpy(wpa_ssid.ssid, ssid->ssid, ssid->len);
|
||||||
wpa_ssid.ssid_len = 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,
|
int esp_wnm_send_bss_transition_mgmt_query(enum btm_query_reason query_reason,
|
||||||
const char *btm_candidates,
|
const char *btm_candidates,
|
||||||
int cand_list)
|
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)
|
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++ = ext_caps_ie_len;
|
||||||
*pos++ = 0;
|
*pos++ = 0;
|
||||||
*pos++ = 0;
|
*pos++ = 0;
|
||||||
#define WLAN_EXT_CAPAB_BSS_TRANSITION BIT(3)
|
#define CAPAB_BSS_TRANSITION BIT(3)
|
||||||
*pos |= WLAN_EXT_CAPAB_BSS_TRANSITION;
|
*pos |= CAPAB_BSS_TRANSITION;
|
||||||
#undef WLAN_EXT_CAPAB_BSS_TRANSITION
|
#undef CAPAB_BSS_TRANSITION
|
||||||
os_memcpy(ie, ext_caps_ie, sizeof(ext_caps_ie));
|
os_memcpy(ie, ext_caps_ie, sizeof(ext_caps_ie));
|
||||||
|
|
||||||
return ext_caps_ie_len + 2;
|
return ext_caps_ie_len + 2;
|
||||||
|
@ -250,6 +250,8 @@
|
|||||||
#define WLAN_EID_EXT_HE_CAPABILITIES 35
|
#define WLAN_EID_EXT_HE_CAPABILITIES 35
|
||||||
#define WLAN_EID_EXT_HE_OPERATION 36
|
#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) */
|
/* Action frame categories (IEEE Std 802.11-2016, 9.4.1.11, Table 9-76) */
|
||||||
#define WLAN_ACTION_SPECTRUM_MGMT 0
|
#define WLAN_ACTION_SPECTRUM_MGMT 0
|
||||||
#define WLAN_ACTION_QOS 1
|
#define WLAN_ACTION_QOS 1
|
||||||
|
@ -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);
|
esp_wifi_set_rssi_threshold(EXAMPLE_WIFI_RSSI_THRESHOLD);
|
||||||
}
|
}
|
||||||
#endif
|
#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");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user