mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_wifi: Add APIs to check BTM and RRM support of connected AP
This commit is contained in:
parent
3e789d4ed4
commit
77661ba436
@ -1,17 +1,6 @@
|
||||
/**
|
||||
* Copyright 2020 Espressif Systems (Shanghai) PTE 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-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_RRM_H
|
||||
@ -41,11 +30,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
|
||||
|
@ -1,17 +1,6 @@
|
||||
/**
|
||||
* Copyright 2020 Espressif Systems (Shanghai) PTE 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-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_WNM_H
|
||||
@ -44,12 +33,22 @@ 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
|
||||
|
@ -249,6 +249,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
|
||||
|
@ -312,23 +312,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);
|
||||
}
|
||||
|
||||
void wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
|
||||
|
@ -52,6 +52,16 @@ 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user