mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-18 06:35:35 +03:00
Merge branch 'bugfix/fix_some_wifi_bugs_240221_v5.2' into 'release/v5.2'
fix(lwip): fixed some wifi bugs(Backport v5.2) See merge request espressif/esp-idf!29147
This commit is contained in:
@@ -210,6 +210,7 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base,
|
||||
wifi_ap_record_t *ap_list = (wifi_ap_record_t *)malloc(sizeof(wifi_ap_record_t) * apCount);
|
||||
if (!ap_list) {
|
||||
BLUFI_ERROR("malloc error, ap_list is NULL");
|
||||
esp_wifi_clear_ap_list();
|
||||
break;
|
||||
}
|
||||
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&apCount, ap_list));
|
||||
|
||||
@@ -67,6 +67,7 @@ static void scan_done_handler(void)
|
||||
ap_list_buffer = malloc(sta_number * sizeof(wifi_ap_record_t));
|
||||
if (ap_list_buffer == NULL) {
|
||||
ESP_LOGE(TAG, "Failed to malloc buffer to print scan results");
|
||||
esp_wifi_clear_ap_list();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -304,6 +304,7 @@ static bool wifi_perform_scan(const char *ssid, bool internal)
|
||||
g_ap_list_buffer = malloc(g_scan_ap_num * sizeof(wifi_ap_record_t));
|
||||
if (g_ap_list_buffer == NULL) {
|
||||
ESP_LOGE(TAG_STA, "Failed to malloc buffer to print scan results");
|
||||
esp_wifi_clear_ap_list();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ static void scan_done_handler(void *arg, esp_event_base_t event_base,
|
||||
ap_list_buffer = malloc(sta_number * sizeof(wifi_ap_record_t));
|
||||
if (ap_list_buffer == NULL) {
|
||||
ESP_LOGE(TAG, "Failed to malloc buffer to print scan results");
|
||||
esp_wifi_clear_ap_list();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -305,9 +305,7 @@ void neighbor_report_recv_cb(void *ctx, const uint8_t *report, size_t report_len
|
||||
goto cleanup;
|
||||
}
|
||||
/* cleanup from net802.11 */
|
||||
uint16_t number = 1;
|
||||
wifi_ap_record_t ap_records;
|
||||
esp_wifi_scan_get_ap_records(&number, &ap_records);
|
||||
esp_wifi_clear_ap_list();
|
||||
cand_list = 1;
|
||||
}
|
||||
/* send AP btm query, this will cause STA to roam as well */
|
||||
|
||||
7
examples/wifi/smart_config/main/Kconfig.projbuild
Normal file
7
examples/wifi/smart_config/main/Kconfig.projbuild
Normal file
@@ -0,0 +1,7 @@
|
||||
menu "Example Configuration"
|
||||
|
||||
config SET_MAC_ADDRESS_OF_TARGET_AP
|
||||
bool "whether set MAC address of target AP or not"
|
||||
default y
|
||||
|
||||
endmenu
|
||||
@@ -13,13 +13,14 @@
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_wpa2.h"
|
||||
#include "esp_eap_client.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_smartconfig.h"
|
||||
#include "esp_mac.h"
|
||||
|
||||
/* FreeRTOS event group to signal when we are connected & ready to make a request */
|
||||
static EventGroupHandle_t s_wifi_event_group;
|
||||
@@ -59,10 +60,14 @@ static void event_handler(void* arg, esp_event_base_t event_base,
|
||||
bzero(&wifi_config, sizeof(wifi_config_t));
|
||||
memcpy(wifi_config.sta.ssid, evt->ssid, sizeof(wifi_config.sta.ssid));
|
||||
memcpy(wifi_config.sta.password, evt->password, sizeof(wifi_config.sta.password));
|
||||
|
||||
#ifdef CONFIG_SET_MAC_ADDRESS_OF_TARGET_AP
|
||||
wifi_config.sta.bssid_set = evt->bssid_set;
|
||||
if (wifi_config.sta.bssid_set == true) {
|
||||
ESP_LOGI(TAG, "Set MAC address of target AP: "MACSTR" ", MAC2STR(evt->bssid));
|
||||
memcpy(wifi_config.sta.bssid, evt->bssid, sizeof(wifi_config.sta.bssid));
|
||||
}
|
||||
#endif
|
||||
|
||||
memcpy(ssid, evt->ssid, sizeof(evt->ssid));
|
||||
memcpy(password, evt->password, sizeof(evt->password));
|
||||
|
||||
Reference in New Issue
Block a user