mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-29 18:27:20 +02:00
fix(wifi): Resolved WPS connectivity issue with pre-connected stations
This fixes the issue where station was not able connect using WPS if it was already in connected state. wifi_wps_scan_done() issues an esp_wifi_disconnect() before calling esp_wifi_connect() to associate with the newly discovered AP. This behavior incorrectly triggered a failure event (WIFI_EVENT_STA_WPS_ER_FAILED) even though the disconnection was part of the normal WPS flow. This commit prevents sending the false failure event, ensuring expected WPS behavior.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -877,9 +877,11 @@ int wps_finish(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* This will get executed in the wifi task's context */
|
||||
static void wps_sm_notify_deauth(void)
|
||||
{
|
||||
if (gWpsSm && gWpsSm->wps->state != WPS_FINISHED) {
|
||||
if (gWpsSm && gWpsSm->wps->state != WPS_FINISHED &&
|
||||
!gWpsSm->intermediate_disconnect) {
|
||||
wps_stop_process(WPS_FAIL_REASON_RECV_DEAUTH);
|
||||
}
|
||||
}
|
||||
@ -1644,7 +1646,9 @@ wifi_wps_scan_done(void *arg, ETS_STATUS status)
|
||||
sm->discover_ssid_cnt = 0;
|
||||
|
||||
if (wps_get_status() == WPS_STATUS_PENDING) {
|
||||
sm->intermediate_disconnect = true;
|
||||
esp_wifi_disconnect();
|
||||
sm->intermediate_disconnect = false;
|
||||
|
||||
os_memcpy(wifi_config.sta.bssid, sm->bssid, ETH_ALEN);
|
||||
os_memcpy(wifi_config.sta.ssid, (char *)sm->creds[0].ssid, sm->creds[0].ssid_len);
|
||||
|
@ -84,6 +84,7 @@ struct wps_sm {
|
||||
bool wps_pbc_overlap;
|
||||
struct discard_ap_list_t dis_ap_list[WPS_MAX_DIS_AP_NUM];
|
||||
u8 discard_ap_cnt;
|
||||
bool intermediate_disconnect;
|
||||
};
|
||||
|
||||
#define API_MUTEX_TAKE() do {\
|
||||
|
Reference in New Issue
Block a user