Merge branch 'opt/opt_ble_log_v5.4' into 'release/v5.4'

feat(ble/bluedroid): Added BLE debug LOG for bluedroid (v5.4)

See merge request espressif/esp-idf!42269
This commit is contained in:
Island
2025-11-18 13:52:00 +08:00
27 changed files with 281 additions and 52 deletions
@@ -2956,6 +2956,15 @@ uint8_t btm_ble_sec_dev_record_count(void)
for (p_node = list_begin(btm_cb.p_sec_dev_rec_list); p_node; p_node = list_next(p_node)) {
p_dev_rec = list_node(p_node);
if (p_dev_rec && (p_dev_rec->sec_flags & BTM_SEC_IN_USE) && (p_dev_rec->ble.key_type != BTM_LE_KEY_NONE)) {
BTM_TRACE_DEBUG("%s BLE security device #%d: bd_addr=%02X:%02X:%02X:%02X:%02X:%02X",
__func__,
count,
p_dev_rec->bd_addr[0],
p_dev_rec->bd_addr[1],
p_dev_rec->bd_addr[2],
p_dev_rec->bd_addr[3],
p_dev_rec->bd_addr[4],
p_dev_rec->bd_addr[5]);
count++;
}
}
@@ -1390,6 +1390,12 @@ uint8_t btm_ble_ext_adv_active_count(void)
for (uint8_t i = 0; i < MAX_BLE_ADV_INSTANCE; i++) {
if (adv_record[i].enabled == true) {
BTM_TRACE_DEBUG("%s EXT ADV active #%d: instance=%d, duration=%d, max_events=%d",
__func__,
count,
adv_record[i].instance,
adv_record[i].duration,
adv_record[i].max_events);
count++;
}
}
@@ -984,6 +984,10 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
*******************************************************************************/
void btm_ble_resolving_list_remove_dev(tBTM_SEC_DEV_REC *p_dev_rec)
{
BTM_TRACE_EVENT ("%s - bd_addr=%02x:%02x:%02x:%02x:%02x:%02x", __func__,
p_dev_rec->bd_addr[0], p_dev_rec->bd_addr[1], p_dev_rec->bd_addr[2],
p_dev_rec->bd_addr[3], p_dev_rec->bd_addr[4], p_dev_rec->bd_addr[5]);
UINT8 rl_mask = btm_cb.ble_ctr_cb.rl_state;
BTM_TRACE_EVENT ("%s\n", __func__);
@@ -335,7 +335,8 @@ tBTM_SEC_DEV_REC *btm_sec_alloc_dev (BD_ADDR bd_addr)
BOOLEAN new_entry_found = FALSE;
BOOLEAN old_entry_found = FALSE;
BOOLEAN malloc_new_entry = FALSE;
BTM_TRACE_EVENT ("btm_sec_alloc_dev\n");
BTM_TRACE_EVENT ("btm_sec_alloc_dev - start alloc for device %02x:%02x:%02x:%02x:%02x:%02x",
bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5]);
for (p_node = list_begin(btm_cb.p_sec_dev_rec_list); p_node; p_node = list_next(p_node)) {
p_dev_old_rec = list_node(p_node);
/* look for old entry which match the bd_addr and the BTM_SEC_IN_USE is cleared */
@@ -691,6 +692,14 @@ tBTM_SEC_DEV_REC *btm_find_oldest_dev (void)
old_ts = p_dev_rec->timestamp;
}
}
if (p_oldest) {
BTM_TRACE_EVENT("oldest paired device found: bd_addr=%02x:%02x:%02x:%02x:%02x:%02x, timestamp=%u",
p_oldest->bd_addr[0], p_oldest->bd_addr[1], p_oldest->bd_addr[2],
p_oldest->bd_addr[3], p_oldest->bd_addr[4], p_oldest->bd_addr[5],
p_oldest->timestamp);
}
return (p_oldest);
}
/*******************************************************************************
@@ -136,6 +136,15 @@ uint8_t btm_ble_acl_active_count(void)
for (p_node = list_begin(btm_cb.p_acl_db_list); p_node; p_node = list_next(p_node)) {
p_acl_conn = list_node(p_node);
if (p_acl_conn && p_acl_conn->in_use && p_acl_conn->transport == BT_TRANSPORT_LE) {
BTM_TRACE_DEBUG("%s LE ACL active #%d: remote_addr=%02X:%02X:%02X:%02X:%02X:%02X",
__func__,
count,
p_acl_conn->remote_addr[0],
p_acl_conn->remote_addr[1],
p_acl_conn->remote_addr[2],
p_acl_conn->remote_addr[3],
p_acl_conn->remote_addr[4],
p_acl_conn->remote_addr[5]);
count++;
}
}
@@ -1128,7 +1128,9 @@ static void btu_hcif_esco_connection_chg_evt (UINT8 *p)
static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_len,
void *p_cplt_cback)
{
#if (BLE_INCLUDED == TRUE)
uint8_t status;
#endif // (BLE_INCLUDED == TRUE)
switch (opcode) {
#if (CLASSIC_BT_INCLUDED == TRUE)
case HCI_INQUIRY_CANCEL:
@@ -1395,10 +1397,6 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC) {
btm_vsc_complete (p, opcode, evt_len, (tBTM_CMPL_CB *)p_cplt_cback);
}
STREAM_TO_UINT8 (status, p);
if(status != HCI_SUCCESS) {
HCI_TRACE_ERROR("CC evt: op=0x%x, status=0x%x", opcode, status);
}
break;
}
}
@@ -1421,6 +1419,10 @@ static void btu_hcif_command_complete_evt_on_task(BT_HDR *event)
uint8_t *stream = hack->response->data + hack->response->offset + 3; // 2 to skip the event headers, 1 to skip the command credits
STREAM_TO_UINT16(opcode, stream);
if (*stream != HCI_SUCCESS) {
HCI_TRACE_WARNING("opcode=0x%04x, status= %02x: %s", opcode, *stream, hci_status_code_to_string(*stream));
}
btu_hcif_hdl_command_complete(
opcode,
stream,
@@ -1506,7 +1508,7 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c
void *p_vsc_status_cback)
{
if (status != HCI_SUCCESS){
HCI_TRACE_WARNING("%s,opcode:0x%04x,status:0x%02x", __func__, opcode,status);
HCI_TRACE_WARNING("opcode=0x%04x, status= %02x: %s", opcode, status, hci_status_code_to_string(status));
}
BD_ADDR bd_addr;
UINT16 handle;
@@ -345,6 +345,15 @@ uint8_t l2cu_ble_plcb_active_count(void)
for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) {
p_lcb = list_node(p_node);
if (p_lcb && p_lcb->in_use && p_lcb->transport == BT_TRANSPORT_LE) {
L2CAP_TRACE_DEBUG("%s LE PLCB active #%d: remote_addr=%02X:%02X:%02X:%02X:%02X:%02X",
__func__,
active_count,
p_lcb->remote_bd_addr[0],
p_lcb->remote_bd_addr[1],
p_lcb->remote_bd_addr[2],
p_lcb->remote_bd_addr[3],
p_lcb->remote_bd_addr[4],
p_lcb->remote_bd_addr[5]);
active_count ++;
}
}
@@ -388,7 +388,7 @@ static const UINT8 smp_master_wait_dhk_check_table[][SMP_SM_NUM_COLS] = {
static const UINT8 smp_master_dhk_check_table[][SMP_SM_NUM_COLS] = {
/* Event Action Next State */
/* locally calculated peer dhkey check is ready -> compare it withs DHKey Check actually received from peer */
/* locally calculated peer dhkey check is ready -> compare it with DHKey Check actually received from peer */
/* SC_KEY_READY */{SMP_MATCH_DHKEY_CHECKS, SMP_SM_NO_ACTION, SMP_STATE_DHK_CHECK},
/* locally calculated peer dhkey check is ready -> calculate STK, go to sending */
/* HCI LE Start Encryption command */
@@ -580,7 +580,7 @@ static const UINT8 smp_slave_wait_dhk_check_table[][SMP_SM_NUM_COLS] = {
static const UINT8 smp_slave_dhk_check_table[][SMP_SM_NUM_COLS] = {
/* Event Action Next State */
/* locally calculated peer dhkey check is ready -> compare it withs DHKey Check */
/* locally calculated peer dhkey check is ready -> compare it with DHKey Check */
/* actually received from peer */
/* SC_KEY_READY */{SMP_MATCH_DHKEY_CHECKS, SMP_SM_NO_ACTION, SMP_STATE_DHK_CHECK},
@@ -771,6 +771,8 @@ void smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data)
/* execute action functions */
for (i = 0; i < SMP_NUM_ACTIONS; i++) {
if ((action = state_table[entry - 1][i]) != SMP_SM_NO_ACTION && smp_sm_action[action] != NULL) {
SMP_TRACE_DEBUG("smp action %d for state %s, event %s",
action, smp_get_state_name(curr_state), smp_get_event_name(event));
(*smp_sm_action[action])(p_cb, (tSMP_INT_DATA *)p_data);
} else {
break;