mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(wpa_supplicant): Replace Neighbor Report callback with an event
- Deprecate the existing esp_rrm_send_neighbor_rep_request() API - Adds a new API to send neighbor report requests esp_rrm_send_neighbor_report_request(). This replaces the older API's callback procedure with a new Wi-Fi event that is posted when the neighbor report is received. This moves the execution of the callback from supplicant context to freertos context.
This commit is contained in:
parent
743772fb76
commit
c6134a23dd
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -27,6 +27,8 @@ typedef void (*neighbor_rep_request_cb)(void *ctx, const uint8_t *report, size_t
|
||||
/**
|
||||
* @brief Send Radio measurement neighbor report request to connected AP
|
||||
*
|
||||
* @deprecated This function is deprecated and will be removed in the future.
|
||||
* Please use 'esp_rrm_send_neighbor_report_request'
|
||||
* @param cb: callback function for neighbor report
|
||||
* @param cb_ctx: callback context
|
||||
*
|
||||
@ -35,8 +37,18 @@ typedef void (*neighbor_rep_request_cb)(void *ctx, const uint8_t *report, size_t
|
||||
* - -1: AP does not support RRM
|
||||
* - -2: station not connected to AP
|
||||
*/
|
||||
|
||||
__attribute__((deprecated("Use 'esp_rrm_send_neighbor_report_request' instead")))
|
||||
int esp_rrm_send_neighbor_rep_request(neighbor_rep_request_cb cb,
|
||||
void *cb_ctx);
|
||||
void *cb_ctx);
|
||||
/**
|
||||
* @brief Send Radio measurement neighbor report request to connected AP
|
||||
* @return
|
||||
* - 0: success
|
||||
* - -1: AP does not support RRM
|
||||
* - -2: station not connected to AP
|
||||
*/
|
||||
int esp_rrm_send_neighbor_report_request(void);
|
||||
|
||||
/**
|
||||
* @brief Check RRM capability of connected AP
|
||||
|
@ -477,6 +477,7 @@ bool esp_rrm_is_rrm_supported_connection(void)
|
||||
|
||||
return true;
|
||||
}
|
||||
/*This function has been deprecated in favour of esp_rrm_send_neighbor_report_request*/
|
||||
int esp_rrm_send_neighbor_rep_request(neighbor_rep_request_cb cb,
|
||||
void *cb_ctx)
|
||||
{
|
||||
@ -503,6 +504,49 @@ int esp_rrm_send_neighbor_rep_request(neighbor_rep_request_cb cb,
|
||||
return wpas_rrm_send_neighbor_rep_request(wpa_s, &wpa_ssid, 0, 0, cb, cb_ctx);
|
||||
}
|
||||
|
||||
|
||||
void neighbor_report_recvd_cb(void *ctx, const uint8_t *report, size_t report_len) {
|
||||
if (report == NULL) {
|
||||
wpa_printf(MSG_DEBUG, "RRM: Notifying neighbor report - NONE");
|
||||
esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_NEIGHBOR_REP, NULL, 0, 0);
|
||||
return;
|
||||
}
|
||||
if (report_len > ESP_WIFI_MAX_NEIGHBOR_REP_LEN) {
|
||||
wpa_printf(MSG_ERROR, "RRM: Neighbor report too large (>%d bytes), hence not reporting", ESP_WIFI_MAX_NEIGHBOR_REP_LEN);
|
||||
return;
|
||||
}
|
||||
wpa_printf(MSG_DEBUG, "RRM: Notifying neighbor report (token = %d)", report[0]);
|
||||
wifi_event_neighbor_report_t neighbor_report_event = {0};
|
||||
os_memcpy(neighbor_report_event.report, report, report_len);
|
||||
neighbor_report_event.report_len = report_len;
|
||||
esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_NEIGHBOR_REP, &neighbor_report_event, sizeof(wifi_event_neighbor_report_t), 0);
|
||||
}
|
||||
|
||||
int esp_rrm_send_neighbor_report_request(void)
|
||||
{
|
||||
struct wpa_supplicant *wpa_s = &g_wpa_supp;
|
||||
struct wpa_ssid_value wpa_ssid = {0};
|
||||
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(wpa_s, &wpa_ssid, 0, 0, neighbor_report_recvd_cb, NULL);
|
||||
}
|
||||
|
||||
bool esp_wnm_is_btm_supported_connection(void)
|
||||
{
|
||||
struct wpa_supplicant *wpa_s = &g_wpa_supp;
|
||||
@ -847,12 +891,16 @@ int esp_supplicant_post_evt(uint32_t evt_id, uint32_t data)
|
||||
}
|
||||
#endif /* CONFIG_SUPPLICANT_TASK */
|
||||
#else /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */
|
||||
int esp_rrm_send_neighbor_report_request(void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int esp_rrm_send_neighbor_rep_request(neighbor_rep_request_cb cb,
|
||||
void *cb_ctx)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int esp_wnm_send_bss_transition_mgmt_query(enum btm_query_reason query_reason,
|
||||
const char *btm_candidates,
|
||||
int cand_list)
|
||||
|
Loading…
x
Reference in New Issue
Block a user