mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
component/bt: fix adv stop event bug and add attribute table create
error - Fix bug that advertising stop event produced while calling start_adv function - Modify gatt server adv data and scan rsp data raw setting - add create attribute table error msg - Delete redundant printf in previous commits
This commit is contained in:
parent
65acd99cce
commit
da67773b02
@ -208,6 +208,19 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
||||
uint16_t uuid = 0;
|
||||
future_t *future_p;
|
||||
esp_ble_gatts_cb_param_t param;
|
||||
param.add_attr_tab.status = ESP_GATT_OK;
|
||||
param.add_attr_tab.num_handle = max_nb_attr;
|
||||
|
||||
// To add a large attribute table, need to enlarge BTC_TASK_QUEUE_NUM
|
||||
if (max_nb_attr > BTC_TASK_QUEUE_NUM){
|
||||
param.add_attr_tab.status = ESP_GATT_NO_RESOURCES;
|
||||
}
|
||||
|
||||
if (param.add_attr_tab.status != ESP_GATT_OK){
|
||||
btc_gatts_cb_to_app(ESP_GATTS_CREAT_ATTR_TAB_EVT, gatts_if, ¶m);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//set the attribute table create service flag to true
|
||||
btc_creat_tab_env.is_tab_creat_svc = true;
|
||||
@ -354,8 +367,6 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
||||
|
||||
}
|
||||
|
||||
param.add_attr_tab.status = ESP_GATT_OK;
|
||||
param.add_attr_tab.num_handle = max_nb_attr;
|
||||
param.add_attr_tab.handles = btc_creat_tab_env.handles;
|
||||
memcpy(¶m.add_attr_tab.svc_uuid, &btc_creat_tab_env.svc_uuid, sizeof(esp_bt_uuid_t));
|
||||
|
||||
|
@ -90,7 +90,7 @@ void bta_dm_co_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap, tBTA_OOB_DATA *p_o
|
||||
#endif
|
||||
btif_dm_proc_io_req(bd_addr, p_io_cap, p_oob_data, p_auth_req, is_orig);
|
||||
#else
|
||||
LOG_ERROR("bta_dm_co_io_req: func not ported\n");
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_io_req: func not ported\n");
|
||||
#endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_oob_data = %d", *p_oob_data);
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_io_cap = %d", *p_io_cap);
|
||||
@ -119,7 +119,7 @@ void bta_dm_co_io_rsp(BD_ADDR bd_addr, tBTA_IO_CAP io_cap,
|
||||
#if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE)
|
||||
btif_dm_proc_io_rsp(bd_addr, io_cap, oob_data, auth_req);
|
||||
#else
|
||||
LOG_ERROR("bta_dm_co_io_rsp: func not ported\n");
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_io_rsp: func not ported\n");
|
||||
#endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ void bta_dm_co_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r)
|
||||
btif_dm_proc_loc_oob(valid, c, r);
|
||||
#endif
|
||||
#else
|
||||
LOG_ERROR("bta_dm_co_loc_oob: func not ported\n");
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_loc_oob: func not ported\n");
|
||||
#endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ void bta_dm_co_rmt_oob(BD_ADDR bd_addr)
|
||||
#if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE)
|
||||
result = btif_dm_proc_rmt_oob(bd_addr, p_c, p_r);
|
||||
#else
|
||||
LOG_ERROR("bta_dm_rmt_oob: func not ported\n");
|
||||
BTIF_TRACE_DEBUG("bta_dm_rmt_oob: func not ported\n");
|
||||
#endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */
|
||||
#endif
|
||||
|
||||
@ -370,9 +370,9 @@ void bta_dm_co_le_io_key_req(BD_ADDR bd_addr, UINT8 *p_max_key_size,
|
||||
{
|
||||
UNUSED(bd_addr);
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
BTIF_TRACE_ERROR("##################################");
|
||||
BTIF_TRACE_ERROR("bta_dm_co_le_io_key_req: only setting max size to 16");
|
||||
BTIF_TRACE_ERROR("##################################");
|
||||
BTIF_TRACE_DEBUG("##################################");
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_le_io_key_req: only setting max size to 16");
|
||||
BTIF_TRACE_DEBUG("##################################");
|
||||
*p_max_key_size = 16;
|
||||
*p_init_key = *p_resp_key =
|
||||
(BTA_LE_KEY_PENC | BTA_LE_KEY_PID | BTA_LE_KEY_PCSRK | BTA_LE_KEY_LENC | BTA_LE_KEY_LID | BTA_LE_KEY_LCSRK);
|
||||
@ -403,7 +403,7 @@ void bta_dm_co_ble_load_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OC
|
||||
#endif ///defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
btc_dm_get_ble_local_keys( p_key_mask, er, p_id_keys);
|
||||
LOG_WARN("bta_dm_co_ble_load_local_keys: func not ported\n");
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_ble_load_local_keys: func not ported\n");
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,6 @@ static void bte_main_enable(void)
|
||||
}
|
||||
|
||||
//Now Test Case Not Supported BTU
|
||||
LOG_ERROR("Startup BTU\n");
|
||||
BTU_StartUp();
|
||||
}
|
||||
|
||||
|
@ -1720,7 +1720,7 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced)
|
||||
STREAM_TO_UINT8 (role, p);
|
||||
STREAM_TO_UINT8 (bda_type, p);
|
||||
STREAM_TO_BDADDR (bda, p);
|
||||
BTM_TRACE_ERROR("status = %d, handle = %d, role = %d, bda_type = %d",status,handle,role,bda_type);
|
||||
BTM_TRACE_DEBUG("status = %d, handle = %d, role = %d, bda_type = %d",status,handle,role,bda_type);
|
||||
if (status == 0) {
|
||||
#if (BLE_PRIVACY_SPT == TRUE )
|
||||
peer_addr_type = bda_type;
|
||||
|
@ -1352,7 +1352,7 @@ tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p
|
||||
p_cb_data->p_pad = p;
|
||||
|
||||
if (mask != 0) {
|
||||
BTM_TRACE_ERROR("Partial data write into ADV");
|
||||
BTM_TRACE_DEBUG("Partial data write into ADV");
|
||||
}
|
||||
|
||||
p_cb_data->data_mask &= ~mask;
|
||||
|
@ -326,7 +326,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
|
||||
case HCI_BLE_EVENT:
|
||||
STREAM_TO_UINT8 (ble_sub_code, p);
|
||||
|
||||
HCI_TRACE_ERROR("BLE HCI(id=%d) event = 0x%02x)", hci_evt_code, ble_sub_code);
|
||||
HCI_TRACE_DEBUG("BLE HCI(id=%d) event = 0x%02x)", hci_evt_code, ble_sub_code);
|
||||
|
||||
switch (ble_sub_code) {
|
||||
case HCI_BLE_ADV_PKT_RPT_EVT: /* result of inquiry */
|
||||
|
@ -296,7 +296,7 @@ void gatt_profile_db_init (void)
|
||||
GATT_StartIf(gatt_cb.gatt_if);
|
||||
|
||||
service_handle = GATTS_CreateService (gatt_cb.gatt_if , &uuid, 0, GATTP_MAX_ATTR_NUM, TRUE);
|
||||
GATT_TRACE_ERROR ("GATTS_CreateService: handle of service handle%x", service_handle);
|
||||
GATT_TRACE_DEBUG ("GATTS_CreateService: handle of service handle%x", service_handle);
|
||||
|
||||
/* add Service Changed characteristic
|
||||
*/
|
||||
|
@ -86,7 +86,6 @@ BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
{
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_ERROR("####################adv_type = %d",adv_type);
|
||||
if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS)) == NULL) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
@ -1315,7 +1315,7 @@ UINT8 L2CA_GetChnlFcrMode (UINT16 lcid)
|
||||
*******************************************************************************/
|
||||
BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_REG *p_freg)
|
||||
{
|
||||
L2CAP_TRACE_ERROR ("L2CA_RegisterFixedChannel() CID: 0x%04x, %p", fixed_cid,p_freg);
|
||||
L2CAP_TRACE_DEBUG ("L2CA_RegisterFixedChannel() CID: 0x%04x, %p", fixed_cid,p_freg);
|
||||
if ( (fixed_cid < L2CAP_FIRST_FIXED_CHNL) || (fixed_cid > L2CAP_LAST_FIXED_CHNL) ) {
|
||||
L2CAP_TRACE_ERROR ("L2CA_RegisterFixedChannel() Invalid CID: 0x%04x", fixed_cid);
|
||||
|
||||
|
@ -767,7 +767,7 @@ void l2c_link_processs_ble_num_bufs (UINT16 num_lm_ble_bufs)
|
||||
num_lm_ble_bufs = L2C_DEF_NUM_BLE_BUF_SHARED;
|
||||
l2cb.num_lm_acl_bufs -= L2C_DEF_NUM_BLE_BUF_SHARED;
|
||||
}
|
||||
L2CAP_TRACE_ERROR("#####################################num_lm_ble_bufs = %d",num_lm_ble_bufs);
|
||||
L2CAP_TRACE_DEBUG("#####################################num_lm_ble_bufs = %d",num_lm_ble_bufs);
|
||||
l2cb.num_lm_ble_bufs = l2cb.controller_le_xmit_window = num_lm_ble_bufs;
|
||||
}
|
||||
|
||||
|
@ -63,12 +63,12 @@ esp_attr_value_t gatts_demo_char1_val =
|
||||
|
||||
#ifdef CONFIG_SET_RAW_ADV_DATA
|
||||
static uint8_t raw_adv_data[] = {
|
||||
0x02, 0x01, 0x06, 0x0f, 0x09, 0x45, 0x53, 0x50, 0x5f, 0x47, 0x41, 0x54, 0x54, 0x53, 0x5f, 0x44,
|
||||
0x45, 0x4d, 0x4f, 0x02, 0x0a, 0xeb, 0x03, 0x03, 0xab, 0xcd
|
||||
0x02, 0x01, 0x06,
|
||||
0x02, 0x0a, 0xeb, 0x03, 0x03, 0xab, 0xcd
|
||||
};
|
||||
static uint8_t raw_scan_rsp_data[] = {
|
||||
0x02, 0x01, 0x06, 0x0f, 0x09, 0x45, 0x53, 0x50, 0x5f, 0x47, 0x41, 0x54, 0x54, 0x53, 0x5f, 0x44,
|
||||
0x45, 0x4d, 0x4f, 0x02, 0x0a, 0xeb, 0x03, 0x03, 0xab, 0xcd
|
||||
0x0f, 0x09, 0x45, 0x53, 0x50, 0x5f, 0x47, 0x41, 0x54, 0x54, 0x53, 0x5f, 0x44,
|
||||
0x45, 0x4d, 0x4f
|
||||
};
|
||||
#else
|
||||
static uint8_t test_service_uuid128[32] = {
|
||||
@ -156,6 +156,7 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
|
||||
if (param->adv_start_cmpl.status != ESP_BT_STATUS_SUCCESS) {
|
||||
ESP_LOGE(GATTS_TAG, "Advertising start failed\n");
|
||||
}
|
||||
break;
|
||||
case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT:
|
||||
if (param->adv_stop_cmpl.status != ESP_BT_STATUS_SUCCESS) {
|
||||
ESP_LOGE(GATTS_TAG, "Advertising stop failed\n");
|
||||
|
@ -263,16 +263,21 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event,
|
||||
case ESP_GATTS_CONGEST_EVT:
|
||||
break;
|
||||
case ESP_GATTS_CREAT_ATTR_TAB_EVT:{
|
||||
ESP_LOGE(GATTS_TABLE_TAG, "The number handle =%x\n",param->add_attr_tab.num_handle);
|
||||
if(param->add_attr_tab.num_handle == HRS_IDX_NB){
|
||||
memcpy(heart_rate_handle_table, param->add_attr_tab.handles,
|
||||
sizeof(heart_rate_handle_table));
|
||||
esp_ble_gatts_start_service(heart_rate_handle_table[HRS_IDX_SVC]);
|
||||
}
|
||||
ESP_LOGI(GATTS_TABLE_TAG, "The number handle =%x\n",param->add_attr_tab.num_handle);
|
||||
if (param->add_attr_tab.status != ESP_GATT_OK){
|
||||
ESP_LOGE(GATTS_TABLE_TAG, "Create attribute table failed, error code=0x%x", param->add_attr_tab.status);
|
||||
}
|
||||
else if (param->add_attr_tab.num_handle != HRS_IDX_NB){
|
||||
ESP_LOGE(GATTS_TABLE_TAG, "Create attribute table abnormally, num_handle (%d) \
|
||||
doesn't equal to HRS_IDX_NB(%d)", param->add_attr_tab.num_handle, HRS_IDX_NB);
|
||||
}
|
||||
else {
|
||||
memcpy(heart_rate_handle_table, param->add_attr_tab.handles, sizeof(heart_rate_handle_table));
|
||||
esp_ble_gatts_start_service(heart_rate_handle_table[HRS_IDX_SVC]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user