From 9a87631f80961fc44c747b84c4504b1c7ccec356 Mon Sep 17 00:00:00 2001 From: Gao Wei Date: Wed, 8 Nov 2023 16:46:57 +0800 Subject: [PATCH] wifi_service: Ignore the 0x3007 status that has been handled internally by wifi --- components/wifi_service/src/wifi_service.c | 8 +++++--- .../advanced_examples/wifi_bt_ble_coex/README.md | 13 +++++++++++++ .../advanced_examples/wifi_bt_ble_coex/README_CN.md | 13 +++++++++++++ .../main/wifi_bt_ble_coex_example.c | 2 +- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/components/wifi_service/src/wifi_service.c b/components/wifi_service/src/wifi_service.c index ddaa7458..c50debba 100644 --- a/components/wifi_service/src/wifi_service.c +++ b/components/wifi_service/src/wifi_service.c @@ -183,6 +183,7 @@ static esp_err_t wifi_event_cb(void *ctx, system_event_t *event) ESP_LOGI(TAG, "SoftAP stopped"); break; case SYSTEM_EVENT_STA_START: + ESP_LOGI(TAG, "Wifi connecting"); esp_wifi_connect(); break; case SYSTEM_EVENT_STA_GOT_IP: @@ -418,9 +419,11 @@ static void wifi_task(void *pvParameters) memcpy(&wifi_cfg, &serv->info, sizeof(wifi_config_t)); } } - ESP_LOGI(TAG, "Connect to wifi ssid: %s, pwd: %s", wifi_cfg.sta.ssid, wifi_cfg.sta.password); configure_wifi_sta_mode(&wifi_cfg); - ESP_ERROR_CHECK(esp_wifi_connect()); + esp_wifi_disconnect(); + esp_err_t ret = esp_wifi_connect(); + AUDIO_CHECK(TAG, (ret == ESP_OK) || (ret == ESP_ERR_WIFI_CONN), abort(), "esp_wifi_connect failed."); + ESP_LOGI(TAG, "Connect to wifi ssid: %s, pwd: %s", wifi_cfg.sta.ssid, wifi_cfg.sta.password); } else if (wifi_msg.type == WIFI_SERV_CMD_DISCONNECT) { serv->reason = WIFI_SERV_STA_BY_USER; ESP_LOGI(TAG, "WIFI_SERV_CMD_DISCONNECT"); @@ -686,4 +689,3 @@ periph_service_handle_t wifi_service_create(wifi_service_config_t *config) return wifi; } - diff --git a/examples/advanced_examples/wifi_bt_ble_coex/README.md b/examples/advanced_examples/wifi_bt_ble_coex/README.md index eb63cf40..2178fb6c 100755 --- a/examples/advanced_examples/wifi_bt_ble_coex/README.md +++ b/examples/advanced_examples/wifi_bt_ble_coex/README.md @@ -10,6 +10,8 @@ This example creates several GATT services and starts ADV with the name of `BLUF The Classic Bluetooth part of this example implements the A2DP SINK. After the program is launched, Bluetooth devices such as smart phones can find the device named `ESP_ADF_COEX_EXAMPLE` and connect to it. Then, you can use the AVRCP configuration file to control the Bluetooth music status. +In this routine, press [Mode] to switch HTTP or A2DP audio; long press [Set] to enter network configuration mode. + ## Environment Setup @@ -193,6 +195,17 @@ I (26066) COEX_EXAMPLE: User cb A2DP event: 1 ``` +- In this example, you can long press [Set] to enter the network configuration mode to update the Wi-Fi information. + +```c +I (249738) COEX_EXAMPLE: [ * ] input key id is 2, key type is 1 +I (251838) COEX_EXAMPLE: [ * ] input key id is 2, key type is 3 +I (251838) COEX_EXAMPLE: [ * ] [Set] Setting Wi-Fi +W (251838) WIFI_SERV: STATE type:3, pdata:0x0, len:0 +I (251838) COEX_EXAMPLE: WIFI_DISCONNECTED +I (252588) COEX_EXAMPLE: [ * ] input key id is 2, key type is 4 +``` + ### Example Log A complete log is as follows: diff --git a/examples/advanced_examples/wifi_bt_ble_coex/README_CN.md b/examples/advanced_examples/wifi_bt_ble_coex/README_CN.md index be0459b0..b9a8b256 100644 --- a/examples/advanced_examples/wifi_bt_ble_coex/README_CN.md +++ b/examples/advanced_examples/wifi_bt_ble_coex/README_CN.md @@ -10,6 +10,8 @@ 本例程的经典蓝牙部分实现了 A2DP SINK 部分。程序启动后,智能手机等蓝牙设备可以发现名为 `ESP_ADF_COEX_EXAMPLE` 的设备,建立连接后,使用 AVRCP 配置文件控制蓝牙音乐状态。 +本例程按 [Mode] 键切换 HTTP 或 A2DP 音频; 长按 [Set] 键进入配网模式。 + ## 环境配置 @@ -193,6 +195,17 @@ I (26066) COEX_EXAMPLE: User cb A2DP event: 1 ``` +- 本例中,可以长按 [Set] 进入配网模式以更新 Wi-Fi 信息。 + +```c +I (249738) COEX_EXAMPLE: [ * ] input key id is 2, key type is 1 +I (251838) COEX_EXAMPLE: [ * ] input key id is 2, key type is 3 +I (251838) COEX_EXAMPLE: [ * ] [Set] Setting Wi-Fi +W (251838) WIFI_SERV: STATE type:3, pdata:0x0, len:0 +I (251838) COEX_EXAMPLE: WIFI_DISCONNECTED +I (252588) COEX_EXAMPLE: [ * ] input key id is 2, key type is 4 +``` + ### 日志输出 以下为本例程的完整日志。 diff --git a/examples/advanced_examples/wifi_bt_ble_coex/main/wifi_bt_ble_coex_example.c b/examples/advanced_examples/wifi_bt_ble_coex/main/wifi_bt_ble_coex_example.c index df7e59a1..aa89a97b 100644 --- a/examples/advanced_examples/wifi_bt_ble_coex/main/wifi_bt_ble_coex_example.c +++ b/examples/advanced_examples/wifi_bt_ble_coex/main/wifi_bt_ble_coex_example.c @@ -371,7 +371,7 @@ void app_main(void) input_key_service_info_t input_key_info[] = INPUT_KEY_DEFAULT_INFO(); input_key_service_cfg_t input_cfg = INPUT_KEY_SERVICE_DEFAULT_CONFIG(); input_cfg.handle = g_coex_handle->set; - input_cfg.based_cfg.task_stack = 2048; + input_cfg.based_cfg.task_stack = 3072; input_cfg.based_cfg.extern_stack = true; periph_service_handle_t input_ser = input_key_service_create(&input_cfg); input_key_service_add_key(input_ser, input_key_info, INPUT_KEY_NUM);