From a21312a5a14cc38e529623755db498af871cee16 Mon Sep 17 00:00:00 2001 From: xueyunfei Date: Thu, 23 Mar 2023 15:37:43 +0800 Subject: [PATCH 01/12] Fixed bug for stop dhcps before set dns Closes https://github.com/espressif/esp-idf/issues/10762 --- examples/mesh/ip_internal_network/main/mesh_netif.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/mesh/ip_internal_network/main/mesh_netif.c b/examples/mesh/ip_internal_network/main/mesh_netif.c index 223c1fe576..7a2bd71dad 100644 --- a/examples/mesh/ip_internal_network/main/mesh_netif.c +++ b/examples/mesh/ip_internal_network/main/mesh_netif.c @@ -66,8 +66,10 @@ static esp_err_t set_dhcps_dns(esp_netif_t *netif, uint32_t addr) dns.ip.u_addr.ip4.addr = addr; dns.ip.type = IPADDR_TYPE_V4; dhcps_offer_t dhcps_dns_value = OFFER_DNS; + ESP_ERROR_CHECK_WITHOUT_ABORT(esp_netif_dhcps_stop(netif)); ESP_ERROR_CHECK(esp_netif_dhcps_option(netif, ESP_NETIF_OP_SET, ESP_NETIF_DOMAIN_NAME_SERVER, &dhcps_dns_value, sizeof(dhcps_dns_value))); ESP_ERROR_CHECK(esp_netif_set_dns_info(netif, ESP_NETIF_DNS_MAIN, &dns)); + ESP_ERROR_CHECK_WITHOUT_ABORT(esp_netif_dhcps_start(netif)); return ESP_OK; } From e70f45acd1da5bf041119d628da6c7c3225755b6 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Thu, 6 Apr 2023 18:10:55 +0800 Subject: [PATCH 02/12] Update the ESP-NOW frame length in docs --- docs/en/api-reference/network/esp_now.rst | 2 +- docs/zh_CN/api-reference/network/esp_now.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/api-reference/network/esp_now.rst b/docs/en/api-reference/network/esp_now.rst index a358291065..8539ca16d9 100644 --- a/docs/en/api-reference/network/esp_now.rst +++ b/docs/en/api-reference/network/esp_now.rst @@ -21,7 +21,7 @@ ESP-NOW uses a vendor-specific action frame to transmit ESP-NOW data. The defaul ------------------------------------------------------------------------------------------------------------ | MAC Header | Category Code | Organization Identifier | Random Values | Vendor Specific Content | FCS | ------------------------------------------------------------------------------------------------------------ - 24 bytes 1 byte 3 bytes 4 bytes 7~255 bytes 4 bytes + 24 bytes 1 byte 3 bytes 4 bytes 7~257 bytes 4 bytes - Category Code: The Category Code field is set to the value(127) indicating the vendor-specific category. - Organization Identifier: The Organization Identifier contains a unique identifier (0x18fe34), which is the first three bytes of MAC address applied by Espressif. diff --git a/docs/zh_CN/api-reference/network/esp_now.rst b/docs/zh_CN/api-reference/network/esp_now.rst index 09055519a7..4288062f87 100644 --- a/docs/zh_CN/api-reference/network/esp_now.rst +++ b/docs/zh_CN/api-reference/network/esp_now.rst @@ -21,7 +21,7 @@ ESP-NOW 使用各个供应商的动作帧传输数据,默认比特率为 1 Mbp ----------------------------------------------------------------------------------------- | MAC 报头 | 分类代码 | 组织标识符 | 随机值 | 供应商特定内容 | FCS | ----------------------------------------------------------------------------------------- - 24 字节 1 字节 3 字节 4 字节 7~255 字节 4 字节 + 24 字节 1 字节 3 字节 4 字节 7~257 字节 4 字节 - 分类代码:分类代码字段可用于指示各个供应商的类别(比如 127)。 - 组织标识符:组织标识符包含一个唯一标识符 (比如 0x18fe34),为乐鑫指定的 MAC 地址的前三个字节。 From 273f36829a72446c97b669df37f86f4f0e715aa3 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Fri, 5 May 2023 17:45:37 +0800 Subject: [PATCH 03/12] wpa_supplicant: Fix max sta num error for softAP --- components/wpa_supplicant/esp_supplicant/src/esp_hostap.c | 2 +- components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c b/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c index 1b3a6db832..10bdcb5534 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c @@ -46,7 +46,7 @@ void *hostap_init(void) os_free(hapd); return NULL; } - hapd->conf->max_num_sta = MAX_STA_COUNT; + hapd->conf->max_num_sta = esp_wifi_ap_get_max_sta_conn(); auth_conf = (struct wpa_auth_config *)os_zalloc(sizeof(struct wpa_auth_config)); diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h index e0b2b5de22..8f991e9716 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h @@ -282,5 +282,6 @@ bool esp_wifi_is_ft_enabled_internal(uint8_t if_index); uint8_t esp_wifi_sta_get_config_sae_pwe_h2e_internal(void); uint8_t esp_wifi_sta_get_use_h2e_internal(void); void esp_wifi_sta_disable_wpa2_authmode_internal(void); +uint8_t esp_wifi_ap_get_max_sta_conn(void); #endif /* _ESP_WIFI_DRIVER_H_ */ From 70e3d8f511373527208af5d4c49915ddefa816de Mon Sep 17 00:00:00 2001 From: Shreyas Sheth Date: Thu, 6 Apr 2023 18:43:06 +0530 Subject: [PATCH 04/12] esp_wifi: Install keys after successful transmission of EAPOL 4/4 Message --- .../wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h | 1 + components/wpa_supplicant/src/rsn_supp/wpa.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h index 8f991e9716..892a399727 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h @@ -283,5 +283,6 @@ uint8_t esp_wifi_sta_get_config_sae_pwe_h2e_internal(void); uint8_t esp_wifi_sta_get_use_h2e_internal(void); void esp_wifi_sta_disable_wpa2_authmode_internal(void); uint8_t esp_wifi_ap_get_max_sta_conn(void); +bool esp_wifi_eb_tx_status_success_internal(void *eb); #endif /* _ESP_WIFI_DRIVER_H_ */ diff --git a/components/wpa_supplicant/src/rsn_supp/wpa.c b/components/wpa_supplicant/src/rsn_supp/wpa.c index 4cf7955c62..6235991b70 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa.c +++ b/components/wpa_supplicant/src/rsn_supp/wpa.c @@ -2750,6 +2750,12 @@ void eapol_txcb(void *eb) case WPA_FIRST_HALF_4WAY_HANDSHAKE: break; case WPA_LAST_HALF_4WAY_HANDSHAKE: + + if (esp_wifi_eb_tx_status_success_internal(eb) != true) { + wpa_printf(MSG_ERROR, "Eapol message 4/4 tx failure, not installing keys"); + return; + } + if (sm->txcb_flags & WPA_4_4_HANDSHAKE_BIT) { sm->txcb_flags &= ~WPA_4_4_HANDSHAKE_BIT; isdeauth = wpa_supplicant_send_4_of_4_txcallback(sm); From ded3169aa5395c8f5b6a2e490cc693218f1c4cf0 Mon Sep 17 00:00:00 2001 From: aditi_lonkar Date: Wed, 29 Mar 2023 15:23:02 +0530 Subject: [PATCH 05/12] esp_wifi: Add APIs to get Assoc id and negotiated phymode. --- components/esp_wifi/include/esp_wifi.h | 23 ++++++++++++++++++++ components/esp_wifi/include/esp_wifi_types.h | 13 +++++++++++ 2 files changed, 36 insertions(+) diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index 87736e460d..1517f81d7b 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -1319,6 +1319,29 @@ esp_err_t esp_wifi_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t ra */ esp_err_t esp_wifi_disable_pmf_config(wifi_interface_t ifx); +/** + * @brief Get the Association id assigned to STA by AP + * + * @param[out] aid store the aid + * + * @attention aid = 0 if station is not connected to AP. + * + * @return + * - ESP_OK: succeed + */ +esp_err_t esp_wifi_sta_get_aid(uint16_t *aid); + +/** + * @brief Get the negotiated phymode after connection. + * + * @param[out] phymode store the negotiated phymode. + * + * @attention Operation phy mode, BIT[5]: indicate whether LR enabled, BIT[0-4]: wifi_phy_mode_t + * + * @return + * - ESP_OK: succeed + */ +esp_err_t esp_wifi_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode); #ifdef __cplusplus } #endif diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 9d945aa34b..19aa667a37 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -359,6 +359,19 @@ typedef enum { #define WIFI_VENDOR_IE_ELEMENT_ID 0xDD +/** + * @brief Operation Phymode + */ +typedef enum +{ + WIFI_PHY_MODE_LR, /**< PHY mode for Low Rate */ + WIFI_PHY_MODE_11B, /**< PHY mode for 11b */ + WIFI_PHY_MODE_11G, /**< PHY mode for 11g */ + WIFI_PHY_MODE_HT20, /**< PHY mode for Bandwidth HT20 */ + WIFI_PHY_MODE_HT40, /**< PHY mode for Bandwidth HT40 */ + WIFI_PHY_MODE_HE20, /**< PHY mode for Bandwidth HE20 */ +} wifi_phy_mode_t; + /** * @brief Vendor Information Element header * From b678fa129014066f90f4c3e8dece8eb034c26c92 Mon Sep 17 00:00:00 2001 From: Sarvesh Bodakhe Date: Wed, 19 Apr 2023 12:09:41 +0530 Subject: [PATCH 06/12] esp_wifi: Combine bugfixes for softAP PMF, beacon tx process and add wpa_sta_connected callback 1. Handle SA-Query bug in AP-STA concurrent mode when both connections are PMF enabled 2. Add wpa_sta_connected callback 3. Validate softAP interface when sending beacon frame --- .../esp_supplicant/src/esp_common.c | 88 ++++++++----------- .../esp_supplicant/src/esp_common_i.h | 2 + .../esp_supplicant/src/esp_wifi_driver.h | 1 + .../esp_supplicant/src/esp_wpa_main.c | 8 ++ 4 files changed, 49 insertions(+), 50 deletions(-) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common.c b/components/wpa_supplicant/esp_supplicant/src/esp_common.c index b182d688db..9f46e29f2b 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common.c @@ -206,47 +206,6 @@ static void register_mgmt_frames(struct wpa_supplicant *wpa_s) esp_wifi_register_mgmt_frame_internal(wpa_s->type, wpa_s->subtype); } -static void supplicant_sta_conn_handler(void* arg, esp_event_base_t event_base, - int32_t event_id, void* event_data) -{ - u8 bssid[ETH_ALEN]; - u8 *ie; - struct wpa_supplicant *wpa_s = &g_wpa_supp; - int ret = esp_wifi_get_assoc_bssid_internal(bssid); - if (ret < 0) { - wpa_printf(MSG_ERROR, "Not able to get connected bssid"); - return; - } - struct wpa_bss *bss = wpa_bss_get_bssid(wpa_s, bssid); - if (!bss) { - wpa_printf(MSG_INFO, "connected bss entry not present in scan cache"); - return; - } - wpa_s->current_bss = bss; - ie = (u8 *)bss; - ie += sizeof(struct wpa_bss); - ieee802_11_parse_elems(wpa_s, ie, bss->ie_len); - wpa_bss_flush(wpa_s); - /* Register for mgmt frames */ - register_mgmt_frames(wpa_s); - /* clear set bssid flag */ - clear_bssid_flag(wpa_s); -} - -static void supplicant_sta_disconn_handler(void* arg, esp_event_base_t event_base, - int32_t event_id, void* event_data) -{ - struct wpa_supplicant *wpa_s = &g_wpa_supp; - -#ifdef CONFIG_WPA_11KV_SUPPORT - wpas_rrm_reset(wpa_s); - wpas_clear_beacon_rep_data(wpa_s); -#endif /* CONFIG_WPA_11KV_SUPPORT */ - if (wpa_s->current_bss) { - wpa_s->current_bss = NULL; - } -} - #ifdef CONFIG_IEEE80211R static int handle_auth_frame(u8 *frame, size_t len, u8 *sender, u32 rssi, u8 channel) @@ -383,11 +342,6 @@ int esp_supplicant_common_init(struct wpa_funcs *wpa_cb) #endif /* CONFIG_WPA_11KV_SUPPORT */ esp_scan_init(wpa_s); - esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_CONNECTED, - &supplicant_sta_conn_handler, NULL); - esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, - &supplicant_sta_disconn_handler, NULL); - #endif /* defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) */ wpa_s->type = 0; wpa_s->subtype = 0; @@ -419,10 +373,6 @@ void esp_supplicant_common_deinit(void) wpas_rrm_reset(wpa_s); wpas_clear_beacon_rep_data(wpa_s); #endif /* CONFIG_WPA_11KV_SUPPORT */ - esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_CONNECTED, - &supplicant_sta_conn_handler); - esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, - &supplicant_sta_disconn_handler); #endif /* defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) */ if (wpa_s->type) { wpa_s->type = 0; @@ -444,6 +394,44 @@ void esp_supplicant_common_deinit(void) #endif /* defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) */ } +void supplicant_sta_conn_handler(uint8_t *bssid) +{ +#if defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) + u8 *ie; + struct wpa_supplicant *wpa_s = &g_wpa_supp; + struct wpa_bss *bss = wpa_bss_get_bssid(wpa_s, bssid); + if (!bss) { + wpa_printf(MSG_INFO, "connected bss entry not present in scan cache"); + return; + } + wpa_s->current_bss = bss; + ie = (u8 *)bss; + ie += sizeof(struct wpa_bss); + ieee802_11_parse_elems(wpa_s, ie, bss->ie_len); + wpa_bss_flush(wpa_s); + /* Register for mgmt frames */ + register_mgmt_frames(wpa_s); + /* clear set bssid flag */ + clear_bssid_flag(wpa_s); +#endif /* defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) */ +} + +void supplicant_sta_disconn_handler(void) +{ +#if defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) + struct wpa_supplicant *wpa_s = &g_wpa_supp; + +#ifdef CONFIG_WPA_11KV_SUPPORT + wpas_rrm_reset(wpa_s); + wpas_clear_beacon_rep_data(wpa_s); +#endif /* CONFIG_WPA_11KV_SUPPORT */ + if (wpa_s->current_bss) { + wpa_s->current_bss = NULL; + } +#endif /* defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) */ + +} + #if defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) #ifdef CONFIG_WPA_11KV_SUPPORT bool esp_rrm_is_rrm_supported_connection(void) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h b/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h index 39e954f071..27b98fd81b 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h @@ -44,4 +44,6 @@ int esp_supplicant_common_init(struct wpa_funcs *wpa_cb); void esp_supplicant_common_deinit(void); void esp_set_scan_ie(void); void esp_set_assoc_ie(uint8_t *bssid, const u8 *ies, size_t ies_len, bool add_mdie); +void supplicant_sta_conn_handler(uint8_t* bssid); +void supplicant_sta_disconn_handler(void); #endif diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h index 892a399727..e6999027b8 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h @@ -118,6 +118,7 @@ struct wpa_funcs { bool (*wpa_sta_init)(void); bool (*wpa_sta_deinit)(void); int (*wpa_sta_connect)(uint8_t *bssid); + void (*wpa_sta_connected_cb)(uint8_t *bssid); void (*wpa_sta_disconnected_cb)(uint8_t reason_code); int (*wpa_sta_rx_eapol)(u8 *src_addr, u8 *buf, u32 len); bool (*wpa_sta_in_4way_handshake)(void); diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c index d26c9b8558..c65f7fd998 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c @@ -228,6 +228,11 @@ int wpa_parse_wpa_ie_wrapper(const u8 *wpa_ie, size_t wpa_ie_len, wifi_wpa_ie_t return ret; } +static void wpa_sta_connected_cb(uint8_t *bssid) +{ + supplicant_sta_conn_handler(bssid); +} + static void wpa_sta_disconnected_cb(uint8_t reason_code) { switch (reason_code) { @@ -250,6 +255,8 @@ static void wpa_sta_disconnected_cb(uint8_t reason_code) #ifdef CONFIG_OWE_STA owe_deinit(); #endif /* CONFIG_OWE_STA */ + + supplicant_sta_disconn_handler(); } #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT @@ -326,6 +333,7 @@ int esp_supplicant_init(void) wpa_cb->wpa_sta_deinit = wpa_deattach; wpa_cb->wpa_sta_rx_eapol = wpa_sm_rx_eapol; wpa_cb->wpa_sta_connect = wpa_sta_connect; + wpa_cb->wpa_sta_connected_cb = wpa_sta_connected_cb; wpa_cb->wpa_sta_disconnected_cb = wpa_sta_disconnected_cb; wpa_cb->wpa_sta_in_4way_handshake = wpa_sta_in_4way_handshake; From 0d2271e539d5a1c78e4afdb5053584b4775102bf Mon Sep 17 00:00:00 2001 From: muhaidong Date: Tue, 13 Dec 2022 19:48:30 +0800 Subject: [PATCH 07/12] docs: add some details for wifi scan description --- docs/en/api-guides/wifi.rst | 2 +- docs/zh_CN/api-guides/wifi.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/api-guides/wifi.rst b/docs/en/api-guides/wifi.rst index 2a8bdb360b..9034cb2fbf 100644 --- a/docs/en/api-guides/wifi.rst +++ b/docs/en/api-guides/wifi.rst @@ -1241,7 +1241,7 @@ API :cpp:func:`esp_wifi_set_config()` can be used to configure the station. And * - bssid - This is valid only when bssid_set is 1; see field “bssid_set”. * - channel - - If the channel is 0, the station scans the channel 1 ~ N to search for the target AP; otherwise, the station starts by scanning the channel whose value is the same as that of the “channel” field, and then scans others to find the target AP. If you do not know which channel the target AP is running on, set it to 0. + - If the channel is 0, the station scans the channel 1 ~ N to search for the target AP; otherwise, the station starts by scanning the channel whose value is the same as that of the “channel” field, and then scans the channel 1 ~ N but skip the specific channel to find the target AP. For example, if the channel is 3, the scan order will be 3, 1, 2, 4,..., N. If you do not know which channel the target AP is running on, set it to 0. * - sort_method - This field is only for WIFI_ALL_CHANNEL_SCAN. diff --git a/docs/zh_CN/api-guides/wifi.rst b/docs/zh_CN/api-guides/wifi.rst index bbd09b064f..a4f777b06e 100644 --- a/docs/zh_CN/api-guides/wifi.rst +++ b/docs/zh_CN/api-guides/wifi.rst @@ -1242,7 +1242,7 @@ API :cpp:func:`esp_wifi_set_config()` 可用于配置 station。配置的参数 * - bssid - 只有当 bssid_set 为 1 时有效。见字段 “bssid_set”。 * - channel - - 该字段为 0 时,station 扫描信道 1 ~ N 寻找目标 AP;否则,station 首先扫描值与 “channel” 字段相同的信道,再扫描其他信道。如果您不知道目标 AP 在哪个信道,请将该字段设置为 0。 + - 该字段为 0 时,station 扫描信道 1 ~ N 寻找目标 AP;否则,station 首先扫描值与 “channel” 字段相同的信道,再扫描其他信道。比如,当该字段设置为 3 时,扫描顺序为 3,1,2,...,N 。如果您不知道目标 AP 在哪个信道,请将该字段设置为 0。 * - sort_method - 该字段仅用于 WIFI_ALL_CHANNEL_SCAN 模式。 From 811e5e06d29155e46a22b4656ec29bc00bd97998 Mon Sep 17 00:00:00 2001 From: muhaidong Date: Tue, 10 Jan 2023 20:55:31 +0800 Subject: [PATCH 08/12] docs: update ftm docs --- docs/en/api-guides/wifi.rst | 2 +- docs/zh_CN/api-guides/wifi.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/api-guides/wifi.rst b/docs/en/api-guides/wifi.rst index 9034cb2fbf..a55ca10619 100644 --- a/docs/en/api-guides/wifi.rst +++ b/docs/en/api-guides/wifi.rst @@ -1620,7 +1620,7 @@ Current implementation of 802.11k includes support for beacon measurement report Refer ESP-IDF example :idf_file:`examples/wifi/roaming/README.md` to set up and use these APIs. Example code only demonstrates how these APIs can be used, and the application should define its own algorithm and cases as required. -.. only:: esp32s2 or esp32c3 +.. only:: SOC_WIFI_FTM_SUPPORT Wi-Fi Location ------------------------------- diff --git a/docs/zh_CN/api-guides/wifi.rst b/docs/zh_CN/api-guides/wifi.rst index a4f777b06e..b33349f969 100644 --- a/docs/zh_CN/api-guides/wifi.rst +++ b/docs/zh_CN/api-guides/wifi.rst @@ -1620,7 +1620,7 @@ WPA2-Enterprise 是企业无线网络的安全认证机制。在连接到接入 请参考 IDF 示例程序 :idf_file:`examples/wifi/roaming/README.md` 来设置和使用这些 API。示例代码只演示了如何使用这些 API,应用程序应根据需要定义自己的算法和案例。 -.. only:: esp32s2 or esp32c3 +.. only:: SOC_WIFI_FTM_SUPPORT Wi-Fi Location ------------------------------- From 25b40c9d5e711d6ee2b57170d3d2db9d8355c5d1 Mon Sep 17 00:00:00 2001 From: muhaidong Date: Fri, 31 Mar 2023 11:39:50 +0800 Subject: [PATCH 09/12] esp_wifi: fix some wifi bugs 1.pm: mesh sleep support phy ref 2.pm: send wake null after scan if txq isn't idle 3.fix esp32 wifi schm interrupted by ble act 4.fix the bug that ble scan start impacts wifi in some coex scenarios 5.fix softAP qos null issue 6.fix the tx data error when change phymode from LR to 11N 7.fix the heap corrupt issue in MTXON task 8.add new api for supplicant to get softAP's max connection 9.owe: reject pmf incapable ciphers for owe connections 10.fix nvs store softap pmk not match ssid&password 11.install keys after successful transmission of eapol 4/4 message 12.add apis to get assoc id and negotiated phymode 13.softAP pmf: handle SA Query bug in AP-STA concurrent mode when both connections are pmf enabled 14.softAP pmf: merge softAP and station SA Query handlers 15.add wpa_sta_connected callback 16.softAP: validate softAP interface when sending beacon 17.ftm: send ftm frames immediately 18.fix ftm procedure with peer failed status 4 issue 19.fix set inactive time crash issue --- components/esp_wifi/include/esp_wifi.h | 1 + components/esp_wifi/lib | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index 1517f81d7b..6f8bb5999e 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -1146,6 +1146,7 @@ esp_err_t esp_wifi_set_inactive_time(wifi_interface_t ifx, uint16_t sec); * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init + * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start * - ESP_ERR_WIFI_ARG: invalid argument */ esp_err_t esp_wifi_get_inactive_time(wifi_interface_t ifx, uint16_t *sec); diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 3f0144cd0f..7792e2ba52 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 3f0144cd0f58073751f76c45f923b382440c58d0 +Subproject commit 7792e2ba528e1c744df5a54ecf45cbb03fc426ed From 5caf842f7235242b7bc47f6b1440dcc0161365ed Mon Sep 17 00:00:00 2001 From: muhaidong Date: Wed, 19 Apr 2023 19:57:27 +0800 Subject: [PATCH 10/12] esp_supplicant: wpa pmf should be disabled --- .../wpa_supplicant/esp_supplicant/src/esp_hostap.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c b/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c index 10bdcb5534..157357056a 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c @@ -32,7 +32,7 @@ void *hostap_init(void) struct wpa_auth_config *auth_conf; u16 spp_attrubute = 0; u8 pairwise_cipher; - wifi_pmf_config_t pmf_cfg; + wifi_pmf_config_t pmf_cfg = {0}; hapd = (struct hostapd_data *)os_zalloc(sizeof(struct hostapd_data)); @@ -69,11 +69,12 @@ void *hostap_init(void) pairwise_cipher = esp_wifi_ap_get_prof_pairwise_cipher_internal(); #ifdef CONFIG_IEEE80211W - - esp_wifi_get_pmf_config_internal(&pmf_cfg, WIFI_IF_AP); - - if (pmf_cfg.required) { - pairwise_cipher = WIFI_CIPHER_TYPE_CCMP; + if((auth_conf->wpa & WPA_PROTO_RSN) == WPA_PROTO_RSN) + { + esp_wifi_get_pmf_config_internal(&pmf_cfg, WIFI_IF_AP); + if (pmf_cfg.required) { + pairwise_cipher = WIFI_CIPHER_TYPE_CCMP; + } } #endif /* CONFIG_IEEE80211W */ From 153f34cf748775759bc871d3def80e73fa0c2347 Mon Sep 17 00:00:00 2001 From: muhaidong Date: Wed, 26 Apr 2023 21:38:34 +0800 Subject: [PATCH 11/12] esp_supplicant: When the softAP authentication mode is set to WPA2_PSK, WPA2_WPA3_PSK, or WPA3_PSK, the pairwise cipher will be overwritten with WIFI_CIPHER_TYPE_CCMP --- components/esp_wifi/include/esp_wifi_types.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 19aa667a37..929b335490 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -259,12 +259,12 @@ typedef struct { uint8_t ssid[32]; /**< SSID of ESP32 soft-AP. If ssid_len field is 0, this must be a Null terminated string. Otherwise, length is set according to ssid_len. */ uint8_t password[64]; /**< Password of ESP32 soft-AP. */ uint8_t ssid_len; /**< Optional length of SSID field. */ - uint8_t channel; /**< Channel of ESP32 soft-AP */ - wifi_auth_mode_t authmode; /**< Auth mode of ESP32 soft-AP. Do not support AUTH_WEP in soft-AP mode */ + uint8_t channel; /**< Channel of soft-AP */ + wifi_auth_mode_t authmode; /**< Auth mode of soft-AP. Do not support AUTH_WEP, AUTH_WAPI_PSK and AUTH_OWE in soft-AP mode. When the auth mode is set to WPA2_PSK, WPA2_WPA3_PSK or WPA3_PSK, the pairwise cipher will be overwritten with WIFI_CIPHER_TYPE_CCMP. */ uint8_t ssid_hidden; /**< Broadcast SSID or not, default 0, broadcast the SSID */ uint8_t max_connection; /**< Max number of stations allowed to connect in */ uint16_t beacon_interval; /**< Beacon interval which should be multiples of 100. Unit: TU(time unit, 1 TU = 1024 us). Range: 100 ~ 60000. Default value: 100 */ - wifi_cipher_type_t pairwise_cipher; /**< pairwise cipher of SoftAP, group cipher will be derived using this. cipher values are valid starting from WIFI_CIPHER_TYPE_TKIP, enum values before that will be considered as invalid and default cipher suites(TKIP+CCMP) will be used. Valid cipher suites in softAP mode are WIFI_CIPHER_TYPE_TKIP, WIFI_CIPHER_TYPE_CCMP and WIFI_CIPHER_TYPE_TKIP_CCMP. */ + wifi_cipher_type_t pairwise_cipher; /**< Pairwise cipher of SoftAP, group cipher will be derived using this. Cipher values are valid starting from WIFI_CIPHER_TYPE_TKIP, enum values before that will be considered as invalid and default cipher suites(TKIP+CCMP) will be used. Valid cipher suites in softAP mode are WIFI_CIPHER_TYPE_TKIP, WIFI_CIPHER_TYPE_CCMP and WIFI_CIPHER_TYPE_TKIP_CCMP. */ bool ftm_responder; /**< Enable FTM Responder mode */ wifi_pmf_config_t pmf_cfg; /**< Configuration for Protected Management Frame */ } wifi_ap_config_t; From 0f09901e300d8f68f2a5e0a997426e39b8ec9a7b Mon Sep 17 00:00:00 2001 From: muhaidong Date: Tue, 13 Jun 2023 11:54:41 +0800 Subject: [PATCH 12/12] esp_wifi: fix some wifi bugs 1. mesh: layer2 node will scan all channels when root leave in fixed root network 2. show warning infomation when setting softAP's max connection number 3. update pairwise cipher in softAP 4. overwrite pairwise cipher when softAP auth mode is WPA2 WPA2_WPA3 WAP3 5. fix sta receive csa issue --- components/esp_wifi/include/esp_wifi_types.h | 4 ++-- components/esp_wifi/lib | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 929b335490..eb32abb895 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -260,11 +260,11 @@ typedef struct { uint8_t password[64]; /**< Password of ESP32 soft-AP. */ uint8_t ssid_len; /**< Optional length of SSID field. */ uint8_t channel; /**< Channel of soft-AP */ - wifi_auth_mode_t authmode; /**< Auth mode of soft-AP. Do not support AUTH_WEP, AUTH_WAPI_PSK and AUTH_OWE in soft-AP mode. When the auth mode is set to WPA2_PSK, WPA2_WPA3_PSK or WPA3_PSK, the pairwise cipher will be overwritten with WIFI_CIPHER_TYPE_CCMP. */ + wifi_auth_mode_t authmode; /**< Auth mode of soft-AP. Do not support AUTH_WEP, AUTH_WAPI_PSK and AUTH_OWE in soft-AP mode. When the auth mode is set to WPA2_PSK, WPA2_WPA3_PSK or WPA3_PSK, the pairwise cipher will be overwritten with WIFI_CIPHER_TYPE_CCMP. */ uint8_t ssid_hidden; /**< Broadcast SSID or not, default 0, broadcast the SSID */ uint8_t max_connection; /**< Max number of stations allowed to connect in */ uint16_t beacon_interval; /**< Beacon interval which should be multiples of 100. Unit: TU(time unit, 1 TU = 1024 us). Range: 100 ~ 60000. Default value: 100 */ - wifi_cipher_type_t pairwise_cipher; /**< Pairwise cipher of SoftAP, group cipher will be derived using this. Cipher values are valid starting from WIFI_CIPHER_TYPE_TKIP, enum values before that will be considered as invalid and default cipher suites(TKIP+CCMP) will be used. Valid cipher suites in softAP mode are WIFI_CIPHER_TYPE_TKIP, WIFI_CIPHER_TYPE_CCMP and WIFI_CIPHER_TYPE_TKIP_CCMP. */ + wifi_cipher_type_t pairwise_cipher; /**< Pairwise cipher of SoftAP, group cipher will be derived using this. Cipher values are valid starting from WIFI_CIPHER_TYPE_TKIP, enum values before that will be considered as invalid and default cipher suites(TKIP+CCMP) will be used. Valid cipher suites in softAP mode are WIFI_CIPHER_TYPE_TKIP, WIFI_CIPHER_TYPE_CCMP and WIFI_CIPHER_TYPE_TKIP_CCMP. */ bool ftm_responder; /**< Enable FTM Responder mode */ wifi_pmf_config_t pmf_cfg; /**< Configuration for Protected Management Frame */ } wifi_ap_config_t; diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 7792e2ba52..1aa30ac2b9 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 7792e2ba528e1c744df5a54ecf45cbb03fc426ed +Subproject commit 1aa30ac2b972d84956f30d03197e93f87d9c8950