From dd08f8ad7331c4e52adeb3b964c0508a2a4a307f Mon Sep 17 00:00:00 2001 From: Zhi Wei Jian Date: Wed, 7 Jan 2026 17:23:16 +0800 Subject: [PATCH] feat(ble/bluedroid): reduce bluedroid host heap used for BLE (cherry picked from commit 438590a1f5cf02edfe659770e1e86e342b8c88f7) Co-authored-by: zhiweijian --- .../bt/host/bluedroid/bta/dm/bta_dm_act.c | 41 +++++++++++++++---- .../bt/host/bluedroid/bta/dm/bta_dm_main.c | 10 ++++- .../bluedroid/bta/dm/include/bta_dm_int.h | 9 ++-- .../bt/host/bluedroid/btc/core/btc_main.c | 4 +- .../common/include/common/bt_target.h | 4 +- components/bt/host/bluedroid/main/bte_init.c | 6 +++ .../bt/host/bluedroid/stack/btm/btm_acl.c | 17 +++++++- .../bt/host/bluedroid/stack/btm/btm_devctl.c | 7 ++-- .../bt/host/bluedroid/stack/btm/btm_main.c | 4 ++ .../bt/host/bluedroid/stack/btm/btm_pm.c | 12 ++++-- .../bt/host/bluedroid/stack/btm/btm_sec.c | 5 ++- .../bluedroid/stack/btm/include/btm_int.h | 4 ++ .../bt/host/bluedroid/stack/gatt/gatt_api.c | 10 ++++- .../bt/host/bluedroid/stack/gatt/gatt_auth.c | 11 ++++- .../bt/host/bluedroid/stack/gatt/gatt_main.c | 31 ++++++++------ .../bt/host/bluedroid/stack/gatt/gatt_utils.c | 35 +++++++++++----- .../bluedroid/stack/gatt/include/gatt_int.h | 18 +++++--- 17 files changed, 172 insertions(+), 56 deletions(-) diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c index 5c41dbd3ea..19b1cb4c31 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -49,9 +49,10 @@ #if (BT_CONTROLLER_INCLUDED == TRUE) #include "esp_bt.h" #endif - +#if (CLASSIC_BT_INCLUDED == TRUE) static void bta_dm_inq_results_cb (tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir); static void bta_dm_inq_cmpl_cb (void *p_result); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) static void bta_dm_service_search_remname_cback (BD_ADDR bd_addr, DEV_CLASS dc, BD_NAME bd_name); static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name); #if (SDP_INCLUDED == TRUE) @@ -70,7 +71,9 @@ static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_ static UINT8 bta_dm_authentication_complete_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, int result); #endif ///SMP_INCLUDED == TRUE static void bta_dm_local_name_cback(const BD_ADDR bd_addr); +#if (CLASSIC_BT_INCLUDED == TRUE) static BOOLEAN bta_dm_check_av(UINT16 event); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data); @@ -91,7 +94,9 @@ static void bta_dm_eir_search_services( tBTM_INQ_RESULTS *p_result, static void bta_dm_search_timer_cback (TIMER_LIST_ENT *p_tle); static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle); static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr); +#if (CLASSIC_BT_INCLUDED == TRUE) static void bta_dm_adjust_roles(BOOLEAN delay_role_switch); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) #if (SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE) static char *bta_dm_get_remname(void); #endif ///SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE @@ -137,7 +142,10 @@ static void bta_dm_observe_cmpl_cb(void *p_result); static void bta_dm_observe_discard_cb (uint32_t num_dis); #endif ///BLE_INCLUDED == TRUE +#if (CLASSIC_BT_INCLUDED == TRUE) static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) + extern void sdpu_uuid16_to_uuid128(UINT16 uuid16, UINT8 *p_uuid128); static void bta_dm_disable_timer_cback(TIMER_LIST_ENT *p_tle); @@ -481,7 +489,9 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status ) /* hw is ready, go on with BTA DM initialization */ memset(&bta_dm_search_cb, 0x00, sizeof(bta_dm_search_cb)); memset(&bta_dm_conn_srvcs, 0x00, sizeof(bta_dm_conn_srvcs)); +#if (CLASSIC_BT_INCLUDED == TRUE) memset(&bta_dm_di_cb, 0, sizeof(tBTA_DM_DI_CB)); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) memcpy(dev_class, p_bta_dm_cfg->dev_class, sizeof(dev_class)); #if CLASSIC_BT_INCLUDED BTM_SetDeviceClass (dev_class); @@ -1656,7 +1666,9 @@ void bta_dm_ci_rmt_oob_act(tBTA_DM_MSG *p_data) *******************************************************************************/ void bta_dm_search_start (tBTA_DM_MSG *p_data) { +#if (CLASSIC_BT_INCLUDED == TRUE) tBTM_INQUIRY_CMPL result; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) #if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE) && (GATTC_INCLUDED == TRUE) UINT16 len = (UINT16)(sizeof(tBT_UUID) * p_data->search.num_uuid); @@ -1665,12 +1677,13 @@ void bta_dm_search_start (tBTA_DM_MSG *p_data) APPL_TRACE_DEBUG("%s avoid_scatter=%d", __func__, p_bta_dm_cfg->avoid_scatter); +#if (CLASSIC_BT_INCLUDED == TRUE) if (p_bta_dm_cfg->avoid_scatter && (p_data->search.rs_res == BTA_DM_RS_NONE) && bta_dm_check_av(BTA_DM_API_SEARCH_EVT)) { memcpy(&bta_dm_cb.search_msg, &p_data->search, sizeof(tBTA_DM_API_SEARCH)); return; } - +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) BTM_ClearInqDb(NULL); /* save search params */ bta_dm_search_cb.p_search_cback = p_data->search.p_cback; @@ -1693,6 +1706,7 @@ void bta_dm_search_start (tBTA_DM_MSG *p_data) memcpy(bta_dm_search_cb.p_srvc_uuid, p_data->search.p_uuid, len); } #endif +#if (CLASSIC_BT_INCLUDED == TRUE) result.status = BTM_StartInquiry( (tBTM_INQ_PARMS *)&p_data->search.inq_params, bta_dm_inq_results_cb, (tBTM_CMPL_CB *) bta_dm_inq_cmpl_cb); @@ -1702,6 +1716,7 @@ void bta_dm_search_start (tBTA_DM_MSG *p_data) result.num_resp = 0; bta_dm_inq_cmpl_cb ((void *)&result); } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) } /******************************************************************************* @@ -2842,6 +2857,7 @@ static void bta_dm_sdp_callback (UINT16 sdp_status) } } #endif ///SDP_INCLUDED == TRUE +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function bta_dm_inq_results_cb @@ -2930,6 +2946,7 @@ static void bta_dm_inq_cmpl_cb (void *p_result) } } } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** @@ -3556,6 +3573,7 @@ static void bta_dm_acl_link_stat_cback(tBTM_ACL_LINK_STAT_EVENT_DATA *p_data) } } +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function bta_dm_rs_cback @@ -3624,6 +3642,7 @@ static BOOLEAN bta_dm_check_av(UINT16 event) } return switching; } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** @@ -3643,10 +3662,11 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data) tBTA_DM_SEC conn; BOOLEAN is_new = p_data->acl_change.is_new; BD_ADDR_PTR p_bda = p_data->acl_change.bd_addr; - BOOLEAN need_policy_change = FALSE; BOOLEAN issue_unpair_cb = FALSE; - +#if (CLASSIC_BT_INCLUDED == TRUE) + BOOLEAN need_policy_change = FALSE; tBTA_DM_PEER_DEVICE *p_dev; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) memset(&conn, 0, sizeof(tBTA_DM_SEC)); switch (p_data->acl_change.event) { @@ -3657,7 +3677,7 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data) bta_dm_cb.p_sec_cback(BTA_DM_BUSY_LEVEL_EVT, &conn); } return; - +#if (CLASSIC_BT_INCLUDED == TRUE) case BTM_BL_ROLE_CHG_EVT: /* role change event */ p_dev = bta_dm_find_peer_device(p_bda); if (p_dev) { @@ -3693,6 +3713,7 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data) } } return; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) } /* Collision report from Stack: Notify profiles */ @@ -3830,7 +3851,9 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data) } } +#if (CLASSIC_BT_INCLUDED == TRUE) bta_dm_adjust_roles(TRUE); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) } /******************************************************************************* @@ -3907,7 +3930,7 @@ static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, } } } - +#if (CLASSIC_BT_INCLUDED == TRUE) if ((BTA_ID_AV == id) || (BTA_ID_AVK == id)) { if ( status == BTA_SYS_CONN_BUSY) { if (p_dev) { @@ -3936,8 +3959,10 @@ static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, if ((status != BTA_SYS_CONN_BUSY) && (status != BTA_SYS_CONN_IDLE)) { bta_dm_adjust_roles(FALSE); } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) } +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function bta_dm_delay_role_switch_cback @@ -3953,6 +3978,7 @@ static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle) APPL_TRACE_EVENT("bta_dm_delay_role_switch_cback: initiating Delayed RS"); bta_dm_adjust_roles (FALSE); } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** @@ -3996,7 +4022,7 @@ static BOOLEAN bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr) } #endif ///SMP_INCLUDED == TRUE - +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function bta_dm_adjust_roles @@ -4080,6 +4106,7 @@ static void bta_dm_adjust_roles(BOOLEAN delay_role_switch) } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c index 79a1bdd456..ef968c35bd 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c @@ -40,11 +40,15 @@ #if BTA_DYNAMIC_MEMORY == FALSE tBTA_DM_CB bta_dm_cb; tBTA_DM_SEARCH_CB bta_dm_search_cb; +#if (CLASSIC_BT_INCLUDED == TRUE) tBTA_DM_DI_CB bta_dm_di_cb; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) #else tBTA_DM_CB *bta_dm_cb_ptr; tBTA_DM_SEARCH_CB *bta_dm_search_cb_ptr; -tBTA_DM_DI_CB *bta_dm_di_cb_ptr; +#if (CLASSIC_BT_INCLUDED == TRUE) + tBTA_DM_DI_CB *bta_dm_di_cb_ptr; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) SemaphoreHandle_t deinit_semaphore; #endif @@ -566,11 +570,15 @@ void bta_dm_sm_deinit(void) { memset(&bta_dm_cb, 0, sizeof(tBTA_DM_CB)); memset(&bta_dm_search_cb, 0, sizeof(tBTA_DM_SEARCH_CB)); +#if (CLASSIC_BT_INCLUDED == TRUE) memset(&bta_dm_di_cb, 0, sizeof(tBTA_DM_DI_CB)); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) #if BTA_DYNAMIC_MEMORY FREE_AND_RESET(bta_dm_cb_ptr); FREE_AND_RESET(bta_dm_search_cb_ptr); +#if (CLASSIC_BT_INCLUDED == TRUE) FREE_AND_RESET(bta_dm_di_cb_ptr); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) #endif /* #if BTA_DYNAMIC_MEMORY */ } diff --git a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h index a1d5189bbe..7b87cecff7 100644 --- a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h @@ -2197,9 +2197,6 @@ typedef struct { UINT16 state; BOOLEAN disabling; TIMER_LIST_ENT disable_timer; - UINT32 wbt_sdp_handle; /* WIDCOMM Extensions SDP record handle */ - UINT8 wbt_scn; /* WIDCOMM Extensions SCN */ - UINT8 num_master_only; #if (BTA_DM_PM_INCLUDED == TRUE) UINT8 pm_id; tBTA_PM_TIMER pm_timer[BTA_DM_NUM_PM_TIMER]; @@ -2207,7 +2204,9 @@ typedef struct { UINT32 role_policy_mask; /* the bits set indicates the modules that wants to remove role switch from the default link policy */ UINT16 cur_policy; /* current default link policy */ UINT16 rs_event; /* the event waiting for role switch */ +#if (CLASSIC_BT_INCLUDED == TRUE) UINT8 cur_av_count; /* current AV connections */ +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) BOOLEAN disable_pair_mode; /* disable pair mode or not */ BOOLEAN conn_paired_only; /* allow connectable to paired device only or not */ tBTA_DM_API_SEARCH search_msg; @@ -2238,7 +2237,9 @@ typedef struct { tBTA_DM_ENCRYPT_CBACK *p_encrypt_cback; +#if (CLASSIC_BT_INCLUDED == TRUE) TIMER_LIST_ENT switch_delay_timer[BTA_DM_NUM_PEER_DEVICE]; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) } tBTA_DM_CB; @@ -2408,8 +2409,10 @@ extern tBTA_DM_SEARCH_CB *bta_dm_search_cb_ptr; #if BTA_DYNAMIC_MEMORY == FALSE extern tBTA_DM_DI_CB bta_dm_di_cb; #else +#if (CLASSIC_BT_INCLUDED == TRUE) extern tBTA_DM_DI_CB *bta_dm_di_cb_ptr; #define bta_dm_di_cb (*bta_dm_di_cb_ptr) +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) extern SemaphoreHandle_t deinit_semaphore; #endif diff --git a/components/bt/host/bluedroid/btc/core/btc_main.c b/components/bt/host/bluedroid/btc/core/btc_main.c index 593bb99e07..e05e7db020 100644 --- a/components/bt/host/bluedroid/btc/core/btc_main.c +++ b/components/bt/host/bluedroid/btc/core/btc_main.c @@ -79,9 +79,9 @@ static void btc_deinit_bluetooth(void) #if (GATTC_INCLUDED) bta_gattc_deinit(); #endif /* #if (GATTC_INCLUDED) */ -#if (GATTS_INCLUDED) +#if (GATTS_INCLUDED == TRUE) bta_gatts_deinit(); -#endif /* #if (GATTS_INCLUDED) */ +#endif /* #if (GATTS_INCLUDED == TRUE) */ bte_main_shutdown(); #if (SMP_INCLUDED) btc_config_clean_up(); diff --git a/components/bt/host/bluedroid/common/include/common/bt_target.h b/components/bt/host/bluedroid/common/include/common/bt_target.h index df456df828..5f969cd2a2 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -404,13 +404,13 @@ #define CONTROLLER_RPA_LIST_ENABLE FALSE #endif -#if (UC_BT_GATTS_ENABLE) +#if (UC_BT_GATTS_ENABLE == TRUE) #define GATTS_INCLUDED TRUE #else #define GATTS_INCLUDED FALSE #endif /* UC_BT_GATTS_ENABLE */ -#if (UC_BT_GATTC_ENABLE) +#if (UC_BT_GATTC_ENABLE == TRUE) #define GATTC_INCLUDED TRUE #else #define GATTC_INCLUDED FALSE diff --git a/components/bt/host/bluedroid/main/bte_init.c b/components/bt/host/bluedroid/main/bte_init.c index 80c4357b6a..84323d8bde 100644 --- a/components/bt/host/bluedroid/main/bte_init.c +++ b/components/bt/host/bluedroid/main/bte_init.c @@ -249,10 +249,12 @@ void BTE_DeinitStack(void) osi_free(bta_dm_conn_srvcs_ptr); bta_dm_conn_srvcs_ptr = NULL; } +#if (CLASSIC_BT_INCLUDED == TRUE) if (bta_dm_di_cb_ptr){ osi_free(bta_dm_di_cb_ptr); bta_dm_di_cb_ptr = NULL; } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) if (bta_dm_search_cb_ptr){ osi_free(bta_dm_search_cb_ptr); bta_dm_search_cb_ptr = NULL; @@ -399,16 +401,20 @@ bt_status_t BTE_InitStack(void) if ((bta_dm_search_cb_ptr = (tBTA_DM_SEARCH_CB *)osi_malloc(sizeof(tBTA_DM_SEARCH_CB))) == NULL) { goto error_exit; } +#if (CLASSIC_BT_INCLUDED == TRUE) if ((bta_dm_di_cb_ptr = (tBTA_DM_DI_CB *)osi_malloc(sizeof(tBTA_DM_DI_CB))) == NULL) { goto error_exit; } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) if ((bta_dm_conn_srvcs_ptr = (tBTA_DM_CONNECTED_SRVCS *)osi_malloc(sizeof(tBTA_DM_CONNECTED_SRVCS))) == NULL) { goto error_exit; } memset((void *)bta_sys_cb_ptr, 0, sizeof(tBTA_SYS_CB)); memset((void *)bta_dm_cb_ptr, 0, sizeof(tBTA_DM_CB)); memset((void *)bta_dm_search_cb_ptr, 0, sizeof(tBTA_DM_SEARCH_CB)); +#if (CLASSIC_BT_INCLUDED == TRUE) memset((void *)bta_dm_di_cb_ptr, 0, sizeof(tBTA_DM_DI_CB)); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) memset((void *)bta_dm_conn_srvcs_ptr, 0, sizeof(tBTA_DM_CONNECTED_SRVCS)); //memset((void *)bta_prm_cb_ptr, 0, sizeof(tBTA_PRM_CB)); diff --git a/components/bt/host/bluedroid/stack/btm/btm_acl.c b/components/bt/host/bluedroid/stack/btm/btm_acl.c index fc4b44a277..6bd991c1f9 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/host/bluedroid/stack/btm/btm_acl.c @@ -532,7 +532,9 @@ void btm_acl_device_down (void) void btm_acl_update_busy_level (tBTM_BLI_EVENT event) { UINT8 busy_level_flags = 0; +#if (CLASSIC_BT_INCLUDED == TRUE) BOOLEAN old_inquiry_state = btm_cb.is_inquiry; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) BTM_TRACE_DEBUG ("btm_acl_update_busy_level\n"); @@ -543,6 +545,7 @@ void btm_acl_update_busy_level (tBTM_BLI_EVENT event) case BTM_BLI_ACL_DOWN_EVT: BTM_TRACE_DEBUG ("BTM_BLI_ACL_DOWN_EVT\n"); break; +#if (CLASSIC_BT_INCLUDED == TRUE) case BTM_BLI_PAGE_EVT: BTM_TRACE_DEBUG ("BTM_BLI_PAGE_EVT\n"); btm_cb.is_paging = TRUE; @@ -568,16 +571,24 @@ void btm_acl_update_busy_level (tBTM_BLI_EVENT event) btm_cb.is_inquiry = FALSE; busy_level_flags = BTM_BL_INQUIRY_COMPLETE; break; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) } UINT8 busy_level; +#if (CLASSIC_BT_INCLUDED == TRUE) if (btm_cb.is_paging || btm_cb.is_inquiry) { busy_level = 10; - } else { + } else +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) + { busy_level = BTM_GetNumAclLinks(); } - if ((busy_level != btm_cb.busy_level) || (old_inquiry_state != btm_cb.is_inquiry)) { + if ((busy_level != btm_cb.busy_level) +#if (CLASSIC_BT_INCLUDED == TRUE) + || (old_inquiry_state != btm_cb.is_inquiry) +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) + ) { tBTM_BL_UPDATE_DATA evt = { .event = BTM_BL_UPDATE_EVT, .busy_level = busy_level, @@ -2640,6 +2651,7 @@ void btm_cont_rswitch (tACL_CONN *p, tBTM_SEC_DEV_REC *p_dev_rec, } } +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btm_acl_resubmit_page @@ -2693,6 +2705,7 @@ void btm_acl_reset_paging (void) btm_cb.paging = FALSE; } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** diff --git a/components/bt/host/bluedroid/stack/btm/btm_devctl.c b/components/bt/host/bluedroid/stack/btm/btm_devctl.c index 0e62e3c24a..4f0277a36e 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_devctl.c +++ b/components/bt/host/bluedroid/stack/btm/btm_devctl.c @@ -93,13 +93,14 @@ void btm_dev_init (void) btm_cb.btm_acl_pkt_types_supported = BTM_ACL_PKT_TYPES_MASK_DH1 + BTM_ACL_PKT_TYPES_MASK_DM1 + BTM_ACL_PKT_TYPES_MASK_DH3 + BTM_ACL_PKT_TYPES_MASK_DM3 + BTM_ACL_PKT_TYPES_MASK_DH5 + BTM_ACL_PKT_TYPES_MASK_DM5; - +#if (CLASSIC_BT_INCLUDED == TRUE) btm_cb.btm_sco_pkt_types_supported = BTM_SCO_PKT_TYPES_MASK_HV1 + BTM_SCO_PKT_TYPES_MASK_HV2 + BTM_SCO_PKT_TYPES_MASK_HV3 + BTM_SCO_PKT_TYPES_MASK_EV3 + BTM_SCO_PKT_TYPES_MASK_EV4 + BTM_SCO_PKT_TYPES_MASK_EV5; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) } @@ -330,7 +331,7 @@ static void btm_decode_ext_features_page (UINT8 page_number, const BD_FEATURES p BTM_TRACE_DEBUG("Local supported ACL packet types: 0x%04x", btm_cb.btm_acl_pkt_types_supported); - +#if (CLASSIC_BT_INCLUDED == TRUE) /* Create (e)SCO supported packet types mask */ btm_cb.btm_sco_pkt_types_supported = 0; #if BTM_SCO_INCLUDED == TRUE @@ -386,7 +387,7 @@ static void btm_decode_ext_features_page (UINT8 page_number, const BD_FEATURES p BTM_TRACE_DEBUG("Local supported SCO packet types: 0x%04x", btm_cb.btm_sco_pkt_types_supported); - +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /* Create Default Policy Settings */ if (HCI_SWITCH_SUPPORTED(p_features)) { btm_cb.btm_def_link_policy |= HCI_ENABLE_MASTER_SLAVE_SWITCH; diff --git a/components/bt/host/bluedroid/stack/btm/btm_main.c b/components/bt/host/bluedroid/stack/btm/btm_main.c index b109e5395b..49447f00f6 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_main.c +++ b/components/bt/host/bluedroid/stack/btm/btm_main.c @@ -64,7 +64,9 @@ void btm_init (void) #endif /* #if BTM_DYNAMIC_MEMORY */ /* All fields are cleared; nonzero fields are reinitialized in appropriate function */ memset(&btm_cb, 0, sizeof(tBTM_CB)); +#if (CLASSIC_BT_INCLUDED == TRUE) btm_cb.page_queue = fixed_queue_new(QUEUE_SIZE_MAX); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) btm_cb.sec_pending_q = fixed_queue_new(QUEUE_SIZE_MAX); #if defined(BTM_INITIAL_TRACE_LEVEL) @@ -110,8 +112,10 @@ void btm_init (void) *******************************************************************************/ void btm_free(void) { +#if (CLASSIC_BT_INCLUDED == TRUE) fixed_queue_free(btm_cb.page_queue, osi_free_func); fixed_queue_free(btm_cb.sec_pending_q, osi_free_func); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) btm_acl_free(); btm_sec_dev_free(); #if BTM_SCO_INCLUDED == TRUE diff --git a/components/bt/host/bluedroid/stack/btm/btm_pm.c b/components/bt/host/bluedroid/stack/btm/btm_pm.c index de48a2dad6..915cd43d55 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_pm.c +++ b/components/bt/host/bluedroid/stack/btm/btm_pm.c @@ -901,7 +901,7 @@ BOOLEAN btm_pm_device_in_active_or_sniff_mode(void) return FALSE; } - +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btm_pm_device_in_scan_state @@ -930,7 +930,7 @@ BOOLEAN btm_pm_device_in_scan_state(void) return FALSE; } - +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function BTM_PM_ReadControllerState @@ -944,9 +944,13 @@ tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void) { if (TRUE == btm_pm_device_in_active_or_sniff_mode()) { return BTM_CONTRL_ACTIVE; - } else if (TRUE == btm_pm_device_in_scan_state()) { + } +#if (CLASSIC_BT_INCLUDED == TRUE) + else if (TRUE == btm_pm_device_in_scan_state()) { return BTM_CONTRL_SCAN; - } else { + } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) + else { return BTM_CONTRL_IDLE; } } diff --git a/components/bt/host/bluedroid/stack/btm/btm_sec.c b/components/bt/host/bluedroid/stack/btm/btm_sec.c index 35337e40a3..94f05ff98f 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_sec.c +++ b/components/bt/host/bluedroid/stack/btm/btm_sec.c @@ -3007,7 +3007,9 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT BTM_TRACE_EVENT ("btm_sec_rmt_name_request_complete\n"); if (((p_bd_addr == NULL) && !BTM_ACL_IS_CONNECTED(btm_cb.connecting_bda)) || ((p_bd_addr != NULL) && !BTM_ACL_IS_CONNECTED(p_bd_addr))) { +#if (CLASSIC_BT_INCLUDED == TRUE) btm_acl_resubmit_page(); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) } /* If remote name request failed, p_bd_addr is null and we need to search */ @@ -4303,8 +4305,9 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode) BOOLEAN is_pairing_device = FALSE; tACL_CONN *p_acl_cb; UINT8 bit_shift = 0; - +#if (CLASSIC_BT_INCLUDED == TRUE) btm_acl_resubmit_page(); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda); diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_int.h index 69748bd4a2..3a4399e7c3 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_int.h @@ -899,7 +899,9 @@ typedef struct { /* Packet types supported by the local device */ UINT16 btm_acl_pkt_types_supported; +#if (CLASSIC_BT_INCLUDED == TRUE) UINT16 btm_sco_pkt_types_supported; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /***************************************************** @@ -969,10 +971,12 @@ typedef struct { UINT8 acl_disc_reason; UINT8 trace_level; UINT8 busy_level; /* the current busy level */ +#if (CLASSIC_BT_INCLUDED == TRUE) BOOLEAN is_paging; /* TRUE, if paging is in progress */ BOOLEAN is_inquiry; /* TRUE, if inquiry is in progress */ fixed_queue_t *page_queue; BOOLEAN paging; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) BOOLEAN discing; fixed_queue_t *sec_pending_q; /* pending sequrity requests in tBTM_SEC_QUEUE_ENTRY format */ #if (!defined(BT_TRACE_VERBOSE) || (BT_TRACE_VERBOSE == FALSE)) diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_api.c b/components/bt/host/bluedroid/stack/gatt/gatt_api.c index db7952e95a..e48d9d2289 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_api.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_api.c @@ -1044,11 +1044,13 @@ tGATT_STATUS GATTC_Read (UINT16 conn_id, tGATT_READ_TYPE type, tGATT_READ_PARAM default: break; } +#if (SMP_INCLUDED == TRUE) /* start security check */ if (gatt_security_check_start(p_clcb) == FALSE) { status = GATT_NO_RESOURCES; gatt_clcb_dealloc(p_clcb); } +#endif // (SMP_INCLUDED == TRUE) } else { status = GATT_NO_RESOURCES; } @@ -1108,10 +1110,11 @@ tGATT_STATUS GATTC_Write (UINT16 conn_id, tGATT_WRITE_TYPE type, tGATT_VALUE *p_ p_clcb->start_offset = p_write->offset; p->offset = 0; } - +#if (SMP_INCLUDED == TRUE) if (gatt_security_check_start(p_clcb) == FALSE) { status = GATT_NO_RESOURCES; } +#endif // (SMP_INCLUDED == TRUE) } else { status = GATT_NO_RESOURCES; } @@ -1584,6 +1587,7 @@ tGATT_STATUS GATT_Disconnect (UINT16 conn_id) return ret; } +#if (GATTS_INCLUDED == TRUE) /******************************************************************************* ** ** Function GATT_SendServiceChangeIndication @@ -1630,6 +1634,7 @@ tGATT_STATUS GATT_SendServiceChangeIndication (BD_ADDR bd_addr) return status; } +#endif // (GATTS_INCLUDED == TRUE) /******************************************************************************* ** @@ -1737,6 +1742,7 @@ BOOLEAN GATT_Listen (tGATT_IF gatt_if, BOOLEAN start, BD_ADDR_PTR bd_addr) return gatt_update_listen_mode(); } +#if (GATTS_INCLUDED == TRUE) tGATT_STATUS GATTS_SetServiceChangeMode(UINT8 mode) { if (mode > GATTS_SEND_SERVICE_CHANGE_MANUAL) { @@ -1748,6 +1754,8 @@ tGATT_STATUS GATTS_SetServiceChangeMode(UINT8 mode) return GATT_SUCCESS; } +#endif // (GATTS_INCLUDED == TRUE) + tGATT_STATUS GATTS_HandleMultiValueNotification (UINT16 conn_id, tGATT_HLV *tuples, UINT16 num_tuples) { tGATT_STATUS cmd_sent = GATT_ILLEGAL_PARAMETER; diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_auth.c b/components/bt/host/bluedroid/stack/gatt/gatt_auth.c index 4db0a554d5..a5769a83d7 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_auth.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_auth.c @@ -129,6 +129,8 @@ void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf) } #endif ///SMP_INCLUDED == TRUE +#if (SMP_INCLUDED == TRUE) + /******************************************************************************* ** ** Function gatt_sec_check_complete @@ -155,6 +157,7 @@ void gatt_sec_check_complete(BOOLEAN sec_check_ok, tGATT_CLCB *p_clcb, UINT8 s #endif ///GATTC_INCLUDED == TRUE } } + /******************************************************************************* ** ** Function gatt_enc_cmpl_cback @@ -253,6 +256,7 @@ void gatt_notify_enc_cmpl(BD_ADDR bd_addr) } return; } + /******************************************************************************* ** ** Function gatt_set_sec_act @@ -268,6 +272,7 @@ void gatt_set_sec_act(tGATT_TCB *p_tcb, tGATT_SEC_ACTION sec_act) p_tcb->sec_act = sec_act; } } + /******************************************************************************* ** ** Function gatt_get_sec_act @@ -285,6 +290,7 @@ tGATT_SEC_ACTION gatt_get_sec_act(tGATT_TCB *p_tcb) } return sec_act; } +#endif // (SMP_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_determine_sec_act @@ -420,7 +426,7 @@ tGATT_STATUS gatt_get_link_encrypt_status(tGATT_TCB *p_tcb) return encrypt_status ; } - +#if (SMP_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_convert_sec_action @@ -450,6 +456,7 @@ static BOOLEAN gatt_convert_sec_action(tGATT_SEC_ACTION gatt_sec_act, tBTM_BLE_S return status; } + /******************************************************************************* ** ** Function gatt_check_enc_req @@ -517,6 +524,6 @@ BOOLEAN gatt_security_check_start(tGATT_CLCB *p_clcb) return status; } - +#endif // (SMP_INCLUDED == TRUE) #endif /* BLE_INCLUDED */ diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_main.c b/components/bt/host/bluedroid/stack/gatt/gatt_main.c index f92a2c392b..f2db5255a8 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_main.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_main.c @@ -102,8 +102,9 @@ void gatt_init (void) #endif /* #if GATT_DYNAMIC_MEMORY */ memset (&gatt_cb, 0, sizeof(tGATT_CB)); memset (&fixed_reg, 0, sizeof(tL2CAP_FIXED_CHNL_REG)); - +#if (GATTC_INCLUDED == TRUE) gatt_cb.auto_disc = TRUE; +#endif // (GATTC_INCLUDED == TRUE) gatt_cb.p_clcb_list = list_new(osi_free_func); gatt_cb.p_tcb_list = list_new(osi_free_func); #if defined(GATT_INITIAL_TRACE_LEVEL) @@ -111,11 +112,11 @@ void gatt_init (void) #else gatt_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */ #endif - gatt_cb.def_mtu_size = GATT_DEF_BLE_MTU_SIZE; - gatt_cb.sign_op_queue = fixed_queue_new(QUEUE_SIZE_MAX); +#if (GATTS_INCLUDED == TRUE) gatt_cb.srv_chg_clt_q = fixed_queue_new(QUEUE_SIZE_MAX); gatt_cb.pending_new_srv_start_q = fixed_queue_new(QUEUE_SIZE_MAX); gatt_cb.srv_chg_mode = GATTS_SEND_SERVICE_CHANGE_MODE; +#endif // (GATTS_INCLUDED == TRUE) /* First, register fixed L2CAP channel for ATT over BLE */ fixed_reg.fixed_chnl_opts.mode = L2CAP_FCR_BASIC_MODE; @@ -140,11 +141,10 @@ void gatt_init (void) #endif ///CLASSIC_BT_GATT_INCLUDED == TRUE BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_ATT, BTM_SEC_NONE, BT_PSM_ATT, 0, 0); BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_ATT, BTM_SEC_NONE, BT_PSM_ATT, 0, 0); - +#if (GATTS_INCLUDED == TRUE) gatt_cb.hdl_cfg.gatt_start_hdl = GATT_GATT_START_HANDLE; gatt_cb.hdl_cfg.gap_start_hdl = GATT_GAP_START_HANDLE; gatt_cb.hdl_cfg.app_start_hdl = GATT_APP_START_HANDLE; -#if (GATTS_INCLUDED == TRUE) gatt_profile_db_init(); #endif ///GATTS_INCLUDED == TRUE //init local MTU size @@ -165,19 +165,21 @@ void gatt_init (void) void gatt_free(void) { GATT_TRACE_DEBUG("gatt_free()"); - fixed_queue_free(gatt_cb.sign_op_queue, NULL); - gatt_cb.sign_op_queue = NULL; +#if (GATTS_INCLUDED == TRUE) fixed_queue_free(gatt_cb.srv_chg_clt_q, NULL); gatt_cb.srv_chg_clt_q = NULL; fixed_queue_free(gatt_cb.pending_new_srv_start_q, osi_free_func); gatt_cb.pending_new_srv_start_q = NULL; +#endif // (GATTS_INCLUDED == TRUE) list_node_t *p_node = NULL; tGATT_TCB *p_tcb = NULL; for(p_node = list_begin(gatt_cb.p_tcb_list); p_node; p_node = list_next(p_node)) { p_tcb = list_node(p_node); +#if (SMP_INCLUDED == TRUE) fixed_queue_free(p_tcb->pending_enc_clcb, NULL); p_tcb->pending_enc_clcb = NULL; +#endif // (SMP_INCLUDED == TRUE) fixed_queue_free(p_tcb->pending_ind_q, NULL); p_tcb->pending_ind_q = NULL; @@ -411,9 +413,11 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, // but here p_tcb is get from gatt_allocate_tcb_by_bdaddr(), is too old, so we get p_tcb again p_tcb = gatt_find_tcb_by_addr(bd_addr, transport); if(p_tcb != NULL) { +#if (SMP_INCLUDED == TRUE) if(p_tcb->pending_enc_clcb != NULL) { fixed_queue_free(p_tcb->pending_enc_clcb, NULL); } +#endif // (SMP_INCLUDED == TRUE) if(p_tcb->pending_ind_q != NULL) { fixed_queue_free(p_tcb->pending_ind_q, NULL); } @@ -450,8 +454,10 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect { tGATT_TCB *p_tcb = gatt_find_tcb_by_addr(bd_addr, transport); +#if (GATTS_INCLUDED == TRUE) BOOLEAN check_srv_chg = FALSE; tGATTS_SRV_CHG *p_srv_chg_clt = NULL; +#endif // (GATTS_INCLUDED == TRUE) /* ignore all fixed channel connect/disconnect on BR/EDR link for GATT */ if (transport == BT_TRANSPORT_BR_EDR) { @@ -461,7 +467,7 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect GATT_TRACE_DEBUG ("GATT ATT protocol channel with BDA: %08x%04x is %s", (bd_addr[0] << 24) + (bd_addr[1] << 16) + (bd_addr[2] << 8) + bd_addr[3], (bd_addr[4] << 8) + bd_addr[5], (connected) ? "connected" : "disconnected"); - +#if (GATTS_INCLUDED == TRUE) if ((p_srv_chg_clt = gatt_is_bda_in_the_srv_chg_clt_list(bd_addr)) != NULL) { check_srv_chg = TRUE; } else { @@ -469,6 +475,7 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect gatt_add_a_bonded_dev_for_srv_chg(bd_addr); } } +#endif // #if (GATTS_INCLUDED == TRUE) if (connected) { /* do we have a channel initiating a connection? */ @@ -481,11 +488,11 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect gatt_send_conn_cback(p_tcb); } - if (check_srv_chg) { #if (GATTS_INCLUDED == TRUE) + if (check_srv_chg) { gatt_chk_srv_chg (p_srv_chg_clt); -#endif ///GATTS_INCLUDED == TRUE } +#endif ///GATTS_INCLUDED == TRUE } /* this is incoming connection or background connection callback */ @@ -498,11 +505,11 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect p_tcb->payload_size = GATT_DEF_BLE_MTU_SIZE; gatt_send_conn_cback (p_tcb); - if (check_srv_chg) { #if (GATTS_INCLUDED == TRUE) + if (check_srv_chg) { gatt_chk_srv_chg (p_srv_chg_clt); -#endif ///GATTS_INCLUDED == TRUE } +#endif ///GATTS_INCLUDED == TRUE } else { GATT_TRACE_ERROR("CCB max out, no resources"); } diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_utils.c b/components/bt/host/bluedroid/stack/gatt/gatt_utils.c index ae99c39a9f..02236abe90 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_utils.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_utils.c @@ -104,6 +104,7 @@ void gatt_free_pending_ind(tGATT_TCB *p_tcb) p_tcb->pending_ind_q = NULL; } +#if (SMP_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_free_pending_enc_queue @@ -127,6 +128,7 @@ void gatt_free_pending_enc_queue(tGATT_TCB *p_tcb) fixed_queue_free(p_tcb->pending_enc_clcb, NULL); p_tcb->pending_enc_clcb = NULL; } +#endif // (SMP_INCLUDED == TRUE) /******************************************************************************* ** @@ -154,6 +156,7 @@ void gatt_free_pending_prepare_write_queue(tGATT_TCB *p_tcb) p_tcb->prepare_write_record.error_code_app = GATT_SUCCESS; } +#if (GATTS_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_delete_dev_from_srv_chg_clt_list @@ -248,7 +251,7 @@ tGATTS_PENDING_NEW_SRV_START *gatt_sr_is_new_srv_chg(tBT_UUID *p_app_uuid128, tB return p_buf; } - +#endif // (GATTS_INCLUDED == TRUE) /******************************************************************************* ** @@ -271,7 +274,7 @@ tGATT_VALUE *gatt_add_pending_ind(tGATT_TCB *p_tcb, tGATT_VALUE *p_ind) return p_buf; } - +#if (GATTS_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_add_pending_new_srv_start @@ -327,7 +330,7 @@ tGATTS_SRV_CHG *gatt_add_srv_chg_clt(tGATTS_SRV_CHG *p_srv_chg) ** Returns Pointer to the allocated buffer, NULL no buffer available ** *******************************************************************************/ -#if (GATTS_INCLUDED == TRUE) + tGATT_HDL_LIST_ELEM *gatt_alloc_hdl_buffer(void) { UINT8 i; @@ -803,7 +806,7 @@ BOOLEAN gatt_find_the_connected_bda(UINT8 start_idx, BD_ADDR bda, UINT8 *p_found return found; } - +#if (GATTS_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_is_srv_chg_ind_pending @@ -874,7 +877,7 @@ tGATTS_SRV_CHG *gatt_is_bda_in_the_srv_chg_clt_list (BD_ADDR bda) return p_buf; } - +#endif // (GATTS_INCLUDED == TRUE) /******************************************************************************* ** @@ -1083,7 +1086,9 @@ tGATT_TCB *gatt_allocate_tcb_by_bdaddr(BD_ADDR bda, tBT_TRANSPORT transport) } if (allocated) { memset(p_tcb, 0, sizeof(tGATT_TCB)); +#if (SMP_INCLUDED == TRUE) p_tcb->pending_enc_clcb = fixed_queue_new(QUEUE_SIZE_MAX); +#endif // (SMP_INCLUDED == TRUE) p_tcb->pending_ind_q = fixed_queue_new(QUEUE_SIZE_MAX); p_tcb->in_use = TRUE; p_tcb->tcb_idx = i; @@ -1390,6 +1395,8 @@ void gatt_ind_ack_timeout(TIMER_LIST_ENT *p_tle) attp_send_cl_msg(((tGATT_TCB *)p_tle->param), 0, GATT_HANDLE_VALUE_CONF, NULL); } + +#if (GATTS_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_sr_find_i_rcb_by_handle @@ -1422,7 +1429,7 @@ UINT8 gatt_sr_find_i_rcb_by_handle(UINT16 handle) ** Returns GATT_MAX_SR_PROFILES if not found. Otherwise index of th eservice. ** *******************************************************************************/ -#if (GATTS_INCLUDED == TRUE) + UINT8 gatt_sr_find_i_rcb_by_app_id(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst) { UINT8 i_rcb = 0; @@ -1446,7 +1453,7 @@ UINT8 gatt_sr_find_i_rcb_by_app_id(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid } return i_rcb; } -#endif ///GATTS_INCLUDED == TRUE + /******************************************************************************* ** ** Function gatt_sr_find_i_rcb_by_handle @@ -1482,6 +1489,7 @@ UINT8 gatt_sr_alloc_rcb(tGATT_HDL_LIST_ELEM *p_list ) return ii; } +#endif ///GATTS_INCLUDED == TRUE /******************************************************************************* ** ** Function gatt_sr_get_sec_info @@ -2370,12 +2378,14 @@ void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason, tBT_TRANSPORT transport) btu_free_timer (&p_tcb->ind_ack_timer_ent); btu_free_timer (&p_tcb->conf_timer_ent); gatt_free_pending_ind(p_tcb); +#if (SMP_INCLUDED == TRUE) gatt_free_pending_enc_queue(p_tcb); +#endif // (SMP_INCLUDED == TRUE) gatt_free_pending_prepare_write_queue(p_tcb); -#if (GATTS_INCLUDED) +#if (GATTS_INCLUDED == TRUE) fixed_queue_free(p_tcb->sr_cmd.multi_rsp_q, osi_free_func); p_tcb->sr_cmd.multi_rsp_q = NULL; -#endif /* #if (GATTS_INCLUDED) */ +#endif /* #if (GATTS_INCLUDED == TRUE) */ for (i = 0; i < GATT_MAX_APPS; i ++) { p_reg = &gatt_cb.cl_rcb[i]; if (p_reg->in_use && p_reg->app_cb.p_conn_cb) { @@ -2389,7 +2399,9 @@ void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason, tBT_TRANSPORT transport) GATT_TRACE_DEBUG ("exit gatt_cleanup_upon_disc "); BTM_Recovery_Pre_State(); } +#if (GATTS_INCLUDED == TRUE) gatt_delete_dev_from_srv_chg_clt_list(bda); +#endif // (GATTS_INCLUDED == TRUE) } /******************************************************************************* ** @@ -2840,7 +2852,7 @@ BOOLEAN gatt_update_auto_connect_dev (tGATT_IF gatt_if, BOOLEAN add, BD_ADDR bd_ } #endif // #if (tGATT_BG_CONN_DEV == TRUE) - +#if (SMP_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_add_pending_new_srv_start @@ -2858,10 +2870,11 @@ tGATT_PENDING_ENC_CLCB *gatt_add_pending_enc_channel_clcb(tGATT_TCB *p_tcb, tGAT if ((p_buf = (tGATT_PENDING_ENC_CLCB *)osi_malloc((UINT16)sizeof(tGATT_PENDING_ENC_CLCB))) != NULL) { GATT_TRACE_DEBUG ("enqueue a new pending encryption channel clcb"); p_buf->p_clcb = p_clcb; - fixed_queue_enqueue(p_tcb->pending_enc_clcb, p_buf, FIXED_QUEUE_MAX_TIMEOUT); + fixed_queue_enqueue(p_tcb->pending_enc_clcb, p_buf, FIXED_QUEUE_MAX_TIMEOUT); } return p_buf; } +#endif // (SMP_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_update_listen_mode diff --git a/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h b/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h index 8701c746d1..07a0ad5930 100644 --- a/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h +++ b/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h @@ -376,8 +376,11 @@ typedef struct{ }tGATT_PREPARE_WRITE_RECORD; typedef struct { +#if (SMP_INCLUDED == TRUE) fixed_queue_t *pending_enc_clcb; /* pending encryption channel q */ tGATT_SEC_ACTION sec_act; +#endif // (SMP_INCLUDED == TRUE) + BD_ADDR peer_bda; tBT_TRANSPORT transport; UINT32 trans_id; @@ -514,11 +517,11 @@ typedef struct { typedef struct { list_t *p_tcb_list; - fixed_queue_t *sign_op_queue; - +#if (GATTS_INCLUDED == TRUE) tGATT_SR_REG sr_reg[GATT_MAX_SR_PROFILES]; UINT16 next_handle; /* next available handle */ tGATT_SVC_CHG gattp_attr; /* GATT profile attribute service change */ +#endif // (GATTS_INCLUDED == TRUE) tGATT_IF gatt_if; #if (GATTS_INCLUDED == TRUE) tGATT_HDL_LIST_INFO hdl_list_info; @@ -526,13 +529,13 @@ typedef struct { tGATT_SRV_LIST_INFO srv_list_info; tGATT_SRV_LIST_ELEM srv_list[GATT_MAX_SR_PROFILES]; #endif ///GATTS_INCLUDED == TRUE +#if (GATTS_INCLUDED == TRUE) fixed_queue_t *srv_chg_clt_q; /* service change clients queue */ fixed_queue_t *pending_new_srv_start_q; /* pending new service start queue */ +#endif // (GATTS_INCLUDED == TRUE) tGATT_REG cl_rcb[GATT_MAX_APPS]; list_t *p_clcb_list; /* connection link control block*/ - tGATT_SCCB sccb[GATT_MAX_SCCB]; /* sign complete callback function GATT_MAX_SCCB <= GATT_CL_MAX_LCB */ UINT8 trace_level; - UINT16 def_mtu_size; #if GATT_CONFORMANCE_TESTING == TRUE BOOLEAN enable_err_rsp; @@ -556,13 +559,18 @@ typedef struct { tGATT_APPL_INFO cb_info; - +#if (GATTS_INCLUDED == TRUE) tGATT_HDL_CFG hdl_cfg; +#endif // (GATTS_INCLUDED == TRUE) #if (tGATT_BG_CONN_DEV == TRUE) tGATT_BG_CONN_DEV bgconn_dev[GATT_MAX_BG_CONN_DEV]; #endif // #if (tGATT_BG_CONN_DEV == TRUE) +#if (GATTC_INCLUDED == TRUE) BOOLEAN auto_disc; /* internal use: true for auto discovering after connected */ +#endif // (GATTC_INCLUDED == TRUE) +#if (GATTS_INCLUDED == TRUE) UINT8 srv_chg_mode; /* internal use: service change mode */ +#endif // (GATTS_INCLUDED == TRUE) tGATTS_RSP rsp; /* use to read internal service attribute */ } tGATT_CB;