diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 7a43b39b07..f23b1bd333 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 7a43b39b07837604d52d187dfe46b00cf209e8ea +Subproject commit f23b1bd33376a50d675af6f606e36815f585c543 diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common.c b/components/wpa_supplicant/esp_supplicant/src/esp_common.c index 322f5000ed..f02d465eda 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common.c @@ -34,7 +34,7 @@ esp_err_t esp_supplicant_str_to_mac(const char *str, uint8_t dest[6]) } struct wpa_supplicant g_wpa_supp; -#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) || defined(CONFIG_SAE_PK) +#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) #ifdef CONFIG_SUPPLICANT_TASK static void *s_supplicant_task_hdl = NULL; @@ -216,47 +216,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_IEEE80211KV - wpas_rrm_reset(wpa_s); - wpas_clear_beacon_rep_data(wpa_s); -#endif /* CONFIG_IEEE80211KV */ - 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) @@ -288,7 +247,7 @@ static int handle_assoc_frame(u8 *frame, size_t len, return 0; } #endif /* CONFIG_IEEE80211R */ -#endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) || defined(CONFIG_SAE_PK)*/ +#endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ static int ieee80211_handle_rx_frm(u8 type, u8 *frame, size_t len, u8 *sender, u32 rssi, u8 channel, u64 current_tsf) @@ -393,11 +352,6 @@ int esp_supplicant_common_init(struct wpa_funcs *wpa_cb) #endif /* CONFIG_IEEE80211KV */ 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_IEEE80211KV) || defined(CONFIG_IEEE80211R) || defined(CONFIG_SAE_PK)*/ wpa_s->type = 0; wpa_s->subtype = 0; @@ -429,10 +383,6 @@ void esp_supplicant_common_deinit(void) wpas_rrm_reset(wpa_s); wpas_clear_beacon_rep_data(wpa_s); #endif /* CONFIG_IEEE80211KV */ - 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_IEEE80211KV) || defined(CONFIG_IEEE80211R) || defined(CONFIG_SAE_PK)*/ if (wpa_s->type) { wpa_s->type = 0; @@ -454,6 +404,43 @@ void esp_supplicant_common_deinit(void) #endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ } +void supplicant_sta_conn_handler(uint8_t *bssid) +{ +#if defined(CONFIG_IEEE80211KV) || 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_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ +} + +void supplicant_sta_disconn_handler(void) +{ +#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) + struct wpa_supplicant *wpa_s = &g_wpa_supp; + +#ifdef CONFIG_IEEE80211KV + wpas_rrm_reset(wpa_s); + wpas_clear_beacon_rep_data(wpa_s); +#endif /* CONFIG_IEEE80211KV */ + if (wpa_s->current_bss) { + wpa_s->current_bss = NULL; + } +#endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ +} + #if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) #ifdef CONFIG_IEEE80211KV 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 3262bbc240..c738dba671 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 573526669a..31c7ee72b5 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 403738d25e..43d7f9c1ae 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;