diff --git a/components/lwip/port/debug/lwip_debug.c b/components/lwip/port/debug/lwip_debug.c index dca5b504cf..06b4b36358 100644 --- a/components/lwip/port/debug/lwip_debug.c +++ b/components/lwip/port/debug/lwip_debug.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -82,7 +82,7 @@ static void dbg_lwip_tcp_pcb_one_show(struct tcp_pcb* pcb) ESP_LWIP_LOGI("local_port=%d, remote_port=%d", pcb->local_port, pcb->remote_port); ESP_LWIP_LOGI("flags=%x", pcb->flags); ESP_LWIP_LOGI("pooltmr=%d pollinterval=%d, last_tmr=%d tmr=%" PRIu32 " rtmer=%d", pcb->polltmr, pcb->pollinterval, pcb->last_timer, pcb->tmr, pcb->rtime); - ESP_LWIP_LOGI("recv_nxt=%" PRIu32 " recv_wnd=%d recv_ann_wnd=%d recv_ann_right_edge=%" PRIu32, pcb->rcv_nxt, pcb->rcv_wnd, pcb->rcv_ann_wnd, pcb->rcv_ann_right_edge); + ESP_LWIP_LOGI("recv_nxt=%" PRIu32 " recv_wnd=%"TCPWNDSIZE_F" recv_ann_wnd=%"TCPWNDSIZE_F" recv_ann_right_edge=%" PRIu32, pcb->rcv_nxt, pcb->rcv_wnd, pcb->rcv_ann_wnd, pcb->rcv_ann_right_edge); ESP_LWIP_LOGI("mss=%d", pcb->mss); ESP_LWIP_LOGI("rttest=%" PRIu32 " rtseq=%" PRIu32 " sa=%d sv=%d", pcb->rttest, pcb->rtseq, pcb->sa, pcb->sv); ESP_LWIP_LOGI("rto=%d nrtx=%d", pcb->rto, pcb->nrtx); @@ -90,11 +90,11 @@ static void dbg_lwip_tcp_pcb_one_show(struct tcp_pcb* pcb) #if ESP_PER_SOC_TCP_WND ESP_LWIP_LOGI("per_soc_window=%d per_soc_snd_buf=%d", pcb->per_soc_tcp_wnd, pcb->per_soc_tcp_snd_buf); #endif - ESP_LWIP_LOGI("cwnd=%d ssthreash=%d", pcb->cwnd, pcb->ssthresh); + ESP_LWIP_LOGI("cwnd=%"TCPWNDSIZE_F" ssthreash=%"TCPWNDSIZE_F, pcb->cwnd, pcb->ssthresh); ESP_LWIP_LOGI("snd_next=%" PRIu32 " snd_wl1=%" PRIu32 " snd_wl2=%" PRIu32, pcb->snd_nxt, pcb->snd_wl1, pcb->snd_wl2); - ESP_LWIP_LOGI("snd_lbb=%" PRIu32 " snd_wnd=%d snd_wnd_max=%d", pcb->snd_lbb, pcb->snd_wnd, pcb->snd_wnd_max); + ESP_LWIP_LOGI("snd_lbb=%" PRIu32 " snd_wnd=%"TCPWNDSIZE_F" snd_wnd_max=%"TCPWNDSIZE_F, pcb->snd_lbb, pcb->snd_wnd, pcb->snd_wnd_max); //ESP_LWIP_LOGI("acked=%d", pcb->acked); - ESP_LWIP_LOGI("snd_buf=%d snd_queuelen=%d", pcb->snd_buf, pcb->snd_queuelen); + ESP_LWIP_LOGI("snd_buf=%"TCPWNDSIZE_F" snd_queuelen=%d", pcb->snd_buf, pcb->snd_queuelen); ESP_LWIP_LOGI("unsent_oversize=%d", pcb->unsent_oversize); ESP_LWIP_LOGI("keep_idle=%" PRIu32 " keep_intvl=%" PRIu32 " keep_cnt=%" PRIu32, pcb->keep_idle, pcb->keep_intvl, pcb->keep_cnt); ESP_LWIP_LOGI("persist_cnt=%d persist_backoff=%d", pcb->persist_cnt, pcb->persist_backoff); diff --git a/components/wifi_provisioning/src/manager.c b/components/wifi_provisioning/src/manager.c index 69ed01e0fc..d2d440f152 100644 --- a/components/wifi_provisioning/src/manager.c +++ b/components/wifi_provisioning/src/manager.c @@ -802,6 +802,7 @@ static esp_err_t update_wifi_scan_results(void) prov_ctx->ap_list[curr_channel] = (wifi_ap_record_t *) calloc(get_count, sizeof(wifi_ap_record_t)); if (!prov_ctx->ap_list[curr_channel]) { ESP_LOGE(TAG, "Failed to allocate memory for AP list"); + esp_wifi_clear_ap_list(); goto exit; } if (esp_wifi_scan_get_ap_records(&get_count, prov_ctx->ap_list[curr_channel]) != ESP_OK) { diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_scan.c b/components/wpa_supplicant/esp_supplicant/src/esp_scan.c index d0f5edcef6..b0192bb94b 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_scan.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_scan.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -66,13 +66,10 @@ static void handle_wnm_scan_done(struct wpa_supplicant *wpa_s) static void scan_done_cleanup(struct wpa_supplicant *wpa_s) { - uint16_t number = 1; - wifi_ap_record_t ap_records; - wpa_s->scanning = 0; wpa_s->scan_reason = 0; /* clean scan list from net80211 */ - esp_wifi_scan_get_ap_records(&number, &ap_records); + esp_wifi_clear_ap_list(); } void esp_supplicant_handle_scan_done_evt(void) diff --git a/examples/bluetooth/blufi/main/blufi_example_main.c b/examples/bluetooth/blufi/main/blufi_example_main.c index 2db4cb2bf4..301a9ea72b 100644 --- a/examples/bluetooth/blufi/main/blufi_example_main.c +++ b/examples/bluetooth/blufi/main/blufi_example_main.c @@ -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)); diff --git a/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/cmd_wifi.c b/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/cmd_wifi.c index da77ae8656..42da684a3a 100644 --- a/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/cmd_wifi.c +++ b/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/cmd_wifi.c @@ -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; } diff --git a/examples/wifi/ftm/main/ftm_main.c b/examples/wifi/ftm/main/ftm_main.c index 89fcfb544f..bc8e27fada 100644 --- a/examples/wifi/ftm/main/ftm_main.c +++ b/examples/wifi/ftm/main/ftm_main.c @@ -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; } diff --git a/examples/wifi/iperf/main/cmd_wifi.c b/examples/wifi/iperf/main/cmd_wifi.c index c5c110b677..9b78ba96e4 100644 --- a/examples/wifi/iperf/main/cmd_wifi.c +++ b/examples/wifi/iperf/main/cmd_wifi.c @@ -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; } diff --git a/examples/wifi/roaming/main/roaming_example.c b/examples/wifi/roaming/main/roaming_example.c index 41150ed86e..367114d52b 100644 --- a/examples/wifi/roaming/main/roaming_example.c +++ b/examples/wifi/roaming/main/roaming_example.c @@ -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 */ diff --git a/examples/wifi/smart_config/main/Kconfig.projbuild b/examples/wifi/smart_config/main/Kconfig.projbuild new file mode 100644 index 0000000000..6cc47b939a --- /dev/null +++ b/examples/wifi/smart_config/main/Kconfig.projbuild @@ -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 diff --git a/examples/wifi/smart_config/main/smartconfig_main.c b/examples/wifi/smart_config/main/smartconfig_main.c index 930127a7f4..7b35f432bf 100644 --- a/examples/wifi/smart_config/main/smartconfig_main.c +++ b/examples/wifi/smart_config/main/smartconfig_main.c @@ -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));