Skip to content

Commit 45775a3

Browse files
committed
feat(ble/bluedroid): Added BLE debug LOG for bluedroid
1 parent 9c05973 commit 45775a3

File tree

29 files changed

+286
-55
lines changed

29 files changed

+286
-55
lines changed

components/bt/common/btc/core/btc_alarm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void btc_alarm_handler(btc_msg_t *msg)
1212
{
1313
btc_alarm_args_t *arg = (btc_alarm_args_t *)msg->arg;
1414

15-
BTC_TRACE_DEBUG("%s act %d\n", __FUNCTION__, msg->act);
15+
BTC_TRACE_DEBUG("%s act %d", __func__, msg->act);
1616

1717
if (arg->cb) {
1818
arg->cb(arg->cb_data);

components/bt/host/bluedroid/bta/dm/bta_dm_co.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,15 @@ void bta_dm_co_security_param_init(void)
6363
bte_appl_cfg.ble_min_key_size = BTM_BLE_MIN_KEY_SIZE;
6464
bte_appl_cfg.ble_accept_auth_enable = BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_DISABLE;
6565
bte_appl_cfg.oob_support = BTM_BLE_OOB_DISABLE;
66-
};
66+
67+
APPL_TRACE_DEBUG("%s: auth_req=%u, io_cap=%u, init_key=%u, resp_key=%u, "
68+
"max_key_size=%u, min_key_size=%u, accept_auth=%u, oob=%u",
69+
__func__,
70+
bte_appl_cfg.ble_auth_req, bte_appl_cfg.ble_io_cap,
71+
bte_appl_cfg.ble_init_key, bte_appl_cfg.ble_resp_key,
72+
bte_appl_cfg.ble_max_key_size, bte_appl_cfg.ble_min_key_size,
73+
bte_appl_cfg.ble_accept_auth_enable, bte_appl_cfg.oob_support);
74+
}
6775
#endif
6876

6977
#if (defined CLASSIC_BT_INCLUDED && CLASSIC_BT_INCLUDED == TRUE)
@@ -379,6 +387,7 @@ void bta_dm_co_ble_set_io_cap(UINT8 ble_io_cap)
379387
#if (SMP_INCLUDED == TRUE)
380388
if(ble_io_cap < BTM_IO_CAP_MAX ) {
381389
bte_appl_cfg.ble_io_cap = ble_io_cap;
390+
APPL_TRACE_DEBUG("%s: ble_io_cap set to %u", __func__, ble_io_cap);
382391
} else {
383392
APPL_TRACE_ERROR("%s error:Invalid io cap value.",__func__);
384393
}
@@ -389,22 +398,25 @@ void bta_dm_co_ble_set_auth_req(UINT8 ble_auth_req)
389398
{
390399
#if (SMP_INCLUDED == TRUE)
391400
bte_appl_cfg.ble_auth_req = ble_auth_req;
392-
#endif ///SMP_INCLUDED == TRUE
401+
APPL_TRACE_DEBUG("%s: ble_auth_req set to %u", __func__, ble_auth_req);
402+
#endif
393403
}
394404

395405
void bta_dm_co_ble_set_init_key_req(UINT8 init_key)
396406
{
397407
#if (SMP_INCLUDED == TRUE)
398-
init_key &= 0x0f; // 4~7bit reservd, only used the 0~3bit
408+
init_key &= 0x0f; // 4~7bit reserved, only used the 0~3bit
399409
bte_appl_cfg.ble_init_key = init_key;
400-
#endif ///SMP_INCLUDED == TRUE
410+
APPL_TRACE_DEBUG("%s: init_key set to 0x%x", __func__, init_key);
411+
#endif
401412
}
402413

403414
void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key)
404415
{
405416
#if (SMP_INCLUDED == TRUE)
406-
rsp_key &= 0x0f; // 4~7bit reservd, only used the 0~3bit
417+
rsp_key &= 0x0f; // 4~7bit reserved, only used the 0~3bit
407418
bte_appl_cfg.ble_resp_key = rsp_key;
419+
APPL_TRACE_DEBUG("%s: rsp_key set to 0x%x", __func__, rsp_key);
408420
#endif ///SMP_INCLUDED == TRUE
409421
}
410422

@@ -413,6 +425,7 @@ void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size)
413425
#if (SMP_INCLUDED == TRUE)
414426
if(ble_key_size >= bte_appl_cfg.ble_min_key_size && ble_key_size <= BTM_BLE_MAX_KEY_SIZE) {
415427
bte_appl_cfg.ble_max_key_size = ble_key_size;
428+
APPL_TRACE_DEBUG("%s: max_key_size set to %d", __func__, ble_key_size);
416429
} else {
417430
APPL_TRACE_ERROR("%s error:Invalid key size value, key_size =%d",__func__, ble_key_size);
418431
}
@@ -424,6 +437,7 @@ void bta_dm_co_ble_set_min_key_size(UINT8 ble_key_size)
424437
#if (SMP_INCLUDED == TRUE)
425438
if(ble_key_size >= BTM_BLE_MIN_KEY_SIZE && ble_key_size <= bte_appl_cfg.ble_max_key_size) {
426439
bte_appl_cfg.ble_min_key_size = ble_key_size;
440+
APPL_TRACE_DEBUG("%s: min_key_size set to %u", __func__, ble_key_size);
427441
} else {
428442
APPL_TRACE_ERROR("%s error:Invalid key size value, key_size =%d",__func__, ble_key_size);
429443
}
@@ -437,6 +451,7 @@ void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable)
437451
enable = BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_ENABLE;
438452
}
439453
bte_appl_cfg.ble_accept_auth_enable = enable;
454+
APPL_TRACE_DEBUG("%s: accept_auth_enable set to %u", __func__, enable);
440455
#endif ///SMP_INCLUDED == TRUE
441456
}
442457

@@ -464,6 +479,7 @@ void bta_dm_co_ble_oob_support(UINT8 enable)
464479
} else {
465480
bte_appl_cfg.oob_support = BTM_BLE_OOB_DISABLE;
466481
}
482+
APPL_TRACE_DEBUG("%s: oob_support set to %u", __func__, bte_appl_cfg.oob_support);
467483
#endif ///SMP_INCLUDED == TRUE
468484
}
469485

components/bt/host/bluedroid/bta/gatt/bta_gattc_utils.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
523523
cmd_data->api_write.p_value = (UINT8 *)(cmd_data + 1);
524524
memcpy(cmd_data->api_write.p_value, p_data->api_write.p_value, len);
525525
} else {
526-
APPL_TRACE_ERROR("%s(), line = %d, alloc fail, no memory.", __func__, __LINE__);
526+
APPL_TRACE_ERROR("%s(), line = %d, alloc fail, size %d,no memory. free=%d, largest_block=%d", __func__, __LINE__,
527+
heap_caps_get_free_size(MALLOC_CAP_DEFAULT), heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT));
527528
return FALSE;
528529
}
529530
} else {

components/bt/host/bluedroid/btc/core/btc_dev.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void btc_dev_cb_arg_deep_free(btc_msg_t *msg)
9595

9696
void btc_dev_call_handler(btc_msg_t *msg)
9797
{
98-
BTC_TRACE_DEBUG("%s act %d\n", __FUNCTION__, msg->act);
98+
BTC_TRACE_DEBUG("%s act %d", __func__, msg->act);
9999

100100
switch (msg->act) {
101101
#if (ESP_COEX_VSC_INCLUDED == TRUE)
@@ -117,6 +117,8 @@ void btc_dev_cb_handler(btc_msg_t *msg)
117117
{
118118
esp_bt_dev_cb_param_t *param = (esp_bt_dev_cb_param_t *)msg->arg;
119119

120+
BTC_TRACE_DEBUG("%s act %d", __func__, msg->act);
121+
120122
if (msg->act < ESP_BT_DEV_EVT_MAX) {
121123
btc_dev_cb_to_app(msg->act, param);
122124
} else {

components/bt/host/bluedroid/btc/core/btc_dm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
784784
ble_msg->pid = BTC_PID_GAP_BLE;
785785
// tBTA_SERVICE_MASK service_mask;
786786
BTC_TRACE_DEBUG("btc_dm_upstreams_cback ev: %d\n", msg->act);
787+
BTC_TRACE_DEBUG("%s act %d", __func__, msg->act);
787788

788789
switch (msg->act) {
789790
case BTA_DM_ENABLE_EVT: {

components/bt/host/bluedroid/btc/core/btc_main.c

Lines changed: 61 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static void btc_deinit_bluetooth(void)
9797

9898
void btc_main_call_handler(btc_msg_t *msg)
9999
{
100-
BTC_TRACE_DEBUG("%s act %d\n", __func__, msg->act);
100+
BTC_TRACE_DEBUG("%s act %d", __func__, msg->act);
101101

102102
switch (msg->act) {
103103
case BTC_MAIN_ACT_INIT:
@@ -127,101 +127,132 @@ uint32_t btc_get_ble_status(void)
127127
return status;
128128
}
129129

130-
#if (BLE_INCLUDED == TRUE)
130+
#if (BLE_INCLUDED == TRUE)
131131
// Number of active advertising
132132
extern uint8_t btm_ble_adv_active_count(void);
133-
if (btm_ble_adv_active_count()) {
133+
uint8_t adv_cnt = btm_ble_adv_active_count();
134+
if (adv_cnt) {
135+
BTC_TRACE_WARNING("%s advertising active, cnt %d", __func__, adv_cnt);
134136
status |= BIT(BTC_BLE_STATUS_ADV);
135137
}
136138

137139
// Number of active scanning
138140
extern uint8_t btm_ble_scan_active_count(void);
139-
if (btm_ble_scan_active_count()) {
141+
uint8_t scan_cnt = btm_ble_scan_active_count();
142+
if (scan_cnt) {
143+
BTC_TRACE_WARNING("%s scan active, cnt %d", __func__, scan_cnt);
140144
status |= BIT(BTC_BLE_STATUS_SCAN);
141145
}
142146

143147
// Number of active GATT tcb
144148
extern uint8_t gatt_tcb_active_count(void);
145-
if (gatt_tcb_active_count()) {
149+
uint8_t gatt_tcb_cnt = gatt_tcb_active_count();
150+
if (gatt_tcb_cnt) {
151+
BTC_TRACE_WARNING("%s gatt tcb active, cnt %d", __func__, gatt_tcb_cnt);
146152
status |= BIT(BTC_BLE_STATUS_CONN);
147153
}
148154

149155
// Number of active ACL connection
150156
extern uint8_t btm_ble_acl_active_count(void);
151-
if (btm_ble_acl_active_count()) {
157+
uint8_t acl_cnt = btm_ble_acl_active_count();
158+
if (acl_cnt) {
159+
BTC_TRACE_WARNING("%s acl connection active, cnt %d", __func__, acl_cnt);
152160
status |= BIT(BTC_BLE_STATUS_CONN);
153161
}
154162

155163
// Number of active L2C plcb
156164
extern uint8_t l2cu_ble_plcb_active_count(void);
157-
if (l2cu_ble_plcb_active_count()) {
165+
uint8_t plcb_cnt = l2cu_ble_plcb_active_count();
166+
if (plcb_cnt) {
167+
BTC_TRACE_WARNING("%s l2c plcb active, cnt %d", __func__, plcb_cnt);
158168
status |= BIT(BTC_BLE_STATUS_CONN);
159169
}
160170

161171
// Address resolve status
162172
extern uint8_t btm_get_ble_addr_resolve_disable_status(void);
163-
if (btm_get_ble_addr_resolve_disable_status()) {
173+
uint8_t addr_resolve_disable = btm_get_ble_addr_resolve_disable_status();
174+
if (addr_resolve_disable) {
175+
BTC_TRACE_WARNING("%s address resolve disabled", __func__);
164176
status |= BIT(BTC_BLE_STATUS_ADDR_RESOLVE_DISABLE);
165177
}
166178

167-
#if (SMP_INCLUDED == TRUE)
179+
#if (SMP_INCLUDED == TRUE)
168180
// Number of recorded devices
169181
extern uint8_t btm_ble_sec_dev_record_count(void);
170-
if (btm_ble_sec_dev_record_count()) {
182+
uint8_t sec_dev_cnt = btm_ble_sec_dev_record_count();
183+
if (sec_dev_cnt) {
184+
BTC_TRACE_WARNING("%s security device record count %d", __func__, sec_dev_cnt);
171185
status |= BIT(BTC_BLE_STATUS_DEVICE_REC);
172186
}
173187

174188
// Number of saved bonded devices
175-
if (btc_storage_get_num_ble_bond_devices()) {
189+
int bond_cnt = btc_storage_get_num_ble_bond_devices();
190+
if (bond_cnt) {
191+
BTC_TRACE_WARNING("%s bonded devices count %d", __func__, bond_cnt);
176192
status |= BIT(BTC_BLE_STATUS_BOND);
177193
}
178-
#endif
194+
#endif // SMP_INCLUDED
179195

180-
#if (BLE_PRIVACY_SPT == TRUE)
196+
#if (BLE_PRIVACY_SPT == TRUE)
181197
// Privacy enabled
182198
extern uint8_t btm_ble_privacy_is_enabled(void);
183-
if (btm_ble_privacy_is_enabled()) {
199+
uint8_t privacy_en = btm_ble_privacy_is_enabled();
200+
if (privacy_en) {
201+
BTC_TRACE_WARNING("%s privacy enabled", __func__);
184202
status |= BIT(BTC_BLE_STATUS_PRIVACY);
185203
}
186-
#endif
187-
#endif
204+
#endif // BLE_PRIVACY_SPT
205+
206+
#endif // BLE_INCLUDED
188207

189-
#if (BLE_50_EXTEND_ADV_EN == TRUE)
190-
// Number of active extended advertsing
208+
#if (BLE_50_EXTEND_ADV_EN == TRUE)
209+
// Number of active extended advertising
191210
extern uint8_t btm_ble_ext_adv_active_count(void);
192-
if (btm_ble_ext_adv_active_count()) {
211+
uint8_t ext_adv_cnt = btm_ble_ext_adv_active_count();
212+
if (ext_adv_cnt) {
213+
BTC_TRACE_WARNING("%s extended advertising active, cnt %d", __func__, ext_adv_cnt);
193214
status |= BIT(BTC_BLE_STATUS_EXT_ADV);
194215
}
195-
#endif
216+
#endif // BLE_50_EXTEND_ADV_EN
196217

197-
#if (GATTC_INCLUDED == TRUE)
218+
#if (GATTC_INCLUDED == TRUE)
198219
// Number of registered GATTC APP
199220
extern uint8_t bta_gattc_cl_rcb_active_count(void);
200-
if (bta_gattc_cl_rcb_active_count()) {
221+
uint8_t gattc_app_cnt = bta_gattc_cl_rcb_active_count();
222+
if (gattc_app_cnt) {
223+
BTC_TRACE_WARNING("%s GATTC app active, cnt %d", __func__, gattc_app_cnt);
201224
status |= BIT(BTC_BLE_STATUS_GATTC_APP);
202225
}
203226

204227
// Number of saved GATTC cache
205228
extern UINT8 bta_gattc_co_get_addr_num(void);
206-
if (bta_gattc_co_get_addr_num()) {
229+
uint8_t gattc_cache_cnt = bta_gattc_co_get_addr_num();
230+
if (gattc_cache_cnt) {
231+
BTC_TRACE_WARNING("%s GATTC cache count %d", __func__, gattc_cache_cnt);
207232
status |= BIT(BTC_BLE_STATUS_GATTC_CACHE);
208233
}
209-
#endif
234+
#endif // GATTC_INCLUDED
210235

211-
#if (GATTS_INCLUDED == TRUE)
236+
#if (GATTS_INCLUDED == TRUE)
212237
// Number of registered GATTS service
213238
extern uint8_t bta_gatts_srvc_active_count(void);
214-
if (bta_gatts_srvc_active_count()) {
239+
uint8_t gatts_srvc_cnt = bta_gatts_srvc_active_count();
240+
if (gatts_srvc_cnt) {
241+
BTC_TRACE_WARNING("%s GATTS service active, cnt %d", __func__, gatts_srvc_cnt);
215242
status |= BIT(BTC_BLE_STATUS_GATTS_SRVC);
216243
}
217-
#endif
244+
#endif // GATTS_INCLUDED
218245

219-
#if SMP_INCLUDED == TRUE
246+
#if (SMP_INCLUDED == TRUE)
220247
extern uint8_t smp_get_state(void);
221-
if (smp_get_state()) {
248+
uint8_t smp_state = smp_get_state();
249+
if (smp_state) {
250+
BTC_TRACE_WARNING("%s SMP state active, state=%d", __func__, smp_state);
222251
status |= BIT(BTC_BLE_STATUS_SMP_STATE);
223252
}
224-
#endif
253+
#endif // SMP_INCLUDED
254+
255+
BTC_TRACE_WARNING("%s exit, final status=0x%x", __func__, status);
225256

226257
return status;
227258
}

components/bt/host/bluedroid/btc/core/btc_profile_queue.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ static void queue_int_advance(void)
6262
void btc_profile_queue_handler(btc_msg_t *msg)
6363
{
6464
btc_prf_que_args_t *arg = (btc_prf_que_args_t *)(msg->arg);
65+
66+
BTC_TRACE_DEBUG("%s act %d", __func__, msg->act);
67+
6568
switch (msg->act) {
6669
case BTC_PRF_QUE_CONNECT:
6770
queue_int_add(&(arg->connect_node));

components/bt/host/bluedroid/btc/profile/std/cte/btc_ble_cte.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ void btc_ble_cte_call_handler(btc_msg_t *msg)
339339
#if ((BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE) || (BLE_FEAT_CTE_CONNECTION_EN == TRUE))
340340
btc_ble_cte_args_t *arg = (btc_ble_cte_args_t *)msg->arg;
341341
#endif // #if ((BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE) || (BLE_FEAT_CTE_CONNECTION_EN == TRUE))
342-
BTC_TRACE_DEBUG("%s act %d\n", __FUNCTION__, msg->act);
342+
BTC_TRACE_DEBUG("%s act %d", __func__, msg->act);
343343

344344
switch (msg->act) {
345345
#if (BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE)

components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ static inline void btc_gap_ble_cb_to_app(esp_gap_ble_cb_event_t event, esp_ble_g
6161
esp_gap_ble_cb_t btc_gap_ble_cb = (esp_gap_ble_cb_t)btc_profile_cb_get(BTC_PID_GAP_BLE);
6262
if (btc_gap_ble_cb) {
6363
btc_gap_ble_cb(event, param);
64+
BTC_TRACE_DEBUG("btc_gap_ble_cb_to_app, event=%d", event);
6465
}
6566
}
6667

@@ -1764,6 +1765,8 @@ void btc_gap_ble_cb_handler(btc_msg_t *msg)
17641765
{
17651766
esp_ble_gap_cb_param_t *param = (esp_ble_gap_cb_param_t *)msg->arg;
17661767

1768+
BTC_TRACE_DEBUG("%s act %d", __func__, msg->act);
1769+
17671770
if (msg->act < ESP_GAP_BLE_EVT_MAX) {
17681771
btc_gap_ble_cb_to_app(msg->act, param);
17691772
} else {
@@ -2173,7 +2176,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
21732176
btc_ble_5_gap_args_t *arg_5 = (btc_ble_5_gap_args_t *)msg->arg;
21742177
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
21752178

2176-
BTC_TRACE_DEBUG("%s act %d\n", __FUNCTION__, msg->act);
2179+
BTC_TRACE_DEBUG("%s act %d", __func__, msg->act);
21772180

21782181
switch (msg->act) {
21792182
#if (BLE_42_FEATURE_SUPPORT == TRUE)

components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_bt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,9 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg)
10631063
void btc_gap_bt_call_handler(btc_msg_t *msg)
10641064
{
10651065
btc_gap_bt_args_t *arg = (btc_gap_bt_args_t *)msg->arg;
1066-
BTC_TRACE_DEBUG("%s act %d\n", __func__, msg->act);
1066+
1067+
BTC_TRACE_DEBUG("%s act %d", __func__, msg->act);
1068+
10671069
switch (msg->act) {
10681070
case BTC_GAP_BT_ACT_SET_SCAN_MODE: {
10691071
btc_bt_set_scan_mode(arg->set_scan_mode.c_mode, arg->set_scan_mode.d_mode);

0 commit comments

Comments
 (0)