From b2abac0a4eac09af38e2501c0ea0564391583b0a Mon Sep 17 00:00:00 2001 From: Aditi Date: Fri, 27 Sep 2024 00:51:29 +0530 Subject: [PATCH] fix(wpa_supplicant): Add some minor fixes in roaming 1) Add a fix in roaming example for 11kvr 2) Removed length constraint for neighbor report received. --- .../esp_wifi/include/esp_wifi_types_generic.h | 3 ++- .../esp_supplicant/src/esp_common.c | 21 ++++++++++++------- .../roaming_11kvr/main/roaming_example.c | 3 +-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi_types_generic.h b/components/esp_wifi/include/esp_wifi_types_generic.h index e232f8bf5c..59a1b50835 100644 --- a/components/esp_wifi/include/esp_wifi_types_generic.h +++ b/components/esp_wifi/include/esp_wifi_types_generic.h @@ -1203,8 +1203,9 @@ typedef struct { * @brief Argument structure for WIFI_EVENT_STA_NEIGHBOR_REP event */ typedef struct { - uint8_t report[ESP_WIFI_MAX_NEIGHBOR_REP_LEN]; /**< Neighbor Report received from the AP*/ + uint8_t report[ESP_WIFI_MAX_NEIGHBOR_REP_LEN]; /**< Neighbor Report received from the AP (will be deprecated in next major release, use n_report instead)*/ uint16_t report_len; /**< Length of the report*/ + uint8_t n_report[]; /**< Neighbor Report received from the AP*/ } wifi_event_neighbor_report_t; /** Argument structure for wifi band */ diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common.c b/components/wpa_supplicant/esp_supplicant/src/esp_common.c index cc2f4d1f35..45d0da459c 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -543,15 +543,20 @@ void neighbor_report_recvd_cb(void *ctx, const uint8_t *report, size_t report_le 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; + + wifi_event_neighbor_report_t *neighbor_report_event = os_zalloc(sizeof(wifi_event_neighbor_report_t) + report_len); + if (neighbor_report_event == NULL) { + wpa_printf(MSG_DEBUG, "memory alloc failed"); + } + + if (report_len < ESP_WIFI_MAX_NEIGHBOR_REP_LEN) { + os_memcpy(neighbor_report_event->report, report, report_len); + } + os_memcpy(neighbor_report_event->n_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); + os_free(neighbor_report_event); } int esp_rrm_send_neighbor_report_request(void) diff --git a/examples/wifi/roaming/roaming_11kvr/main/roaming_example.c b/examples/wifi/roaming/roaming_11kvr/main/roaming_example.c index 3e47cbb158..edf0669494 100644 --- a/examples/wifi/roaming/roaming_11kvr/main/roaming_example.c +++ b/examples/wifi/roaming/roaming_11kvr/main/roaming_example.c @@ -364,9 +364,8 @@ static void esp_bss_rssi_low_handler(void* arg, esp_event_base_t event_base, { wifi_event_bss_rssi_low_t *event = event_data; - ESP_LOGI(TAG, "%s:bss rssi is=%d", __func__, event->rssi); + ESP_LOGI(TAG, "%s:bss rssi is=%ld", __func__, event->rssi); /* Lets check channel conditions */ - rrm_ctx++; if (esp_rrm_send_neighbor_report_request() < 0) { /* failed to send neighbor report request */ ESP_LOGI(TAG, "failed to send neighbor report request");