From 0ac54bb267cd96f6eb6004ad5f8876c1b5a95892 Mon Sep 17 00:00:00 2001 From: Tarun Narain Date: Thu, 2 Apr 2020 19:22:14 +0530 Subject: [PATCH 1/2] Added BLE And BTDM Support to bluetooth_service.c As bluetooth_service component uses CLASSIC_BT by default and releases BLE memory, it was not compatible with BLE ,GATT-A2DP coexist and BTDM. --- .../bluetooth_service/bluetooth_service.c | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/components/bluetooth_service/bluetooth_service.c b/components/bluetooth_service/bluetooth_service.c index 6f95f6513..949d31167 100644 --- a/components/bluetooth_service/bluetooth_service.c +++ b/components/bluetooth_service/bluetooth_service.c @@ -434,19 +434,35 @@ esp_err_t bluetooth_service_start(bluetooth_service_cfg_t *config) g_bt_service = calloc(1, sizeof(bluetooth_service_t)); AUDIO_MEM_CHECK(TAG, g_bt_service, return ESP_ERR_NO_MEM); - + +#if define(CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY) ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE)); +#endif + esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); if (esp_bt_controller_init(&bt_cfg) != ESP_OK) { AUDIO_ERROR(TAG, "initialize controller failed"); return ESP_FAIL; } - +#if define(CONFIG_BTDM_CONTROLLER_MODE_BTDM) + if (esp_bt_controller_enable(ESP_BT_MODE_BTDM) != ESP_OK) { + AUDIO_ERROR(TAG, "enable controller (BTDM Mode) failed"); + return ESP_FAIL; + } +#endif +#if define(CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY) + if (esp_bt_controller_enable(ESP_BT_MODE_BLE) != ESP_OK) { + AUDIO_ERROR(TAG, "enable controller (BLE Only) failed"); + return ESP_FAIL; + } +#endif +#if define(CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY) if (esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT) != ESP_OK) { - AUDIO_ERROR(TAG, "enable controller failed"); + AUDIO_ERROR(TAG, "enable controller (BR_EDR Mode) failed"); return ESP_FAIL; } +#endif if (esp_bluedroid_init() != ESP_OK) { AUDIO_ERROR(TAG, "initialize bluedroid failed"); From 80f72088c15d69d567e69e85f1c165c13cd96e30 Mon Sep 17 00:00:00 2001 From: Tarun Narain Date: Sat, 11 Apr 2020 14:54:12 +0530 Subject: [PATCH 2/2] Updated mistakes. --- components/bluetooth_service/bluetooth_service.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/bluetooth_service/bluetooth_service.c b/components/bluetooth_service/bluetooth_service.c index 949d31167..d256429e9 100644 --- a/components/bluetooth_service/bluetooth_service.c +++ b/components/bluetooth_service/bluetooth_service.c @@ -435,7 +435,7 @@ esp_err_t bluetooth_service_start(bluetooth_service_cfg_t *config) g_bt_service = calloc(1, sizeof(bluetooth_service_t)); AUDIO_MEM_CHECK(TAG, g_bt_service, return ESP_ERR_NO_MEM); -#if define(CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY) +#if defined(CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY) ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE)); #endif @@ -445,19 +445,19 @@ esp_err_t bluetooth_service_start(bluetooth_service_cfg_t *config) AUDIO_ERROR(TAG, "initialize controller failed"); return ESP_FAIL; } -#if define(CONFIG_BTDM_CONTROLLER_MODE_BTDM) +#if defined(CONFIG_BTDM_CONTROLLER_MODE_BTDM) if (esp_bt_controller_enable(ESP_BT_MODE_BTDM) != ESP_OK) { AUDIO_ERROR(TAG, "enable controller (BTDM Mode) failed"); return ESP_FAIL; } #endif -#if define(CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY) +#if defined(CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY) if (esp_bt_controller_enable(ESP_BT_MODE_BLE) != ESP_OK) { AUDIO_ERROR(TAG, "enable controller (BLE Only) failed"); return ESP_FAIL; } #endif -#if define(CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY) +#if defined(CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY) if (esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT) != ESP_OK) { AUDIO_ERROR(TAG, "enable controller (BR_EDR Mode) failed"); return ESP_FAIL;