diff --git a/components/wpa_supplicant/src/esp_supplicant/esp_dpp.c b/components/wpa_supplicant/src/esp_supplicant/esp_dpp.c index 223030fea9..3f2710bfc7 100644 --- a/components/wpa_supplicant/src/esp_supplicant/esp_dpp.c +++ b/components/wpa_supplicant/src/esp_supplicant/esp_dpp.c @@ -4,13 +4,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "esp_dpp_i.h" #include "esp_dpp.h" #include "esp_wpa.h" #include "esp_timer.h" #include "esp_event.h" #include "esp_wifi.h" #include "common/ieee802_11_defs.h" +#include "esp_dpp_i.h" #ifdef CONFIG_DPP static TaskHandle_t s_dpp_task_hdl = NULL; @@ -32,6 +32,7 @@ struct action_rx_param { u32 vendor_data_len; struct ieee80211_action *action_frm; }; +extern bool is_wps_enabled(void); static int esp_dpp_post_evt(uint32_t evt_id, uint32_t data) { @@ -631,6 +632,13 @@ void esp_supp_dpp_stop_listen(void) esp_wifi_remain_on_channel(ESP_IF_WIFI_STA, WIFI_ROC_CANCEL, 0, 0, NULL); } +#ifdef CONFIG_WPA_DPP_SUPPORT +bool is_dpp_enabled(void) +{ + return (s_dpp_ctx.dpp_global ? true : false); +} +#endif + esp_err_t esp_supp_dpp_init(esp_supp_dpp_event_cb_t cb) { wifi_mode_t mode = 0; @@ -638,6 +646,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/src/esp_supplicant/esp_dpp_i.h b/components/wpa_supplicant/src/esp_supplicant/esp_dpp_i.h index 3c7aea750a..91517d4caf 100644 --- a/components/wpa_supplicant/src/esp_supplicant/esp_dpp_i.h +++ b/components/wpa_supplicant/src/esp_supplicant/esp_dpp_i.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef ESP_DPP_I_H #define ESP_DPP_I_H @@ -65,4 +57,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_WPA_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/src/esp_supplicant/esp_wps.c b/components/wpa_supplicant/src/esp_supplicant/esp_wps.c index 58a0b11415..ca68518247 100644 --- a/components/wpa_supplicant/src/esp_supplicant/esp_wps.c +++ b/components/wpa_supplicant/src/esp_supplicant/esp_wps.c @@ -14,6 +14,7 @@ #include "common/ieee802_11_defs.h" #include "crypto/dh_group5.h" #include "wps/wps_i.h" +#include "esp_dpp_i.h" #include "wps/wps_dev_attr.h" #include "eap_peer/eap_defs.h" #include "eap_peer/eap_common.h" @@ -2134,6 +2135,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; @@ -2150,6 +2156,10 @@ int wifi_wps_enable_internal(const esp_wps_config_t *config) 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) {