Skip to content

Commit

Permalink
Merge branch 'bugfix/wifi_service_failed_to_switch_wifi' into 'master'
Browse files Browse the repository at this point in the history
bugfix: Ignore the 0x3007 status that has been handled internally by wifi

See merge request adf/esp-adf-internal!1243
  • Loading branch information
jason-mao committed Sep 6, 2024
2 parents 0e1d257 + 9a87631 commit d0381eb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
8 changes: 5 additions & 3 deletions components/wifi_service/src/wifi_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -686,4 +689,3 @@ periph_service_handle_t wifi_service_create(wifi_service_config_t *config)

return wifi;
}

13 changes: 13 additions & 0 deletions examples/advanced_examples/wifi_bt_ble_coex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions examples/advanced_examples/wifi_bt_ble_coex/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

本例程的经典蓝牙部分实现了 A2DP SINK 部分。程序启动后,智能手机等蓝牙设备可以发现名为 `ESP_ADF_COEX_EXAMPLE` 的设备,建立连接后,使用 AVRCP 配置文件控制蓝牙音乐状态。

本例程按 [Mode] 键切换 HTTP 或 A2DP 音频; 长按 [Set] 键进入配网模式。


## 环境配置

Expand Down Expand Up @@ -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
```

### 日志输出
以下为本例程的完整日志。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d0381eb

Please sign in to comment.