mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-23 09:20:30 +00:00
esp_wifi: Add APIs to check BTM and RRM support of connected AP
This commit is contained in:
@@ -429,23 +429,82 @@ void esp_supplicant_common_deinit(void)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_WPA_11KV_SUPPORT
|
||||
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)
|
||||
@@ -572,9 +631,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;
|
||||
|
Reference in New Issue
Block a user