Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_examples_issues_v2.4' into 'release/v2.4'
Browse files Browse the repository at this point in the history
example: fix example issues(backport 2.4)

See merge request adf/esp-adf-internal!1084
  • Loading branch information
jason-mao committed Sep 6, 2022
2 parents 677ecbb + aeff7fc commit 9ffbb5a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
6 changes: 0 additions & 6 deletions components/wifi_service/blufi_config/blufi_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,6 @@ static void wifi_ble_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_par
#if (defined CONFIG_BT_BLE_BLUFI_ENABLE) || (defined CONFIG_BLUEDROID_ENABLED)
esp_err_t esp_blufi_host_init(void)
{
ESP_ERROR_CHECK(esp_bluedroid_init());
ESP_ERROR_CHECK(esp_bluedroid_enable());
ESP_LOGI(TAG, "BD ADDR: "ESP_BD_ADDR_STR"\n", ESP_BD_ADDR_HEX(esp_bt_dev_get_address()));
return ESP_OK;
}
Expand Down Expand Up @@ -365,10 +363,6 @@ esp_wifi_setting_handle_t blufi_config_create(void *info)
return NULL;
});
esp_wifi_setting_set_data(bc_setting_handle, cfg);
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_bt_controller_init(&bt_cfg));
ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BLE));
ESP_ERROR_CHECK(esp_blufi_host_and_cb_init(&wifi_ble_callbacks));
esp_wifi_setting_register_function(bc_setting_handle, _ble_config_start, _ble_config_stop, NULL);
return bc_setting_handle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@
#include <stdlib.h>

#include "sdkconfig.h"
#include "esp_log.h"
#include "esp_bt.h"
#include "esp_bt_main.h"

#include "esp_peripherals.h"
#include "audio_mem.h"
#include "audio_setup.h"
#include "esp_dispatcher_dueros_app.h"
#include "esp_player_wrapper.h"
#include "duer_audio_action.h"
#include "esp_log.h"

#include "display_service.h"
#include "dueros_service.h"
Expand Down Expand Up @@ -247,6 +250,39 @@ static esp_err_t input_key_service_cb(periph_service_handle_t handle, periph_ser
return ESP_OK;
}

static esp_err_t initialize_ble_stack(void)
{
esp_err_t ret = ESP_OK;
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));

esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
ret = esp_bt_controller_init(&bt_cfg);
if (ret) {
ESP_LOGE(TAG, "%s initialize bt controller failed: %s\n", __func__, esp_err_to_name(ret));
return ret;
}

ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
if (ret) {
ESP_LOGE(TAG, "%s enable bt controller failed: %s\n", __func__, esp_err_to_name(ret));
return ret;
}

ret = esp_bluedroid_init();
if (ret) {
ESP_LOGE(TAG, "%s init bluedroid failed: %s\n", __func__, esp_err_to_name(ret));
return ret;
}

ret = esp_bluedroid_enable();
if (ret) {
ESP_LOGE(TAG, "%s init bluedroid failed: %s\n", __func__, esp_err_to_name(ret));
return ret;
}
return ESP_OK;
}


void duer_app_init(void)
{
esp_log_level_set("*", ESP_LOG_INFO);
Expand Down Expand Up @@ -369,6 +405,7 @@ void duer_app_init(void)
smart_config_info_t info = SMART_CONFIG_INFO_DEFAULT();
h = smart_config_create(&info);
#elif (defined CONFIG_ESP_BLUFI_PROVISIONING)
initialize_ble_stack();
h = blufi_config_create(NULL);
#endif
esp_wifi_setting_regitster_notify_handle(h, (void *)dueros_speaker->wifi_serv);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ static esp_err_t wifi_service_cb(periph_service_handle_t handle, periph_service_
if (evt->type == WIFI_SERV_EVENT_CONNECTED) {
ESP_LOGI(TAG, "WIFI_CONNECTED");
g_wifi_connect_state = true;
esp_err_t set_dev_name_ret = esp_bt_dev_set_device_name(SAMPLE_DEVICE_NAME);
if (set_dev_name_ret) {
ESP_LOGE(TAG, "Set BT device name failed, error code = %x, line(%d)", set_dev_name_ret, __LINE__);
}
} else if (evt->type == WIFI_SERV_EVENT_DISCONNECTED) {
ESP_LOGI(TAG, "WIFI_DISCONNECTED");
g_wifi_connect_state = false;
Expand Down Expand Up @@ -314,7 +318,7 @@ static void a2dp_sink_blufi_start(coex_handle_t *handle)

esp_err_t set_dev_name_ret = esp_bt_dev_set_device_name(SAMPLE_DEVICE_NAME);
if (set_dev_name_ret) {
ESP_LOGE(TAG, "set device name failed, error code = %x", set_dev_name_ret);
ESP_LOGE(TAG, "Set BT device name failed, error code = %x, line(%d)", set_dev_name_ret, __LINE__);
}
ESP_LOGI(TAG, "[4.3] Create Bluetooth peripheral");
handle->bt_periph = bt_create_periph();
Expand Down
1 change: 1 addition & 0 deletions examples/korvo_du1906/main/app_player_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ esp_err_t app_player_init(QueueHandle_t que, audio_player_evt_callback cb, esp_p
audio_board_handle_t board_handle = audio_board_init();
audio_hal_ctrl_codec(board_handle->audio_hal, AUDIO_HAL_CODEC_MODE_BOTH, AUDIO_HAL_CTRL_START);

// This API must call before BluFI's network
esp_periph_handle_t bt_periph = app_bluetooth_init(set);

esp_audio_cfg_t default_cfg = DEFAULT_ESP_AUDIO_CONFIG();
Expand Down

0 comments on commit 9ffbb5a

Please sign in to comment.