diff --git a/components/audio_stream/test/http_stream_test.c b/components/audio_stream/test/http_stream_test.c index 6712400ff..bf0111382 100644 --- a/components/audio_stream/test/http_stream_test.c +++ b/components/audio_stream/test/http_stream_test.c @@ -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]") { @@ -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://"); @@ -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); @@ -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; } } @@ -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]") @@ -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); @@ -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; } } @@ -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]") @@ -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); @@ -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); @@ -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; @@ -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); @@ -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; } } diff --git a/components/audio_stream/test/tcp_client_stream_test.c b/components/audio_stream/test/tcp_client_stream_test.c index c585424f4..89ed89db6 100644 --- a/components/audio_stream/test/tcp_client_stream_test.c +++ b/components/audio_stream/test/tcp_client_stream_test.c @@ -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]") { @@ -58,8 +58,8 @@ 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"); @@ -67,7 +67,7 @@ TEST_CASE("tcp client stream init memory", "[esp-adf-stream]") 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(); @@ -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)); @@ -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(); @@ -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)); diff --git a/components/esp_peripherals/include/periph_wifi.h b/components/esp_peripherals/include/periph_wifi.h index a0d2c91a6..da4d0242c 100644 --- a/components/esp_peripherals/include/periph_wifi.h +++ b/components/esp_peripherals/include/periph_wifi.h @@ -25,6 +25,7 @@ #ifndef _DEV_WIFI_H_ #define _DEV_WIFI_H_ +#include "esp_wifi_types.h" #include "esp_peripherals.h" #ifdef __cplusplus @@ -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; diff --git a/components/esp_peripherals/periph_wifi.c b/components/esp_peripherals/periph_wifi.c index c41e11202..e414c1069 100644 --- a/components/esp_peripherals/periph_wifi.c +++ b/components/esp_peripherals/periph_wifi.c @@ -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; @@ -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) { @@ -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(); @@ -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); } @@ -310,7 +307,7 @@ 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) { @@ -323,7 +320,7 @@ static void _wifi_event_callback(void *arg, esp_event_base_t event_base, 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) { @@ -356,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; @@ -365,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) { @@ -388,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); } @@ -424,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; @@ -477,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) { @@ -501,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); @@ -519,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); @@ -529,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; diff --git a/components/esp_peripherals/test/esp_peripherals_test.c b/components/esp_peripherals/test/esp_peripherals_test.c index 2dc117be6..83e2d6c97 100644 --- a/components/esp_peripherals/test/esp_peripherals_test.c +++ b/components/esp_peripherals/test/esp_peripherals_test.c @@ -594,10 +594,10 @@ static void periph_wifi_test(void) ESP_ERROR_CHECK( ret ); tcpip_adapter_init(); - periph_wifi_cfg_t wifi_cfg = {0}; - wifi_cfg.ssid = "ESP-Audio"; - wifi_cfg.password = "esp123456"; - + periph_wifi_cfg_t wifi_cfg = { + .wifi_config.sta.ssid = "YOUR_SSID", + .wifi_config.sta.password = "YOUR_PASSWORD", + } esp_periph_handle_t wifi_handle = periph_wifi_init(&wifi_cfg); esp_periph_start(set, wifi_handle); periph_wifi_wait_for_connected(wifi_handle, portMAX_DELAY); diff --git a/components/wifi_service/test/test_wifi_ssid_manager.c b/components/wifi_service/test/test_wifi_ssid_manager.c index 145f5714c..6d22ebf6b 100644 --- a/components/wifi_service/test/test_wifi_ssid_manager.c +++ b/components/wifi_service/test/test_wifi_ssid_manager.c @@ -70,8 +70,8 @@ static esp_periph_set_handle_t wifi_setup(void) tcpip_adapter_init(); periph_wifi_cfg_t wifi_cfg = { - .ssid = "myssid", - .password = "mypassword", + .wifi_config.sta.ssid = "YOUR_SSID", + .wifi_config.sta.password = "YOUR_PASSWORD", }; esp_periph_handle_t wifi_handle = periph_wifi_init(&wifi_cfg); TEST_ASSERT_FALSE(esp_periph_start(set, wifi_handle)); diff --git a/docs/en/design-guide/audio-peripheral.rst b/docs/en/design-guide/audio-peripheral.rst index 364ab59b0..153be9a06 100644 --- a/docs/en/design-guide/audio-peripheral.rst +++ b/docs/en/design-guide/audio-peripheral.rst @@ -10,8 +10,8 @@ Example esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG(); esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); 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); esp_periph_start(set, wifi_handle); diff --git a/examples/advanced_examples/dlna/main/dlna_example.c b/examples/advanced_examples/dlna/main/dlna_example.c index 46b47870b..4a72883ba 100644 --- a/examples/advanced_examples/dlna/main/dlna_example.c +++ b/examples/advanced_examples/dlna/main/dlna_example.c @@ -133,7 +133,7 @@ int renderer_request(esp_dlna_handle_t dlna, const upnp_attr_t *attr, int attr_n return 0; case AVT_SEEK: sscanf(buffer, "%d:%d:%d", &hour, &min, &sec); - tmp_data = hour*3600 + min*60 + sec; + tmp_data = hour * 3600 + min * 60 + sec; ESP_LOGI(TAG, "Seekto %d s", tmp_data); esp_audio_seek(player, tmp_data); return 0; @@ -326,8 +326,8 @@ void app_main() esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG(); esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); periph_wifi_cfg_t wifi_cfg = { - .ssid = "ESP-Audio", - .password = "esp123456", + .wifi_config.sta.ssid = "YOUR_SSID", + .wifi_config.sta.password = "YOUR_PASSWORD", }; esp_periph_handle_t wifi_handle = periph_wifi_init(&wifi_cfg); esp_periph_start(set, wifi_handle); diff --git a/examples/advanced_examples/http_play_and_save_to_file/main/http_play_and_save_to_file.c b/examples/advanced_examples/http_play_and_save_to_file/main/http_play_and_save_to_file.c index 45ae17329..80f80538d 100644 --- a/examples/advanced_examples/http_play_and_save_to_file/main/http_play_and_save_to_file.c +++ b/examples/advanced_examples/http_play_and_save_to_file/main/http_play_and_save_to_file.c @@ -130,8 +130,8 @@ void app_main(void) esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG(); esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); 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); esp_periph_start(set, wifi_handle); diff --git a/examples/advanced_examples/multi-room/main/multi_room.c b/examples/advanced_examples/multi-room/main/multi_room.c index a737d27b1..a41ce4cb4 100644 --- a/examples/advanced_examples/multi-room/main/multi_room.c +++ b/examples/advanced_examples/multi-room/main/multi_room.c @@ -12,6 +12,7 @@ #include "nvs_flash.h" #include "esp_wifi.h" #include "esp_log.h" +#include "string.h" #include "esp_peripherals.h" #include "periph_is31fl3216.h" @@ -48,8 +49,8 @@ static void setup_wifi(esp_periph_set_handle_t set) ESP_LOGI(TAG, "Start Wi-Fi"); periph_wifi_cfg_t wifi_cfg = { .disable_auto_reconnect = true, - .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); esp_periph_start(set, wifi_handle); @@ -240,14 +241,14 @@ static int _mrm_event_handler(mrm_event_msg_t *event, void *ctx) break; case MRM_EVENT_SYNC_FAST: sync = *(int *)event->data; - if (sync < -200){ + if (sync < -200) { sync = -200; } i2s_stream_sync_delay(i2s_h, sync); break; case MRM_EVENT_SYNC_SLOW: sync = *(int *)event->data; - if (sync > 200){ + if (sync > 200) { sync = 200; } i2s_stream_sync_delay(i2s_h, sync); diff --git a/examples/cli/main/console_example.c b/examples/cli/main/console_example.c index d55a6d6b4..6e6d4cc2f 100644 --- a/examples/cli/main/console_example.c +++ b/examples/cli/main/console_example.c @@ -533,8 +533,8 @@ static void cli_setup_wifi() ESP_LOGI(TAG, "Start Wi-Fi"); periph_wifi_cfg_t wifi_cfg = { .disable_auto_reconnect = true, - .ssid = "", - .password = "", + .wifi_config.sta.ssid = "YOUR_SSID", + .wifi_config.sta.password = "YOUR_PASSWORD", }; esp_periph_handle_t wifi_handle = periph_wifi_init(&wifi_cfg); esp_periph_start(set, wifi_handle); @@ -556,7 +556,7 @@ static void cli_setup_player(void) { if (player ) { return ; - } + } esp_audio_cfg_t cfg = DEFAULT_ESP_AUDIO_CONFIG(); audio_board_handle_t board_handle = audio_board_init(); cfg.vol_handle = board_handle->audio_hal; diff --git a/examples/cloud_services/google_translate_device/main/translate_device_example.c b/examples/cloud_services/google_translate_device/main/translate_device_example.c index c0ac6d789..b74ae2a75 100644 --- a/examples/cloud_services/google_translate_device/main/translate_device_example.c +++ b/examples/cloud_services/google_translate_device/main/translate_device_example.c @@ -75,8 +75,8 @@ void translate_task(void *pv) esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); 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); diff --git a/examples/cloud_services/pipeline_aws_polly_mp3/main/play_aws_polly_mp3_example.c b/examples/cloud_services/pipeline_aws_polly_mp3/main/play_aws_polly_mp3_example.c index 2f1cc787f..9827daf08 100644 --- a/examples/cloud_services/pipeline_aws_polly_mp3/main/play_aws_polly_mp3_example.c +++ b/examples/cloud_services/pipeline_aws_polly_mp3/main/play_aws_polly_mp3_example.c @@ -146,8 +146,8 @@ void app_main(void) esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG(); esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); 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); esp_periph_start(set, wifi_handle); diff --git a/examples/cloud_services/pipeline_baidu_speech_mp3/main/play_baidu_speech_mp3_example.c b/examples/cloud_services/pipeline_baidu_speech_mp3/main/play_baidu_speech_mp3_example.c index 449303ea6..1f37eeb64 100644 --- a/examples/cloud_services/pipeline_baidu_speech_mp3/main/play_baidu_speech_mp3_example.c +++ b/examples/cloud_services/pipeline_baidu_speech_mp3/main/play_baidu_speech_mp3_example.c @@ -93,8 +93,8 @@ void app_main(void) esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG(); esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); 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); esp_periph_start(set, wifi_handle); diff --git a/examples/get-started/pipeline_tcp_client/main/tcp_client_example.c b/examples/get-started/pipeline_tcp_client/main/tcp_client_example.c index 02cfd9213..8cad11f1d 100644 --- a/examples/get-started/pipeline_tcp_client/main/tcp_client_example.c +++ b/examples/get-started/pipeline_tcp_client/main/tcp_client_example.c @@ -97,8 +97,8 @@ void app_main(void) esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG(); esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); 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); esp_periph_start(set, wifi_handle); diff --git a/examples/korvo_du1906/components/audio_player/test/audio_player_setup_common.c b/examples/korvo_du1906/components/audio_player/test/audio_player_setup_common.c index d3dda5ba7..ff7680d82 100644 --- a/examples/korvo_du1906/components/audio_player/test/audio_player_setup_common.c +++ b/examples/korvo_du1906/components/audio_player/test/audio_player_setup_common.c @@ -99,8 +99,8 @@ void setup_wifi() } periph_wifi_cfg_t wifi_cfg = { .disable_auto_reconnect = false, - .ssid = "ESP-Audio39", - .password = "esp123456", + .wifi_config.sta.ssid = "YOUR_SSID", + .wifi_config.sta.password = "YOUR_PASSWORD", }; wifi_handle = periph_wifi_init(&wifi_cfg); esp_periph_start(set, wifi_handle); diff --git a/examples/ota/main/ota_example.c b/examples/ota/main/ota_example.c index b30a5cc6b..dc04437b1 100644 --- a/examples/ota/main/ota_example.c +++ b/examples/ota/main/ota_example.c @@ -162,8 +162,8 @@ void app_main() ESP_LOGI(TAG, "[1.1] Start and wait for Wi-Fi network"); 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); esp_periph_start(set, wifi_handle); diff --git a/examples/player/pipeline_bt_source/main/play_bt_source_example.c b/examples/player/pipeline_bt_source/main/play_bt_source_example.c index 43f56b25a..254d541d7 100644 --- a/examples/player/pipeline_bt_source/main/play_bt_source_example.c +++ b/examples/player/pipeline_bt_source/main/play_bt_source_example.c @@ -94,8 +94,8 @@ void app_main(void) esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG(); esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); 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); esp_periph_start(set, wifi_handle); @@ -142,7 +142,7 @@ void app_main(void) /* Stop when the Bluetooth is disconnected or suspended */ if (msg.source_type == PERIPH_ID_BLUETOOTH - && msg.source == (void *)bt_periph) { + && msg.source == (void *)bt_periph) { if ((msg.cmd == PERIPH_BLUETOOTH_DISCONNECTED) || (msg.cmd == PERIPH_BLUETOOTH_AUDIO_SUSPENDED)) { ESP_LOGW(TAG, "[ * ] Bluetooth disconnected or suspended"); periph_bluetooth_stop(bt_periph); diff --git a/examples/player/pipeline_http_mp3/main/play_http_mp3_example.c b/examples/player/pipeline_http_mp3/main/play_http_mp3_example.c index 36ff15166..e359fcf6e 100644 --- a/examples/player/pipeline_http_mp3/main/play_http_mp3_example.c +++ b/examples/player/pipeline_http_mp3/main/play_http_mp3_example.c @@ -94,8 +94,8 @@ void app_main(void) esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG(); esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); 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); esp_periph_start(set, wifi_handle); diff --git a/examples/player/pipeline_http_select_decoder/main/play_http_select_decoder_example.c b/examples/player/pipeline_http_select_decoder/main/play_http_select_decoder_example.c index 2ecf460a6..f10cba502 100644 --- a/examples/player/pipeline_http_select_decoder/main/play_http_select_decoder_example.c +++ b/examples/player/pipeline_http_select_decoder/main/play_http_select_decoder_example.c @@ -156,8 +156,8 @@ void app_main(void) esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG(); esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); 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); esp_periph_start(set, wifi_handle); diff --git a/examples/player/pipeline_living_stream/main/play_living_stream_example.c b/examples/player/pipeline_living_stream/main/play_living_stream_example.c index 5f836367d..700890be9 100644 --- a/examples/player/pipeline_living_stream/main/play_living_stream_example.c +++ b/examples/player/pipeline_living_stream/main/play_living_stream_example.c @@ -117,8 +117,8 @@ void app_main(void) esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG(); esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); 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); esp_periph_start(set, wifi_handle); diff --git a/examples/protocols/esp-rtc/main/main.c b/examples/protocols/esp-rtc/main/main.c index 49f4282e5..6ff0d47e1 100644 --- a/examples/protocols/esp-rtc/main/main.c +++ b/examples/protocols/esp-rtc/main/main.c @@ -7,6 +7,7 @@ CONDITIONS OF ANY KIND, either express or implied. */ +#include "string.h" #include "nvs_flash.h" #include "esp_netif.h" #include "esp_log.h" @@ -21,7 +22,7 @@ #include "audio_tone_uri.h" #include "audio_player_int_tone.h" -#define TAG "ESP_RTC_Demo" +#define TAG "ESP_RTC_Demo" #define WIFI_SSID CONFIG_WIFI_SSID #define WIFI_PWD CONFIG_WIFI_PASSWORD @@ -34,8 +35,8 @@ static void setup_wifi(esp_periph_set_handle_t set) { ESP_ERROR_CHECK(esp_netif_init()); periph_wifi_cfg_t wifi_cfg = { - .ssid = WIFI_SSID, - .password = WIFI_PWD, + .wifi_config.sta.ssid = WIFI_SSID, + .wifi_config.sta.password = WIFI_PWD, }; esp_periph_handle_t wifi_handle = periph_wifi_init(&wifi_cfg); esp_periph_start(set, wifi_handle); @@ -99,8 +100,8 @@ void app_main() esp_log_level_set("AFE_VC", ESP_LOG_ERROR); AUDIO_MEM_SHOW(TAG); - /* nvs init */ - esp_err_t err = nvs_flash_init(); + /* nvs init */ + esp_err_t err = nvs_flash_init(); if (err == ESP_ERR_NVS_NO_FREE_PAGES) { // NVS partition was truncated and needs to be erased // Retry nvs_flash_init @@ -124,9 +125,9 @@ void app_main() input_key_service_add_key(input_ser, input_key_info, INPUT_KEY_NUM); periph_service_set_callback(input_ser, input_key_service_cb, NULL); - #if (DEBUG_AEC_INPUT || DEBUG_AEC_OUTPUT) +#if (DEBUG_AEC_INPUT || DEBUG_AEC_OUTPUT) audio_board_sdcard_init(set, SD_MODE_1_LINE); - #endif +#endif ESP_LOGI(TAG, "[ 2 ] Initialize av stream"); av_stream_config_t av_stream_config = { diff --git a/examples/protocols/esp-rtsp/main/main.c b/examples/protocols/esp-rtsp/main/main.c index 1a0723843..0a544bf6f 100644 --- a/examples/protocols/esp-rtsp/main/main.c +++ b/examples/protocols/esp-rtsp/main/main.c @@ -7,6 +7,7 @@ CONDITIONS OF ANY KIND, either express or implied. */ +#include "string.h" #include "nvs_flash.h" #include "esp_netif.h" #include "esp_log.h" @@ -17,7 +18,7 @@ #include "algorithm_stream.h" #include "rtsp_service.h" -#define TAG "ESP_RTSP_Demo" +#define TAG "ESP_RTSP_Demo" #define WIFI_SSID "myssid" #define WIFI_PWD "mypassword" @@ -35,8 +36,8 @@ static void setup_wifi(esp_periph_set_handle_t set) { ESP_ERROR_CHECK(esp_netif_init()); periph_wifi_cfg_t wifi_cfg = { - .ssid = WIFI_SSID, - .password = WIFI_PWD, + .wifi_config.sta.ssid = WIFI_SSID, + .wifi_config.sta.password = WIFI_PWD, }; esp_periph_handle_t wifi_handle = periph_wifi_init(&wifi_cfg); esp_periph_start(set, wifi_handle); diff --git a/examples/protocols/rtmp/main/main.c b/examples/protocols/rtmp/main/main.c index 01687360b..1fc851717 100644 --- a/examples/protocols/rtmp/main/main.c +++ b/examples/protocols/rtmp/main/main.c @@ -46,7 +46,7 @@ typedef enum { } rtmp_app_type_t; static int app_running = 0; -static char* rtmp_server_url = NULL; +static char *rtmp_server_url = NULL; static esp_periph_set_handle_t set; static esp_periph_handle_t wifi_handle; static bool wifi_connected = false; @@ -56,25 +56,21 @@ static rtmp_app_type_t rtmp_app_type = RTMP_APP_TYPE_PUSHER; static int connect_sta(const char *ssid, const char *psw) { - periph_wifi_cfg_t wifi_cfg = { - .ssid = ssid ? ssid : CONFIG_WIFI_SSID, - .password = psw ? psw : CONFIG_WIFI_PASSWORD, - }; + periph_wifi_cfg_t wifi_cfg = {0}; + memset(&wifi_cfg, 0, sizeof(wifi_cfg)); + strncpy((char *)wifi_cfg.wifi_config.sta.ssid, ssid ? ssid : CONFIG_WIFI_SSID, sizeof(wifi_cfg.wifi_config.sta.ssid) - 1); + strncpy((char *)wifi_cfg.wifi_config.sta.password, psw ? psw : CONFIG_WIFI_PASSWORD, sizeof(wifi_cfg.wifi_config.sta.password) - 1); if (wifi_handle) { esp_wifi_disconnect(); esp_wifi_stop(); - wifi_config_t wifi_config; - memset(&wifi_config, 0x00, sizeof(wifi_config_t)); - strcpy((char *)wifi_config.sta.ssid, wifi_cfg.ssid); - strcpy((char *)wifi_config.sta.password, wifi_cfg.password); - ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_cfg.wifi_config)); ESP_ERROR_CHECK(esp_wifi_start()); } else { wifi_handle = periph_wifi_init(&wifi_cfg); esp_periph_init(wifi_handle); ESP_LOGI(TAG, "Waiting for wifi connected"); } - periph_wifi_wait_for_connected(wifi_handle, 6000/portTICK_PERIOD_MS); + periph_wifi_wait_for_connected(wifi_handle, 6000 / portTICK_PERIOD_MS); if (periph_wifi_is_connected(wifi_handle) == PERIPH_WIFI_CONNECTED) { ESP_LOGI(TAG, "Wifi connected OK"); wifi_connected = true; @@ -107,8 +103,9 @@ static void app_thread(void *arg) media_lib_thread_destroy(NULL); } -static void start_app() { - rtmp_app_type_t app_type = RTMP_APP_TYPE_PUSHER; +static void start_app() +{ + rtmp_app_type_t app_type = RTMP_APP_TYPE_PUSHER; #ifdef CONFIG_RTMP_APP_MODE_PUSHER app_type = RTMP_APP_TYPE_PUSHER; #endif @@ -177,11 +174,11 @@ static int setting_cli(int argc, char **argv) av_record_get_video_size(rtmp_setting_get_video_quality(), &width, &height); ESP_LOGI(TAG, "RTMP server url: %s", SERVER_URL); ESP_LOGI(TAG, "Video setting | format:%s sw_jpeg:%d quality:%dx%d fps:%d", - av_record_get_vfmt_str(rtmp_setting_get_video_fmt()), - rtmp_setting_get_sw_jpeg(), width, height, rtmp_setting_get_video_fps()); - ESP_LOGI(TAG, "Audio setting | format:%s channel:%d sample_rate:%d", - av_record_get_afmt_str(rtmp_setting_get_audio_fmt()), - rtmp_setting_get_audio_channel(), rtmp_setting_get_audio_sample_rate()); + av_record_get_vfmt_str(rtmp_setting_get_video_fmt()), + rtmp_setting_get_sw_jpeg(), width, height, rtmp_setting_get_video_fps()); + ESP_LOGI(TAG, "Audio setting | format:%s channel:%d sample_rate:%d", + av_record_get_afmt_str(rtmp_setting_get_audio_fmt()), + rtmp_setting_get_audio_channel(), rtmp_setting_get_audio_sample_rate()); return 0; } @@ -217,29 +214,29 @@ static int stop_cli(int argc, char **argv) static int assert_cli(int argc, char **argv) { - *(int*) 0 = 0; + *(int *) 0 = 0; return 0; } -static const char* get_mode_str(rtmp_app_type_t app_type) +static const char *get_mode_str(rtmp_app_type_t app_type) { switch ((int)app_type) { case RTMP_APP_TYPE_PUSHER: - return "Pusher"; + return "Pusher"; case RTMP_APP_TYPE_SRC: - return "Src"; + return "Src"; case RTMP_APP_TYPE_SERVER: - return "Server"; - case (RTMP_APP_TYPE_SRC | RTMP_APP_TYPE_PUSHER): - return "Src + Pusher"; + return "Server"; + case (RTMP_APP_TYPE_SRC | RTMP_APP_TYPE_PUSHER): + return "Src + Pusher"; case (RTMP_APP_TYPE_SRC | RTMP_APP_TYPE_SERVER): - return "Src + Server"; + return "Src + Server"; case (RTMP_APP_TYPE_PUSHER | RTMP_APP_TYPE_SERVER): - return "Pusher + Server"; + return "Pusher + Server"; case (RTMP_APP_TYPE_SRC | RTMP_APP_TYPE_PUSHER | RTMP_APP_TYPE_SERVER): - return "Pusher + Server + Src"; + return "Pusher + Server + Src"; default: - return "Undef"; + return "Undef"; } } @@ -247,7 +244,7 @@ static int mode_cli(int argc, char **argv) { if (argc > 1) { rtmp_app_type = (rtmp_app_type_t) atoi(argv[1]); - } + } ESP_LOGI(TAG, "Working in mode: %s", get_mode_str(rtmp_app_type)); return 0; } @@ -292,7 +289,7 @@ static int init_console() .func = start_cli, .help = "Start to run RTMP applications", .command = "start", - }, + }, { .func = stop_cli, .help = "Stop RTMP applications", @@ -314,7 +311,7 @@ static int init_console() .command = "assert", }, }; - for (int i = 0; i < sizeof(console_cmd)/ sizeof(esp_console_cmd_t); i++) { + for (int i = 0; i < sizeof(console_cmd) / sizeof(esp_console_cmd_t); i++) { ESP_ERROR_CHECK(esp_console_cmd_register(&console_cmd[i])); } #if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 1, 0)) diff --git a/examples/recorder/pipeline_raw_http/main/record_raw_http.c b/examples/recorder/pipeline_raw_http/main/record_raw_http.c index c9e8734a7..2999ceea4 100644 --- a/examples/recorder/pipeline_raw_http/main/record_raw_http.c +++ b/examples/recorder/pipeline_raw_http/main/record_raw_http.c @@ -181,8 +181,8 @@ void app_main(void) esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); 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); diff --git a/examples/system/coredump/main/coredump_example.c b/examples/system/coredump/main/coredump_example.c index e1864b4fb..654f570dd 100644 --- a/examples/system/coredump/main/coredump_example.c +++ b/examples/system/coredump/main/coredump_example.c @@ -99,8 +99,8 @@ void app_main() ESP_LOGI(TAG, "[1.1] Start and wait for Wi-Fi network"); 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); esp_periph_start(set, wifi_handle); diff --git a/examples/system/power_save/main/audio_power_save.c b/examples/system/power_save/main/audio_power_save.c index e190f3c1d..38ca7abdb 100644 --- a/examples/system/power_save/main/audio_power_save.c +++ b/examples/system/power_save/main/audio_power_save.c @@ -7,6 +7,7 @@ CONDITIONS OF ANY KIND, either express or implied. */ +#include "string.h" #include "esp_log.h" #include "nvs_flash.h" #include "esp_wifi.h" @@ -194,10 +195,10 @@ void wifi_low_power_test(void) set = esp_periph_set_init(&periph_cfg); ESP_LOGI(TAG, "Start and wait for Wi-Fi network"); periph_wifi_cfg_t wifi_cfg = { - .ssid = CONFIG_EXAMPLE_WIFI_SSID, - .password = CONFIG_EXAMPLE_WIFI_PASSWORD, .disable_auto_reconnect = false, - .reconnect_timeout_ms = 100 + .reconnect_timeout_ms = 100, + .wifi_config.sta.ssid = CONFIG_EXAMPLE_WIFI_SSID, + .wifi_config.sta.password = CONFIG_EXAMPLE_WIFI_PASSWORD, }; wifi_handle = periph_wifi_init(&wifi_cfg); // Please place it between periph_wifi_init() and esp_periph_start() @@ -241,10 +242,10 @@ void app_main(void) ESP_LOGI(TAG, "Init Wi-Fi network"); periph_wifi_cfg_t wifi_cfg = { - .ssid = CONFIG_EXAMPLE_WIFI_SSID, - .password = CONFIG_EXAMPLE_WIFI_PASSWORD, .disable_auto_reconnect = false, - .reconnect_timeout_ms = 100 + .reconnect_timeout_ms = 100, + .wifi_config.sta.ssid = CONFIG_EXAMPLE_WIFI_SSID, + .wifi_config.sta.password = CONFIG_EXAMPLE_WIFI_PASSWORD, }; wifi_handle = periph_wifi_init(&wifi_cfg); // Please place it between periph_wifi_init() and esp_periph_start() diff --git a/examples/system/wpa2_enterprise/main/wpa2_enterprise_example.c b/examples/system/wpa2_enterprise/main/wpa2_enterprise_example.c index e3c2087ec..a95519c3f 100644 --- a/examples/system/wpa2_enterprise/main/wpa2_enterprise_example.c +++ b/examples/system/wpa2_enterprise/main/wpa2_enterprise_example.c @@ -54,8 +54,7 @@ void app_main() esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); ESP_LOGI(TAG, "[ 1 ] Set Wi-Fi config"); - periph_wifi_cfg_t wifi_cfg = {0}; - wifi_cfg.ssid = CONFIG_WIFI_SSID; + periph_wifi_cfg_t wifi_cfg = {.wifi_config.sta.ssid = CONFIG_WIFI_SSID}; wifi_cfg.wpa2_e_cfg.diasble_wpa2_e = true; wifi_cfg.wpa2_e_cfg.eap_method = CONFIG_EAP_METHOD; wifi_cfg.wpa2_e_cfg.ca_pem_start = (char *)ca_pem_start;