Skip to content

Commit

Permalink
Merge branch 'feature/improvement_periph_wifi' into 'master'
Browse files Browse the repository at this point in the history
Improvment periph_wifi (breaking change) [PR#1044]

See merge request adf/esp-adf-internal!1247
  • Loading branch information
jason-mao committed Dec 1, 2023
2 parents 74663b6 + 0fcea07 commit 81bf025
Show file tree
Hide file tree
Showing 28 changed files with 157 additions and 168 deletions.
44 changes: 22 additions & 22 deletions components/audio_stream/test/http_stream_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ static const char URL_RANDOM[] = "0123456789abcdefghijklmnopqrstuvwxyuzABCDEFGHI
#define AAC_STREAM_URI "http://open.ls.qingting.fm/live/274/64k.m3u8?format=aac"
#define UNITEST_HTTP_SERVRE_URI "http://192.168.199.168:8000/upload"

#define UNITETS_HTTP_STREAM_WIFI_SSID "ESPRESSIF"
#define UNITETS_HTTP_STREAM_WIFI_PASSWD "espressif"
#define UNITETS_HTTP_STREAM_WIFI_SSID "ESPRESSIF"
#define UNITETS_HTTP_STREAM_WIFI_PASSWD "espressif"

TEST_CASE("http stream init memory", "[esp-adf-stream]")
{
Expand Down Expand Up @@ -88,7 +88,7 @@ TEST_CASE("http stream url test", "[esp-adf-stream]")
http_cfg.enable_playlist_parser = true;
http_stream_reader = http_stream_init(&http_cfg);

srand((unsigned int)time((time_t*)NULL));
srand((unsigned int)time((time_t *)NULL));
for (int cnt = 0; cnt < 100; cnt++) {
memset(url, 0x00, sizeof("http://"));
strcpy(url, "http://");
Expand Down Expand Up @@ -190,8 +190,8 @@ TEST_CASE("http stream read", "[esp-adf-stream]")
TEST_ASSERT_EQUAL(ESP_OK, audio_board_sdcard_init(set, SD_MODE_1_LINE));

periph_wifi_cfg_t wifi_cfg = {
.ssid = UNITETS_HTTP_STREAM_WIFI_SSID,
.password = UNITETS_HTTP_STREAM_WIFI_SSID,
.wifi_config.sta.ssid = UNITETS_HTTP_STREAM_WIFI_SSID,
.wifi_config.sta.password = UNITETS_HTTP_STREAM_WIFI_PASSWD,
};
esp_periph_handle_t wifi_handle = periph_wifi_init(&wifi_cfg);
TEST_ASSERT_NOT_NULL(wifi_handle);
Expand Down Expand Up @@ -240,9 +240,9 @@ TEST_CASE("http stream read", "[esp-adf-stream]")
continue;
}

if (msg.source_type == AUDIO_ELEMENT_TYPE_ELEMENT && msg.source == (void *) http_stream_reader
if (msg.source_type == AUDIO_ELEMENT_TYPE_ELEMENT && msg.source == (void *) http_stream_reader
&& msg.cmd == AEL_MSG_CMD_REPORT_STATUS && (int) msg.data == AEL_STATUS_ERROR_OPEN) {
break;
break;
continue;
}
}
Expand All @@ -259,7 +259,7 @@ TEST_CASE("http stream read", "[esp-adf-stream]")
TEST_ASSERT_EQUAL(ESP_OK, esp_periph_set_destroy(set));
}

/*
/*
* Note : Before run this unitest, please run the http_server_read.py, and Confirm server ip in UNITEST_HTTP_SERVRE_URI
*/
TEST_CASE("http stream write", "[esp-adf-stream]")
Expand All @@ -283,8 +283,8 @@ TEST_CASE("http stream write", "[esp-adf-stream]")
TEST_ASSERT_EQUAL(ESP_OK, audio_board_sdcard_init(set, SD_MODE_1_LINE));

periph_wifi_cfg_t wifi_cfg = {
.ssid = UNITETS_HTTP_STREAM_WIFI_SSID,
.password = UNITETS_HTTP_STREAM_WIFI_PASSWD,
.wifi_config.sta.ssid = UNITETS_HTTP_STREAM_WIFI_SSID,
.wifi_config.sta.password = UNITETS_HTTP_STREAM_WIFI_PASSWD,
};
esp_periph_handle_t wifi_handle = periph_wifi_init(&wifi_cfg);
TEST_ASSERT_NOT_NULL(wifi_handle);
Expand Down Expand Up @@ -334,9 +334,9 @@ TEST_CASE("http stream write", "[esp-adf-stream]")
continue;
}

if (msg.source_type == AUDIO_ELEMENT_TYPE_ELEMENT && msg.source == (void *) http_stream_writer
if (msg.source_type == AUDIO_ELEMENT_TYPE_ELEMENT && msg.source == (void *) http_stream_writer
&& msg.cmd == AEL_MSG_CMD_REPORT_STATUS && (int) msg.data == AEL_STATUS_ERROR_OPEN) {
break;
break;
continue;
}
}
Expand All @@ -351,7 +351,7 @@ TEST_CASE("http stream write", "[esp-adf-stream]")
TEST_ASSERT_EQUAL(ESP_OK, audio_element_deinit(http_stream_writer));
TEST_ASSERT_EQUAL(ESP_OK, audio_element_deinit(fatfs_stream_reader));

TEST_ASSERT_EQUAL(ESP_OK,esp_periph_set_destroy(set));
TEST_ASSERT_EQUAL(ESP_OK, esp_periph_set_destroy(set));
}

TEST_CASE("http stream living test", "[esp-adf-stream]")
Expand All @@ -370,7 +370,7 @@ TEST_CASE("http stream living test", "[esp-adf-stream]")

audio_board_handle_t board_handle = audio_board_init();
TEST_ASSERT_NOT_NULL(board_handle);
TEST_ASSERT_EQUAL(ESP_OK,audio_hal_ctrl_codec(board_handle->audio_hal, AUDIO_HAL_CODEC_MODE_DECODE, AUDIO_HAL_CTRL_START));
TEST_ASSERT_EQUAL(ESP_OK, audio_hal_ctrl_codec(board_handle->audio_hal, AUDIO_HAL_CODEC_MODE_DECODE, AUDIO_HAL_CTRL_START));

audio_pipeline_cfg_t pipeline_cfg = DEFAULT_AUDIO_PIPELINE_CONFIG();
pipeline = audio_pipeline_init(&pipeline_cfg);
Expand Down Expand Up @@ -403,8 +403,8 @@ TEST_CASE("http stream living test", "[esp-adf-stream]")
esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg);
TEST_ASSERT_NOT_NULL(set);
periph_wifi_cfg_t wifi_cfg = {
.ssid = UNITETS_HTTP_STREAM_WIFI_SSID,
.password = UNITETS_HTTP_STREAM_WIFI_PASSWD,
.wifi_config.sta.ssid = UNITETS_HTTP_STREAM_WIFI_SSID,
.wifi_config.sta.password = UNITETS_HTTP_STREAM_WIFI_PASSWD,
};
esp_periph_handle_t wifi_handle = periph_wifi_init(&wifi_cfg);
TEST_ASSERT_NOT_NULL(wifi_handle);
Expand Down Expand Up @@ -476,8 +476,8 @@ TEST_CASE("http stream living test", "[esp-adf-stream]")
TEST_CASE("https stream test", "[esp-adf-stream]")
{

extern const char howsmyssl_com_root_cert_pem_start[] asm("_binary_howsmyssl_com_root_cert_pem_start");
extern const char howsmyssl_com_root_cert_pem_end[] asm("_binary_howsmyssl_com_root_cert_pem_end");
extern const char howsmyssl_com_root_cert_pem_start[] asm("_binary_howsmyssl_com_root_cert_pem_start");
extern const char howsmyssl_com_root_cert_pem_end[] asm("_binary_howsmyssl_com_root_cert_pem_end");

audio_pipeline_handle_t pipeline;
audio_element_handle_t http_stream_reader, fatfs_stream_writer;
Expand All @@ -498,8 +498,8 @@ extern const char howsmyssl_com_root_cert_pem_end[] asm("_binary_howsmyssl_com
TEST_ASSERT_EQUAL(ESP_OK, audio_board_sdcard_init(set, SD_MODE_1_LINE));

periph_wifi_cfg_t wifi_cfg = {
.ssid = UNITETS_HTTP_STREAM_WIFI_SSID,
.password = UNITETS_HTTP_STREAM_WIFI_SSID,
.wifi_config.sta.ssid = UNITETS_HTTP_STREAM_WIFI_SSID,
.wifi_config.sta.password = UNITETS_HTTP_STREAM_WIFI_PASSWD,
};
esp_periph_handle_t wifi_handle = periph_wifi_init(&wifi_cfg);
TEST_ASSERT_NOT_NULL(wifi_handle);
Expand Down Expand Up @@ -549,9 +549,9 @@ extern const char howsmyssl_com_root_cert_pem_end[] asm("_binary_howsmyssl_com
continue;
}

if (msg.source_type == AUDIO_ELEMENT_TYPE_ELEMENT && msg.source == (void *) http_stream_reader
if (msg.source_type == AUDIO_ELEMENT_TYPE_ELEMENT && msg.source == (void *) http_stream_reader
&& msg.cmd == AEL_MSG_CMD_REPORT_STATUS && (int) msg.data == AEL_STATUS_ERROR_OPEN) {
break;
break;
continue;
}
}
Expand Down
18 changes: 9 additions & 9 deletions components/audio_stream/test/tcp_client_stream_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#define CONFIG_TCP_URL "192.168.199.118"
#define CONFIG_TCP_PORT 8080

static const char *TAG = "TCP_CLIENT_STREAM_TEST"
static const char *TAG = "TCP_CLIENT_STREAM_TEST";

TEST_CASE("tcp client stream init memory", "[esp-adf-stream]")
{
Expand All @@ -58,16 +58,16 @@ TEST_CASE("tcp client stream init memory", "[esp-adf-stream]")
int cnt = 2000;
AUDIO_MEM_SHOW("BEFORE TCP_CLIENT_STREAM_INIT MEMORY TEST");
while (cnt--) {
tcp_stream_writer = tcp_stream_init(&tcp_cfg);
TEST_ASSERT_NOT_NULL(tcp_stream_writer);
tcp_stream_writer = tcp_stream_init(&tcp_cfg);
TEST_ASSERT_NOT_NULL(tcp_stream_writer);
TEST_ASSERT_EQUAL(ESP_OK, audio_element_deinit(tcp_stream_writer));
}
AUDIO_MEM_SHOW("AFTER TCP_CLIENT_STREAM_INIT MEMORY TEST");
}

TEST_CASE("tcp client stream write", "[esp-adf-stream]")
{
esp_err_t err = nvs_flash_init();
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES) {
ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init();
Expand Down Expand Up @@ -108,8 +108,8 @@ TEST_CASE("tcp client stream write", "[esp-adf-stream]")
TEST_ASSERT_EQUAL(ESP_OK, audio_element_set_uri(fatfs_stream_reader, "/sdcard/test.mp3"));

periph_wifi_cfg_t wifi_cfg = {
.ssid = CONFIG_WIFI_SSID,
.password = CONFIG_WIFI_PASSWORD,
.wifi_config.sta.ssid = CONFIG_WIFI_SSID,
.wifi_config.sta.password = CONFIG_WIFI_PASSWORD,
};
esp_periph_handle_t wifi_handle = periph_wifi_init(&wifi_cfg);
TEST_ASSERT_EQUAL(ESP_OK, esp_periph_start(set, wifi_handle));
Expand Down Expand Up @@ -155,7 +155,7 @@ TEST_CASE("tcp client stream write", "[esp-adf-stream]")

TEST_CASE("tcp client stream read", "[esp-adf-stream]")
{
esp_err_t err = nvs_flash_init();
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES) {
ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init();
Expand Down Expand Up @@ -196,8 +196,8 @@ TEST_CASE("tcp client stream read", "[esp-adf-stream]")
TEST_ASSERT_EQUAL(ESP_OK, audio_element_set_uri(fatfs_stream_reader, "/sdcard/test.mp3"));

periph_wifi_cfg_t wifi_cfg = {
.ssid = CONFIG_WIFI_SSID,
.password = CONFIG_WIFI_PASSWORD,
.wifi_config.sta.ssid = CONFIG_WIFI_SSID,
.wifi_config.sta.password = CONFIG_WIFI_PASSWORD,
};
esp_periph_handle_t wifi_handle = periph_wifi_init(&wifi_cfg);
TEST_ASSERT_EQUAL(ESP_OK, esp_periph_start(set, wifi_handle));
Expand Down
4 changes: 2 additions & 2 deletions components/esp_peripherals/include/periph_wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#ifndef _DEV_WIFI_H_
#define _DEV_WIFI_H_

#include "esp_wifi_types.h"
#include "esp_peripherals.h"

#ifdef __cplusplus
Expand Down Expand Up @@ -80,8 +81,7 @@ typedef struct {
typedef struct {
bool disable_auto_reconnect; /*!< Disable Wi-Fi auto reconnect */
int reconnect_timeout_ms; /*!< The reconnect timeout after disconnected from Wi-Fi network */
const char *ssid; /*!< SSID of target AP */
const char *password; /*!< password of target AP */
wifi_config_t wifi_config; /*!< Wifi configure */
periph_wpa2_enterprise_cfg_t wpa2_e_cfg; /*!< wpa2 enterprise config */
} periph_wifi_cfg_t;

Expand Down
69 changes: 29 additions & 40 deletions components/esp_peripherals/periph_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ struct periph_wifi {
bool disable_auto_reconnect;
bool is_open;
uint8_t max_recon_time;
char *ssid;
char *password;
wifi_config_t wifi_config;
EventGroupHandle_t state_event;
int reconnect_timeout_ms;
periph_wifi_config_mode_t config_mode;
Expand All @@ -77,7 +76,6 @@ static const int SMARTCONFIG_DONE_BIT = BIT2;
static const int SMARTCONFIG_ERROR_BIT = BIT3;

static esp_periph_handle_t g_periph = NULL;
static wifi_config_t wifi_config;

esp_err_t periph_wifi_wait_for_connected(esp_periph_handle_t periph, TickType_t tick_to_wait)
{
Expand Down Expand Up @@ -120,14 +118,13 @@ static void _wifi_smartconfig_event_callback(void *arg, esp_event_base_t event_b
case SC_EVENT_GOT_SSID_PSWD:
ESP_LOGE(TAG, "SC_EVENT_GOT_SSID_PSWD");
smartconfig_event_got_ssid_pswd_t *evt = (smartconfig_event_got_ssid_pswd_t *)event_data;
memset(&sta_conf, 0x00, sizeof(sta_conf));
memcpy(sta_conf.sta.ssid, evt->ssid, sizeof(sta_conf.sta.ssid));
memcpy(sta_conf.sta.password, evt->password, sizeof(sta_conf.sta.password));
sta_conf.sta.bssid_set = evt->bssid_set;
if (sta_conf.sta.bssid_set == true) {
memcpy(sta_conf.sta.bssid, evt->bssid, sizeof(sta_conf.sta.bssid));
memcpy(periph_wifi->wifi_config.sta.ssid, evt->ssid, sizeof(periph_wifi->wifi_config.sta.ssid));
memcpy(periph_wifi->wifi_config.sta.password, evt->password, sizeof(periph_wifi->wifi_config.sta.password));
periph_wifi->wifi_config.sta.bssid_set = evt->bssid_set;
if (periph_wifi->wifi_config.sta.bssid_set == true) {
memcpy(periph_wifi->wifi_config.sta.bssid, evt->bssid, sizeof(periph_wifi->wifi_config.sta.bssid));
}
ESP_LOGE(TAG, "SSID=%s, PASS=%s", sta_conf.sta.ssid, sta_conf.sta.password);
ESP_LOGE(TAG, "SSID=%s, PASS=%s", periph_wifi->wifi_config.sta.ssid, periph_wifi->wifi_config.sta.password);

esp_wifi_disconnect();

Expand Down Expand Up @@ -175,12 +172,12 @@ static void _wifi_smartconfig_event_callback(smartconfig_status_t status, void *

case SC_STATUS_LINK:
ESP_LOGE(TAG, "SC_STATUS_LINK");
memset(&sta_conf, 0x00, sizeof(sta_conf));
memcpy(&sta_conf.sta, pdata, sizeof(wifi_sta_config_t));
ESP_LOGE(TAG, "SSID=%s, PASS=%s", sta_conf.sta.ssid, sta_conf.sta.password);
memset(&periph_wifi->wifi_config, 0x00, sizeof(periph_wifi->wifi_config));
memcpy(&periph_wifi->wifi_config.sta, pdata, sizeof(wifi_sta_config_t));
ESP_LOGE(TAG, "SSID=%s, PASS=%s", periph_wifi->wifi_config.sta.ssid, periph_wifi->wifi_config.sta.password);
esp_wifi_disconnect();

if (esp_wifi_set_config(WIFI_IF_STA, &sta_conf) != ESP_OK) {
if (esp_wifi_set_config(WIFI_IF_STA, &periph_wifi->wifi_config) != ESP_OK) {
periph_wifi->wifi_state = PERIPH_WIFI_CONFIG_ERROR;
xEventGroupSetBits(periph_wifi->state_event, SMARTCONFIG_ERROR_BIT);
}
Expand Down Expand Up @@ -310,15 +307,20 @@ static void _wifi_event_callback(void *arg, esp_event_base_t event_base,
wifi_config_t w_config;
memset(&w_config, 0x00, sizeof(wifi_config_t));
esp_wifi_get_config(WIFI_IF_STA, &w_config);
strcpy(periph_wifi->ssid, (char *)w_config.sta.ssid);
memcpy(&periph_wifi->wifi_config.sta.ssid, (char *)w_config.sta.ssid, sizeof(periph_wifi->wifi_config.sta.ssid));
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
wifi_event_sta_disconnected_t *event = (wifi_event_sta_disconnected_t *) event_data;
if (event->reason == WIFI_REASON_ROAMING) {
ESP_LOGI(TAG, "Wi-Fi Station Roaming");
return;
}
periph_wifi->wifi_state = PERIPH_WIFI_DISCONNECTED;
xEventGroupClearBits(periph_wifi->state_event, CONNECTED_BIT);
xEventGroupSetBits(periph_wifi->state_event, DISCONNECTED_BIT);
esp_periph_send_event(self, PERIPH_WIFI_DISCONNECTED, NULL, 0);

ESP_LOGW(TAG, "Wi-Fi disconnected from SSID %s, auto-reconnect %s, reconnect after %d ms",
periph_wifi->ssid,
periph_wifi->wifi_config.sta.ssid,
periph_wifi->disable_auto_reconnect == 0 ? "enabled" : "disabled",
periph_wifi->reconnect_timeout_ms);
if (periph_wifi->disable_auto_reconnect) {
Expand Down Expand Up @@ -351,7 +353,7 @@ static esp_err_t _wifi_event_callback(void *ctx, system_event_t *event)
wifi_config_t w_config;
memset(&w_config, 0x00, sizeof(wifi_config_t));
esp_wifi_get_config(WIFI_IF_STA, &w_config);
strcpy(periph_wifi->ssid, (char *)w_config.sta.ssid);
memcpy(&periph_wifi->wifi_config.sta.ssid, (char *)w_config.sta.ssid, sizeof(periph_wifi->wifi_config.sta.ssid));
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
periph_wifi->wifi_state = PERIPH_WIFI_DISCONNECTED;
Expand All @@ -360,7 +362,7 @@ static esp_err_t _wifi_event_callback(void *ctx, system_event_t *event)
esp_periph_send_event(self, PERIPH_WIFI_DISCONNECTED, NULL, 0);

ESP_LOGW(TAG, "Wi-Fi disconnected from SSID %s, auto-reconnect %s, reconnect after %d ms",
periph_wifi->ssid,
periph_wifi->wifi_config.sta.ssid,
periph_wifi->disable_auto_reconnect == 0 ? "enabled" : "disabled",
periph_wifi->reconnect_timeout_ms);
if (periph_wifi->disable_auto_reconnect) {
Expand All @@ -383,8 +385,9 @@ static esp_err_t _wifi_run(esp_periph_handle_t self, audio_event_iface_msg_t *ms

esp_err_t esp_wifi_set_listen_interval(esp_periph_handle_t periph, int interval)
{
if (wifi_config.sta.listen_interval != interval) {
wifi_config.sta.listen_interval = interval;
periph_wifi_handle_t periph_wifi = (periph_wifi_handle_t)esp_periph_get_data(periph);
if (periph_wifi->wifi_config.sta.listen_interval != interval) {
periph_wifi->wifi_config.sta.listen_interval = interval;
} else {
ESP_LOGW(TAG, "Wifi listen interval %d is already set", interval);
}
Expand Down Expand Up @@ -419,19 +422,11 @@ static esp_err_t _wifi_init(esp_periph_handle_t self)

wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &periph_wifi->wifi_config));
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_MIN_MODEM));

if (periph_wifi->ssid) {
strcpy((char *)wifi_config.sta.ssid, periph_wifi->ssid);
ESP_LOGD(TAG, "WIFI_SSID=%s", wifi_config.sta.ssid);
if (periph_wifi->password) {
strcpy((char *)wifi_config.sta.password, periph_wifi->password);
ESP_LOGD(TAG, "WIFI_PASS=%s", wifi_config.sta.password);
}
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_MIN_MODEM));
}
if (periph_wifi->wpa2_e_cfg->diasble_wpa2_e) {
unsigned int ca_pem_bytes = periph_wifi->wpa2_e_cfg->ca_pem_end - periph_wifi->wpa2_e_cfg->ca_pem_start;
unsigned int client_crt_bytes = periph_wifi->wpa2_e_cfg->wpa2_e_cert_end - periph_wifi->wpa2_e_cfg->wpa2_e_cert_start;
Expand Down Expand Up @@ -472,8 +467,6 @@ static esp_err_t _wifi_destroy(esp_periph_handle_t self)
periph_wifi_wait_for_disconnected(self, portMAX_DELAY);
esp_wifi_stop();
esp_wifi_deinit();
audio_free(periph_wifi->ssid);
audio_free(periph_wifi->password);

vEventGroupDelete(periph_wifi->state_event);
if (periph_wifi->wpa2_e_cfg != NULL) {
Expand All @@ -496,9 +489,7 @@ esp_periph_handle_t periph_wifi_init(periph_wifi_cfg_t *config)
periph_wifi_handle_t periph_wifi = NULL;
bool _success = ((periph = esp_periph_create(PERIPH_ID_WIFI, "periph_wifi"))
&& (periph_wifi = audio_calloc(1, sizeof(struct periph_wifi)))
&& (periph_wifi->state_event = xEventGroupCreate())
&& (config->ssid ? (bool)(periph_wifi->ssid = audio_strdup(config->ssid)) : true)
&& (config->password ? (bool)(periph_wifi->password = audio_strdup(config->password)) : true));
&& (periph_wifi->state_event = xEventGroupCreate()));

AUDIO_MEM_CHECK(TAG, _success, goto _periph_wifi_init_failed);

Expand All @@ -514,7 +505,7 @@ esp_periph_handle_t periph_wifi_init(periph_wifi_cfg_t *config)
goto _periph_wifi_init_failed;
});
memcpy(periph_wifi->wpa2_e_cfg, &config->wpa2_e_cfg, sizeof(periph_wpa2_enterprise_cfg_t));
memset(&wifi_config, 0x00, sizeof(wifi_config_t));
memcpy(&periph_wifi->wifi_config, &config->wifi_config, sizeof(wifi_config_t));

esp_periph_set_data(periph, periph_wifi);
esp_periph_set_function(periph, _wifi_init, _wifi_run, _wifi_destroy);
Expand All @@ -524,8 +515,6 @@ esp_periph_handle_t periph_wifi_init(periph_wifi_cfg_t *config)
_periph_wifi_init_failed:
if (periph_wifi) {
vEventGroupDelete(periph_wifi->state_event);
audio_free(periph_wifi->ssid);
audio_free(periph_wifi->password);
audio_free(periph_wifi);
}
return NULL;
Expand Down
Loading

0 comments on commit 81bf025

Please sign in to comment.