From 9d98cd8f8d8221f46dcfa2bb4cbf9251abe22a61 Mon Sep 17 00:00:00 2001 From: Kapil Gupta Date: Mon, 18 Jul 2022 14:55:34 +0530 Subject: [PATCH] WiFi: Do not disconnect in WPS disable incase WPS is done/scanning Closes https://github.com/espressif/esp-idf/issues/9341 --- components/wpa_supplicant/esp_supplicant/src/esp_wps.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wps.c b/components/wpa_supplicant/esp_supplicant/src/esp_wps.c index c3f2b77dcf..d70717ac41 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wps.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wps.c @@ -1877,6 +1877,7 @@ int wifi_wps_disable_internal(void) int esp_wifi_wps_disable(void) { int ret = 0; + int wps_status; if (ESP_OK != wps_check_wifi_mode()) { return ESP_ERR_WIFI_MODE; @@ -1890,7 +1891,8 @@ int esp_wifi_wps_disable(void) return ESP_OK; } - wpa_printf(MSG_INFO, "wifi_wps_disable\n"); + wps_status = wps_get_status(); + wpa_printf(MSG_INFO, "wifi_wps_disable"); wps_set_type(WPS_TYPE_DISABLE); /* Notify WiFi task */ /* Call wps_delete_timer to delete all WPS timer, no timer will call wps_post() @@ -1908,7 +1910,10 @@ int esp_wifi_wps_disable(void) wpa_printf(MSG_ERROR, "wps disable: failed to disable wps, ret=%d", ret); } - esp_wifi_disconnect(); + /* Only disconnect in case of WPS pending */ + if (wps_status == WPS_STATUS_PENDING) { + esp_wifi_disconnect(); + } esp_wifi_set_wps_start_flag_internal(false); wps_task_deinit(); s_wps_enabled = false;