From 7a4d10b718261c5bd019fa064a2dd6abd709b6c5 Mon Sep 17 00:00:00 2001 From: Zhang Hai Peng Date: Tue, 5 Nov 2024 16:13:46 +0800 Subject: [PATCH] fix(ble/bluedroid): Fixed BLE build fail when enable dynamic memory and BLE5.0 (cherry picked from commit 94d1a4f1c009031c7623153b885f1f75b39b4555) Co-authored-by: zhanghaipeng --- components/bt/common/btc/core/btc_task.c | 10 ++++++---- .../bluedroid/btc/profile/std/include/btc_gap_ble.h | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/components/bt/common/btc/core/btc_task.c b/components/bt/common/btc/core/btc_task.c index b6af1aadcb5c..7b45cf85f1d8 100644 --- a/components/bt/common/btc/core/btc_task.c +++ b/components/bt/common/btc/core/btc_task.c @@ -382,7 +382,7 @@ static void btc_deinit_mem(void) { btc_profile_cb_tab = NULL; } -#if (BLE_INCLUDED == TRUE) +#if (BLE_42_FEATURE_SUPPORT == TRUE) if (gl_bta_adv_data_ptr) { osi_free(gl_bta_adv_data_ptr); gl_bta_adv_data_ptr = NULL; @@ -392,7 +392,7 @@ static void btc_deinit_mem(void) { osi_free(gl_bta_scan_rsp_data_ptr); gl_bta_scan_rsp_data_ptr = NULL; } -#endif ///BLE_INCLUDED == TRUE +#endif // BLE_42_FEATURE_SUPPORT #if GATTS_INCLUDED == TRUE && GATT_DYNAMIC_MEMORY == TRUE if (btc_creat_tab_env_ptr) { @@ -444,7 +444,8 @@ static bt_status_t btc_init_mem(void) { } memset((void *)btc_profile_cb_tab, 0, sizeof(void *) * BTC_PID_NUM); -#if (BLE_INCLUDED == TRUE) +#if BTC_DYNAMIC_MEMORY == TRUE +#if (BLE_42_FEATURE_SUPPORT == TRUE) if ((gl_bta_adv_data_ptr = (tBTA_BLE_ADV_DATA *)osi_malloc(sizeof(tBTA_BLE_ADV_DATA))) == NULL) { goto error_exit; } @@ -454,7 +455,8 @@ static bt_status_t btc_init_mem(void) { goto error_exit; } memset((void *)gl_bta_scan_rsp_data_ptr, 0, sizeof(tBTA_BLE_ADV_DATA)); -#endif ///BLE_INCLUDED == TRUE +#endif // (BLE_42_FEATURE_SUPPORT == TRUE) +#endif // BTC_DYNAMIC_MEMORY == TRUE #if GATTS_INCLUDED == TRUE && GATT_DYNAMIC_MEMORY == TRUE if ((btc_creat_tab_env_ptr = (esp_btc_creat_tab_t *)osi_malloc(sizeof(esp_btc_creat_tab_t))) == NULL) { diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h index e540116de19f..9e9ad155e845 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h @@ -11,11 +11,13 @@ #include "esp_gap_ble_api.h" #if BTC_DYNAMIC_MEMORY == TRUE +#if (BLE_42_FEATURE_SUPPORT == TRUE) #include "bta/bta_api.h" extern tBTA_BLE_ADV_DATA *gl_bta_adv_data_ptr; extern tBTA_BLE_ADV_DATA *gl_bta_scan_rsp_data_ptr; #define gl_bta_adv_data (*gl_bta_adv_data_ptr) #define gl_bta_scan_rsp_data (*gl_bta_scan_rsp_data_ptr) +#endif // BLE_42_FEATURE_SUPPORT #endif #define BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)))