diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c b/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c index 57adbd5a98..63a819a1ff 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c @@ -14,6 +14,7 @@ #include "esp_event.h" #include "esp_wifi.h" #include "common/ieee802_11_defs.h" +#include "esp_wps_i.h" #ifdef CONFIG_DPP static void *s_dpp_task_hdl = NULL; @@ -610,6 +611,11 @@ void esp_supp_dpp_stop_listen(void) esp_wifi_remain_on_channel(WIFI_IF_STA, WIFI_ROC_CANCEL, 0, 0, NULL); } +bool is_dpp_enabled(void) +{ + return (s_dpp_ctx.dpp_global ? true : false); +} + esp_err_t esp_supp_dpp_init(esp_supp_dpp_event_cb_t cb) { wifi_mode_t mode = 0; @@ -617,6 +623,11 @@ esp_err_t esp_supp_dpp_init(esp_supp_dpp_event_cb_t cb) wpa_printf(MSG_ERROR, "DPP: failed to init as not in station mode."); return ESP_FAIL; } + + if (is_wps_enabled()) { + wpa_printf(MSG_ERROR, "DPP: failed to init since WPS is enabled"); + return ESP_FAIL; + } if (s_dpp_ctx.dpp_global) { wpa_printf(MSG_ERROR, "DPP: failed to init as init already done."); return ESP_FAIL; diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_dpp_i.h b/components/wpa_supplicant/esp_supplicant/src/esp_dpp_i.h index 3646d1866c..2e97d1aa39 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_dpp_i.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_dpp_i.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -55,4 +55,12 @@ struct esp_dpp_context_t { int esp_supp_rx_action(uint8_t *hdr, uint8_t *payload, size_t len, uint8_t channel); +#ifdef CONFIG_ESP_WIFI_DPP_SUPPORT +bool is_dpp_enabled(void); +#else +static inline bool is_dpp_enabled(void) +{ + return false; +} +#endif #endif /* ESP_DPP_I_H */ diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wps.c b/components/wpa_supplicant/esp_supplicant/src/esp_wps.c index de43583afa..19bcb7440f 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wps.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wps.c @@ -26,6 +26,7 @@ #include "esp_err.h" #include "esp_private/wifi.h" #include "esp_wps_i.h" +#include "esp_dpp_i.h" #include "esp_wps.h" #include "eap_common/eap_wsc_common.h" #include "esp_wpas_glue.h" @@ -1863,6 +1864,11 @@ int esp_wifi_wps_enable(const esp_wps_config_t *config) #endif } +bool is_wps_enabled(void) +{ + return s_wps_enabled; +} + int wifi_wps_enable_internal(const esp_wps_config_t *config) { int ret = 0; @@ -1873,7 +1879,10 @@ int wifi_wps_enable_internal(const esp_wps_config_t *config) wpa_printf(MSG_ERROR, "wps enable: invalid wps type"); return ESP_ERR_WIFI_WPS_TYPE; } - + if (is_dpp_enabled()) { + wpa_printf(MSG_ERROR, "wps enabled failed since DPP is initialized"); + return ESP_FAIL; + } wpa_printf(MSG_DEBUG, "Set factory information."); ret = wps_set_factory_info(config); if (ret != 0) { diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h b/components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h index 5dd055ad4d..8b0f87cc48 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h @@ -125,5 +125,7 @@ static inline int wps_set_status(uint32_t status) { return esp_wifi_set_wps_status_internal(status); } + +bool is_wps_enabled(void); int wps_init_cfg_pin(struct wps_config *cfg); void wifi_station_wps_eapol_start_handle(void *data, void *user_ctx);