From 7e772d21953d91f66f7ae3c5cd5c8701a7c5dcf0 Mon Sep 17 00:00:00 2001 From: weitianhua Date: Sat, 23 May 2020 15:11:20 +0800 Subject: [PATCH] Add some debug log for bt: 1. Add logs for SPP not enabled successfully 2. Add information to Applicatioin layer that the A2DP is connecting to peer device Regular BTC and BTU Task name & Add BTC Init protection 1. Regular the BTC Task Name to Close a Github issue Closes https://github.com/espressif/esp-idf/issues/4966 2. Add BTC Init failure protection 3. Regular BTU Task Name with BTC 4. Correct the comment of a. SDP_ServiceSearchRequest and SDP_ServiceSearchRequest2 b. l2cu_create_conn_after_switch 5. Correct comment of esp_bt_hf_vra(); 6. Fix cpp compilier region --- components/bt/common/btc/core/btc_task.c | 6 +++--- .../bt/common/btc/include/btc/btc_task.h | 2 +- .../bt/host/bluedroid/api/esp_bt_main.c | 16 ++++++++++---- .../bluedroid/api/include/api/esp_hf_ag_api.h | 4 ++-- .../bt/host/bluedroid/bta/jv/bta_jv_api.c | 5 ++++- .../bt/host/bluedroid/bta/sys/bta_sys_main.c | 1 - .../bt/host/bluedroid/stack/btu/btu_init.c | 2 +- .../bluedroid/stack/include/stack/a2d_api.h | 21 +++++++++++++++---- .../bluedroid/stack/include/stack/sdp_api.h | 2 +- .../bt/host/bluedroid/stack/l2cap/l2c_utils.c | 2 +- .../bt/host/bluedroid/stack/sdp/sdp_api.c | 7 +++---- 11 files changed, 45 insertions(+), 23 deletions(-) diff --git a/components/bt/common/btc/core/btc_task.c b/components/bt/common/btc/core/btc_task.c index a59df607c0..5367d5ef85 100644 --- a/components/bt/common/btc/core/btc_task.c +++ b/components/bt/common/btc/core/btc_task.c @@ -68,7 +68,7 @@ #define BTC_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE) #define BTC_TASK_STACK_SIZE (BT_BTC_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE) //by menuconfig -#define BTC_TASK_NAME "btcT" +#define BTC_TASK_NAME "BTC_TASK" #define BTC_TASK_PRIO (BT_TASK_MAX_PRIORITIES - 6) osi_thread_t *btc_thread; @@ -331,9 +331,9 @@ error_exit:; } #endif ///BTC_DYNAMIC_MEMORY -int btc_init(void) +bt_status_t btc_init(void) { - btc_thread = osi_thread_create("BTC_TASK", BTC_TASK_STACK_SIZE, BTC_TASK_PRIO, BTC_TASK_PINNED_TO_CORE, 2); + btc_thread = osi_thread_create(BTC_TASK_NAME, BTC_TASK_STACK_SIZE, BTC_TASK_PRIO, BTC_TASK_PINNED_TO_CORE, 2); if (btc_thread == NULL) { return BT_STATUS_NOMEM; } diff --git a/components/bt/common/btc/include/btc/btc_task.h b/components/bt/common/btc/include/btc/btc_task.h index abbbf8110b..e9ee22acec 100644 --- a/components/bt/common/btc/include/btc/btc_task.h +++ b/components/bt/common/btc/include/btc/btc_task.h @@ -98,7 +98,7 @@ typedef void (* btc_arg_deep_copy_t)(btc_msg_t *msg, void *dst, void *src); bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func); -int btc_init(void); +bt_status_t btc_init(void); void btc_deinit(void); bool btc_check_queue_is_congest(void); diff --git a/components/bt/host/bluedroid/api/esp_bt_main.c b/components/bt/host/bluedroid/api/esp_bt_main.c index 8097956d10..f5b758918c 100644 --- a/components/bt/host/bluedroid/api/esp_bt_main.c +++ b/components/bt/host/bluedroid/api/esp_bt_main.c @@ -117,6 +117,7 @@ esp_err_t esp_bluedroid_init(void) { btc_msg_t msg; future_t **future_p; + bt_status_t ret; if (esp_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_ENABLED) { LOG_ERROR("Controller not initialised\n"); @@ -132,12 +133,19 @@ esp_err_t esp_bluedroid_init(void) osi_mem_dbg_init(); #endif - btc_init(); + /* + * BTC Init + */ + ret = btc_init(); + if (ret != BT_STATUS_SUCCESS) { + LOG_ERROR("Bluedroid Initialize Fail"); + return ESP_FAIL; + } future_p = btc_main_get_future_p(BTC_MAIN_INIT_FUTURE); *future_p = future_new(); if (*future_p == NULL) { - LOG_ERROR("Bluedroid initialise failed\n"); + LOG_ERROR("Bluedroid Initialize Fail!"); return ESP_ERR_NO_MEM; } @@ -146,12 +154,12 @@ esp_err_t esp_bluedroid_init(void) msg.act = BTC_MAIN_ACT_INIT; if (btc_transfer_context(&msg, NULL, 0, NULL) != BT_STATUS_SUCCESS) { - LOG_ERROR("Bluedroid initialise failed\n"); + LOG_ERROR("Bluedroid Initialize Fail"); return ESP_FAIL; } if (future_await(*future_p) == FUTURE_FAIL) { - LOG_ERROR("Bluedroid initialise failed\n"); + LOG_ERROR("Bluedroid Initialize Fail"); return ESP_FAIL; } diff --git a/components/bt/host/bluedroid/api/include/api/esp_hf_ag_api.h b/components/bt/host/bluedroid/api/include/api/esp_hf_ag_api.h index f8d6011d8c..80b25d3c97 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_hf_ag_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_hf_ag_api.h @@ -301,8 +301,8 @@ esp_err_t esp_bt_hf_disconnect_audio(esp_bd_addr_t remote_bda); * @brief Response of Volume Recognition Command(AT+VRA) from HFP client. As a precondition to use this API, * Service Level Connection shall exist with HFP client. * - * @param[in] remote_bda: volume control target, speaker or microphone - * @param[in] value: gain of the speaker of microphone, ranges 0 to 15 + * @param[in] remote_bda: the device address of voice recognization initiator + * @param[in] value: 0 - voice recognition disabled, 1- voice recognition enabled * * @return * - ESP_OK: disconnect request is sent to lower layer diff --git a/components/bt/host/bluedroid/bta/jv/bta_jv_api.c b/components/bt/host/bluedroid/bta/jv/bta_jv_api.c index 80277cb060..b0995c0b1b 100644 --- a/components/bt/host/bluedroid/bta/jv/bta_jv_api.c +++ b/components/bt/host/bluedroid/bta/jv/bta_jv_api.c @@ -94,8 +94,11 @@ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback) bta_sys_sendmsg(p_buf); status = BTA_JV_SUCCESS; } + } else if (p_cback == NULL) { + APPL_TRACE_ERROR("No p_cback."); } else { - APPL_TRACE_ERROR("JVenable fails"); + APPL_TRACE_WARNING("No need to Init again."); + // status = BTA_JV_SUCCESS; } return (status); } diff --git a/components/bt/host/bluedroid/bta/sys/bta_sys_main.c b/components/bt/host/bluedroid/bta/sys/bta_sys_main.c index 0fa4813d03..c495e14f09 100644 --- a/components/bt/host/bluedroid/bta/sys/bta_sys_main.c +++ b/components/bt/host/bluedroid/bta/sys/bta_sys_main.c @@ -504,7 +504,6 @@ void bta_sys_event(void * param) if (freebuf) { osi_free(p_msg); } - } /******************************************************************************* diff --git a/components/bt/host/bluedroid/stack/btu/btu_init.c b/components/bt/host/bluedroid/stack/btu/btu_init.c index 430cd65af6..daf5fdadb9 100644 --- a/components/bt/host/bluedroid/stack/btu/btu_init.c +++ b/components/bt/host/bluedroid/stack/btu/btu_init.c @@ -47,7 +47,7 @@ #define BTU_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE) #define BTU_TASK_STACK_SIZE (BT_BTU_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE) #define BTU_TASK_PRIO (BT_TASK_MAX_PRIORITIES - 5) -#define BTU_TASK_NAME "btuT" +#define BTU_TASK_NAME "BTU_TASK" hash_map_t *btu_general_alarm_hash_map; osi_mutex_t btu_general_alarm_lock; diff --git a/components/bt/host/bluedroid/stack/include/stack/a2d_api.h b/components/bt/host/bluedroid/stack/include/stack/a2d_api.h index 466f9fad72..47ed61f31a 100644 --- a/components/bt/host/bluedroid/stack/include/stack/a2d_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/a2d_api.h @@ -236,10 +236,6 @@ extern UINT8 A2D_SetTraceLevel (UINT8 new_level); ******************************************************************************/ extern UINT8 A2D_BitsSet(UINT8 num); -#ifdef __cplusplus -} -#endif - /******************************************************************************* ** ** Function A2D_Init @@ -252,6 +248,23 @@ extern UINT8 A2D_BitsSet(UINT8 num); ** *******************************************************************************/ extern bt_status_t A2D_Init(void); + +/******************************************************************************* +** +** Function A2D_Deinit +** +** Description This function is called at stack startup to free the +** control block (if using dynamic memory), and free the +** control block and tracing level. +** +** Returns void +** +*******************************************************************************/ extern void A2D_Deinit(void); + +#ifdef __cplusplus +} +#endif + #endif ///A2D_INCLUDED #endif /* A2D_API_H */ diff --git a/components/bt/host/bluedroid/stack/include/stack/sdp_api.h b/components/bt/host/bluedroid/stack/include/stack/sdp_api.h index a64e5f2604..70da3182a5 100644 --- a/components/bt/host/bluedroid/stack/include/stack/sdp_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/sdp_api.h @@ -222,7 +222,7 @@ extern BOOLEAN SDP_ServiceSearchRequest (UINT8 *p_bd_addr, ** Description This function queries an SDP server for information. ** ** The difference between this API function and the function -** SDP_ServiceSearchRequest is that this one does a +** SDP_ServiceSearchRequest2 is that this one does a ** combined ServiceSearchAttributeRequest SDP function. ** ** Returns TRUE if discovery started, FALSE if failed. diff --git a/components/bt/host/bluedroid/stack/l2cap/l2c_utils.c b/components/bt/host/bluedroid/stack/l2cap/l2c_utils.c index 3899090e44..21b139e6eb 100644 --- a/components/bt/host/bluedroid/stack/l2cap/l2c_utils.c +++ b/components/bt/host/bluedroid/stack/l2cap/l2c_utils.c @@ -2300,7 +2300,7 @@ UINT8 l2cu_get_num_hi_priority (void) ** Description This function initiates an acl connection via HCI ** If switch required to create connection it is already done. ** -** Returns TRUE if successful, FALSE if gki get buffer fails. +** Returns TRUE if successful, FALSE if osi get buffer fails. ** *******************************************************************************/ diff --git a/components/bt/host/bluedroid/stack/sdp/sdp_api.c b/components/bt/host/bluedroid/stack/sdp/sdp_api.c index 5a2e4f8ba4..0103e4de01 100644 --- a/components/bt/host/bluedroid/stack/sdp/sdp_api.c +++ b/components/bt/host/bluedroid/stack/sdp/sdp_api.c @@ -169,9 +169,8 @@ BOOLEAN SDP_ServiceSearchRequest (UINT8 *p_bd_addr, tSDP_DISCOVERY_DB *p_db, ** Description This function queries an SDP server for information. ** ** The difference between this API function and the function -** SDP_ServiceSearchRequest is that this one does a +** SDP_ServiceSearchRequest2 is that this one does a ** combined ServiceSearchAttributeRequest SDP function. -** (This is for Unplug Testing) ** ** Returns TRUE if discovery started, FALSE if failed. ** @@ -208,8 +207,8 @@ BOOLEAN SDP_ServiceSearchAttributeRequest (UINT8 *p_bd_addr, tSDP_DISCOVERY_DB * ** ** The difference between this API function and the function ** SDP_ServiceSearchRequest is that this one does a -** combined ServiceSearchAttributeRequest SDP function. -** (This is for Unplug Testing) +** combined ServiceSearchAttributeRequest SDP function with the +** user data piggyback ** ** Returns TRUE if discovery started, FALSE if failed. **