mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
fix(ble/bluedroid): optimize bluedroid host code
This commit is contained in:
@@ -78,9 +78,9 @@ static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data);
|
||||
|
||||
|
||||
static void bta_dm_acl_link_stat_cback(tBTM_ACL_LINK_STAT_EVENT_DATA *p_data);
|
||||
static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
static void bta_dm_encryption_change_cback(BD_ADDR bd_addr, UINT8 enc_mode);
|
||||
static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data);
|
||||
/* Extended Inquiry Response */
|
||||
@@ -540,8 +540,9 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
|
||||
/* initialize bluetooth low power manager */
|
||||
bta_dm_init_pm();
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
bta_sys_policy_register((tBTA_SYS_CONN_CBACK *)bta_dm_policy_cback);
|
||||
#endif // (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE) && (GATTC_INCLUDED == TRUE)
|
||||
bta_dm_gattc_register();
|
||||
@@ -1361,6 +1362,7 @@ void bta_dm_pin_reply (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_policy_cback
|
||||
@@ -1426,7 +1428,7 @@ static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // (CLASSIC_BT_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_confirm
|
||||
|
||||
@@ -257,7 +257,9 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, UINT8 bdn[BTM_MAX_REM_BD_NAME_L
|
||||
#endif
|
||||
BTM_TRACE_DEBUG ("Duplicate btm_acl_created: RemBdAddr: %02x%02x%02x%02x%02x%02x\n",
|
||||
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
BTM_SetLinkPolicy(p->remote_addr, &btm_cb.btm_def_link_policy);
|
||||
#endif // (CLASSIC_BT_INCLUDED == TRUE)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -871,6 +873,7 @@ void btm_acl_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable)
|
||||
}
|
||||
}
|
||||
#endif // (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_SetLinkPolicy
|
||||
@@ -954,7 +957,7 @@ void BTM_SetDefaultLinkPolicy (UINT16 settings)
|
||||
/* Set the default Link Policy of the controller */
|
||||
btsnd_hcic_write_def_policy_set(settings);
|
||||
}
|
||||
|
||||
#endif // (CLASSIC_BT_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_read_remote_version_complete
|
||||
@@ -1260,6 +1263,7 @@ void btm_establish_continue (tACL_CONN *p_acl_cb)
|
||||
tBTM_BL_EVENT_DATA evt_data;
|
||||
BTM_TRACE_DEBUG ("btm_establish_continue\n");
|
||||
#if (!defined(BTM_BYPASS_EXTRA_ACL_SETUP) || BTM_BYPASS_EXTRA_ACL_SETUP == FALSE)
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
|
||||
if (p_acl_cb->transport == BT_TRANSPORT_BR_EDR)
|
||||
#endif
|
||||
@@ -1273,6 +1277,7 @@ void btm_establish_continue (tACL_CONN *p_acl_cb)
|
||||
BTM_SetLinkPolicy (p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
|
||||
}
|
||||
}
|
||||
#endif // (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#endif
|
||||
p_acl_cb->link_up_issued = TRUE;
|
||||
|
||||
|
||||
@@ -69,7 +69,9 @@ static tBTM_BLE_VENDOR_HCI_EVT_CBACK *ble_vs_evt_callback = NULL;
|
||||
** Local functions
|
||||
*******************************************************************************/
|
||||
static void btm_ble_update_adv_flag(UINT8 flag);
|
||||
#if (BLE_42_SCAN_EN == TRUE)
|
||||
static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt_type, UINT8 *p);
|
||||
#endif // (BLE_42_SCAN_EN == TRUE)
|
||||
|
||||
UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst,
|
||||
tBTM_BLE_ADV_DATA *p_data);
|
||||
@@ -414,7 +416,9 @@ tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
|
||||
|
||||
btm_cb.ble_ctr_cb.p_scan_results_cb = p_results_cb;
|
||||
btm_cb.ble_ctr_cb.p_scan_cmpl_cb = p_cmpl_cb;
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
btm_cb.ble_ctr_cb.p_obs_discard_cb = p_discard_cb;
|
||||
#endif // (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
status = BTM_CMD_STARTED;
|
||||
|
||||
/* scan is not started */
|
||||
@@ -3081,7 +3085,6 @@ static void btm_adv_pkt_handler(void *arg)
|
||||
UNUSED(hci_evt_code);
|
||||
UNUSED(hci_evt_len);
|
||||
}
|
||||
#endif // #if (BLE_42_SCAN_EN == TRUE)
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -3348,7 +3351,7 @@ void btm_ble_process_direct_adv_pkt(UINT8 *p)
|
||||
// TODO
|
||||
}
|
||||
|
||||
#if (BLE_42_SCAN_EN == TRUE)
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_ble_start_scan
|
||||
@@ -4030,8 +4033,9 @@ void btm_ble_init (void)
|
||||
BTM_TRACE_DEBUG("%s", __func__);
|
||||
|
||||
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
|
||||
|
||||
#if (BLE_42_SCAN_EN == TRUE)
|
||||
btu_free_timer(&p_cb->scan_timer_ent);
|
||||
#endif // (BLE_42_SCAN_EN == TRUE)
|
||||
btu_free_timer(&p_cb->inq_var.fast_adv_timer);
|
||||
memset(p_cb, 0, sizeof(tBTM_BLE_CB));
|
||||
#if (BLE_TOPOLOGY_CHECK == TRUE)
|
||||
|
||||
@@ -393,7 +393,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;
|
||||
@@ -418,9 +418,9 @@ static void btm_decode_ext_features_page (UINT8 page_number, const BD_FEATURES p
|
||||
} else {
|
||||
btm_cb.btm_def_link_policy &= ~HCI_ENABLE_PARK_MODE;
|
||||
}
|
||||
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
btm_sec_dev_reset ();
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
if (HCI_LMP_INQ_RSSI_SUPPORTED(p_features)) {
|
||||
if (HCI_EXT_INQ_RSP_SUPPORTED(p_features)) {
|
||||
BTM_SetInquiryMode (BTM_INQ_RESULT_EXTENDED);
|
||||
@@ -428,7 +428,7 @@ static void btm_decode_ext_features_page (UINT8 page_number, const BD_FEATURES p
|
||||
BTM_SetInquiryMode (BTM_INQ_RESULT_WITH_RSSI);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
|
||||
if ( HCI_NON_FLUSHABLE_PB_SUPPORTED(p_features)) {
|
||||
l2cu_set_non_flushable_pbf(TRUE);
|
||||
@@ -771,6 +771,7 @@ void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len,
|
||||
tBTM_BLE_CB *ble_cb = &btm_cb.ble_ctr_cb;
|
||||
switch(opcode) {
|
||||
case HCI_VENDOR_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST: {
|
||||
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
|
||||
uint8_t subcode, status; uint32_t length;
|
||||
STREAM_TO_UINT8(status, p);
|
||||
STREAM_TO_UINT8(subcode, p);
|
||||
@@ -779,6 +780,7 @@ void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len,
|
||||
(*ble_cb->update_exceptional_list_cmp_cb)(status, subcode, length, p);
|
||||
}
|
||||
break;
|
||||
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
|
||||
}
|
||||
case HCI_VENDOR_BLE_CLEAR_ADV: {
|
||||
uint8_t status;
|
||||
|
||||
@@ -67,8 +67,9 @@ void btm_init (void)
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
btm_cb.page_queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
btm_cb.sec_pending_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
#endif // (SMP_INCLUDED == TRUE)
|
||||
#if defined(BTM_INITIAL_TRACE_LEVEL)
|
||||
btm_cb.trace_level = BTM_INITIAL_TRACE_LEVEL;
|
||||
#else
|
||||
@@ -88,7 +89,9 @@ void btm_init (void)
|
||||
#if BLE_INCLUDED == TRUE
|
||||
btm_ble_lock_init();
|
||||
btm_ble_sem_init();
|
||||
#if ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
|
||||
btm_cb.addr_res_en = TRUE;
|
||||
#endif // ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
|
||||
#endif
|
||||
btm_sec_dev_init();
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
@@ -114,8 +117,10 @@ 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)
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
fixed_queue_free(btm_cb.sec_pending_q, osi_free_func);
|
||||
#endif // (SMP_INCLUDED == TRUE)
|
||||
btm_acl_free();
|
||||
btm_sec_dev_free();
|
||||
#if BTM_SCO_INCLUDED == TRUE
|
||||
@@ -155,7 +160,7 @@ uint8_t btm_ble_acl_active_count(void)
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#if ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
|
||||
// Address resolution status
|
||||
uint8_t btm_get_ble_addr_resolve_disable_status(void)
|
||||
{
|
||||
@@ -167,4 +172,5 @@ void btm_ble_addr_resolve_enable(bool enable)
|
||||
{
|
||||
btm_cb.addr_res_en = enable;
|
||||
}
|
||||
#endif // ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
|
||||
#endif /*BLE_INCLUDED*/
|
||||
|
||||
@@ -331,15 +331,15 @@ typedef struct {
|
||||
** BLE Inquiry
|
||||
*****************************************************/
|
||||
tBTM_BLE_INQ_CB inq_var;
|
||||
|
||||
#if (BLE_42_SCAN_EN == TRUE)
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
// /* observer callback and timer */
|
||||
tBTM_INQ_DIS_CB *p_obs_discard_cb;
|
||||
|
||||
#endif // (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
/* scan callback and timer */
|
||||
tBTM_INQ_RESULTS_CB *p_scan_results_cb;
|
||||
tBTM_CMPL_CB *p_scan_cmpl_cb;
|
||||
TIMER_LIST_ENT scan_timer_ent;
|
||||
#if (BLE_42_SCAN_EN == TRUE)
|
||||
struct pkt_queue *adv_rpt_queue;
|
||||
struct osi_event *adv_rpt_ready;
|
||||
#endif // #if (BLE_42_SCAN_EN == TRUE)
|
||||
@@ -384,11 +384,15 @@ typedef struct {
|
||||
#if (BLE_TOPOLOGY_CHECK == TRUE)
|
||||
/* current BLE link state */
|
||||
tBTM_BLE_STATE_MASK cur_states; /* bit mask of tBTM_BLE_STATE */
|
||||
#endif // (BLE_TOPOLOGY_CHECK == TRUE)
|
||||
UINT8 link_count[2]; /* total link count master and slave*/
|
||||
#endif // (BLE_TOPOLOGY_CHECK == TRUE)
|
||||
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
|
||||
tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK *update_exceptional_list_cmp_cb;
|
||||
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
|
||||
#if (BLE_VENDOR_HCI_EN == TRUE)
|
||||
tBTM_SET_CSA_SUPPORT_CMPL_CBACK *set_csa_support_cmpl_cb;
|
||||
tBTM_SET_VENDOR_EVT_MASK_CBACK *set_vendor_evt_mask_cmpl_cb;
|
||||
#endif // (BLE_VENDOR_HCI_EN == TRUE)
|
||||
} tBTM_BLE_CB;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -867,8 +867,9 @@ typedef struct {
|
||||
list_t *p_acl_db_list;
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
UINT8 btm_scn[BTM_MAX_SCN]; /* current SCNs: TRUE if SCN is in use */
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
|
||||
UINT16 btm_def_link_policy;
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
UINT16 btm_def_link_super_tout;
|
||||
|
||||
tBTM_ACL_LINK_STAT_CB *p_acl_link_stat_cb; /* Callback for when ACL link related events came */
|
||||
@@ -894,12 +895,15 @@ typedef struct {
|
||||
*****************************************************/
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
tBTM_BLE_CB ble_ctr_cb;
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
UINT16 enc_handle;
|
||||
BT_OCTET8 enc_rand; /* received rand value from LTK request*/
|
||||
UINT16 ediv; /* received ediv value from LTK request */
|
||||
UINT8 key_size;
|
||||
#endif // (SMP_INCLUDED == TRUE)
|
||||
#if ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
|
||||
BOOLEAN addr_res_en; /* internal use for test: address resolution enable/disable */
|
||||
#endif // ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
|
||||
#endif
|
||||
|
||||
/* Packet types supported by the local device */
|
||||
@@ -982,8 +986,12 @@ typedef struct {
|
||||
fixed_queue_t *page_queue;
|
||||
BOOLEAN paging;
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#if (SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE)
|
||||
BOOLEAN discing;
|
||||
#endif // (SMP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE)
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
fixed_queue_t *sec_pending_q; /* pending sequrity requests in tBTM_SEC_QUEUE_ENTRY format */
|
||||
#endif // (SMP_INCLUDED == TRUE)
|
||||
#if (!defined(BT_TRACE_VERBOSE) || (BT_TRACE_VERBOSE == FALSE))
|
||||
char state_temp_buffer[BTM_STATE_BUFFER_SIZE];
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user