Skip to content

Commit

Permalink
Merge branch 'bugfix/dpp_config_memset_v5.2' into 'release/v5.2'
Browse files Browse the repository at this point in the history
Wi-Fi: Fixed some DPP issues (v5.2)

See merge request espressif/esp-idf!27191
  • Loading branch information
jack0c committed Nov 16, 2023
2 parents 89c3beb + 476f83c commit f0869bb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
12 changes: 12 additions & 0 deletions components/wpa_supplicant/esp_supplicant/src/esp_dpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -179,6 +180,7 @@ static int esp_dpp_handle_config_obj(struct dpp_authentication *auth,
{
wifi_config_t *wifi_cfg = &s_dpp_ctx.wifi_cfg;

os_memset(wifi_cfg, 0, sizeof(wifi_config_t));
if (conf->ssid_len) {
os_memcpy(wifi_cfg->sta.ssid, conf->ssid, conf->ssid_len);
}
Expand Down Expand Up @@ -609,13 +611,23 @@ 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;
if (esp_wifi_get_mode(&mode) || ((mode != WIFI_MODE_STA) && (mode != WIFI_MODE_APSTA))) {
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;
Expand Down
10 changes: 9 additions & 1 deletion components/wpa_supplicant/esp_supplicant/src/esp_dpp_i.h
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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 */
11 changes: 10 additions & 1 deletion components/wpa_supplicant/esp_supplicant/src/esp_wps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit f0869bb

Please sign in to comment.