Loading system/bta/gatt/bta_gattc_act.cc +1 −1 Original line number Diff line number Diff line Loading @@ -546,7 +546,7 @@ void bta_gattc_close(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { cb_data.close.client_if = p_clcb->p_rcb->client_if; cb_data.close.conn_id = p_clcb->bta_conn_id; cb_data.close.reason = 0; cb_data.close.reason = GATT_CONN_OK; cb_data.close.remote_bda = p_clcb->bda; cb_data.close.status = GATT_SUCCESS; Loading system/bta/gatt/bta_gattc_int.h +1 −3 Original line number Diff line number Diff line Loading @@ -133,13 +133,11 @@ typedef struct { uint16_t cid; } tBTA_GATTC_API_CONFIRM; typedef tGATT_CL_COMPLETE tBTA_GATTC_CMPL; typedef struct { BT_HDR_RIGID hdr; uint8_t op_code; tGATT_STATUS status; tBTA_GATTC_CMPL* p_cmpl; tGATT_CL_COMPLETE* p_cmpl; } tBTA_GATTC_OP_CMPL; typedef struct { Loading system/bta/hh/bta_hh_act.cc +4 −2 Original line number Diff line number Diff line Loading @@ -314,7 +314,8 @@ void bta_hh_start_sdp(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) { p_cb->mode = p_data->api_conn.mode; bta_hh_cb.p_cur = p_cb; if (bta_hh_is_le_device(p_cb, p_data->api_conn.bd_addr)) { if (BTM_UseLeLink(p_data->api_conn.bd_addr)) { p_cb->is_le_device = true; bta_hh_le_open_conn(p_cb, p_data->api_conn.bd_addr); return; } Loading Loading @@ -932,7 +933,8 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) { dev_info.bda = p_dev_info->bda; /* initialize callback data */ if (p_cb->hid_handle == BTA_HH_INVALID_HANDLE) { if (bta_hh_is_le_device(p_cb, p_data->api_conn.bd_addr)) { if (BTM_UseLeLink(p_data->api_conn.bd_addr)) { p_cb->is_le_device = true; dev_info.handle = bta_hh_le_add_device(p_cb, p_dev_info); if (dev_info.handle != BTA_HH_INVALID_HANDLE) dev_info.status = BTA_HH_OK; Loading system/bta/hh/bta_hh_int.h +3 −6 Original line number Diff line number Diff line Loading @@ -130,9 +130,7 @@ typedef struct { typedef struct { BT_HDR_RIGID hdr; uint16_t conn_id; tBTA_GATT_REASON reason; /* disconnect reason code, not useful when connect event is reported */ tGATT_DISCONN_REASON reason; } tBTA_HH_LE_CLOSE; typedef struct { Loading Loading @@ -226,7 +224,7 @@ typedef struct { uint8_t disc_active; tBTA_HH_STATUS status; tBTA_GATT_REASON reason; tBTM_STATUS btm_status; bool is_le_device; tBTA_HH_LE_HID_SRVC hid_srvc; uint16_t conn_id; Loading Loading @@ -310,6 +308,7 @@ extern void bta_hh_open_failure(tBTA_HH_DEV_CB* p_cb, /* utility functions */ extern uint8_t bta_hh_find_cb(const RawAddress& bda); extern tBTA_HH_DEV_CB* bta_hh_get_cb(const RawAddress& bda); extern void bta_hh_parse_keybd_rpt(tBTA_HH_BOOT_RPT* p_kb_data, uint8_t* p_report, uint16_t report_len); extern void bta_hh_parse_mice_rpt(tBTA_HH_BOOT_RPT* p_kb_data, Loading Loading @@ -342,8 +341,6 @@ extern tBTA_HH_STATUS bta_hh_read_ssr_param(const RawAddress& bd_addr, extern void bta_hh_le_enable(void); extern bool bta_hh_le_is_hh_gatt_if(tGATT_IF client_if); extern void bta_hh_le_deregister(void); extern bool bta_hh_is_le_device(tBTA_HH_DEV_CB* p_cb, const RawAddress& remote_bda); extern void bta_hh_le_open_conn(tBTA_HH_DEV_CB* p_cb, const RawAddress& remote_bda); extern void bta_hh_le_api_disc_act(tBTA_HH_DEV_CB* p_cb); Loading system/bta/hh/bta_hh_le.cc +26 −42 Original line number Diff line number Diff line Loading @@ -39,10 +39,16 @@ using bluetooth::Uuid; using std::vector; namespace { #ifndef BTA_HH_LE_RECONN #define BTA_HH_LE_RECONN TRUE constexpr bool kBTA_HH_LE_RECONN = true; #else constexpr bool kBTA_HH_LE_RECONN = false; #endif } // namespace #define BTA_HH_APP_ID_LE 0xff #define BTA_HH_LE_PROTO_BOOT_MODE 0x00 Loading Loading @@ -206,21 +212,6 @@ bool bta_hh_le_is_hh_gatt_if(tGATT_IF client_if) { ******************************************************************************/ void bta_hh_le_deregister(void) { BTA_GATTC_AppDeregister(bta_hh_cb.gatt_if); } /******************************************************************************* * * Function bta_hh_is_le_device * * Description Check to see if the remote device is a LE only device * * Parameters: * ******************************************************************************/ bool bta_hh_is_le_device(tBTA_HH_DEV_CB* p_cb, const RawAddress& remote_bda) { p_cb->is_le_device = BTM_UseLeLink(remote_bda); return p_cb->is_le_device; } /****************************************************************************** * * Function bta_hh_le_get_le_cb Loading Loading @@ -635,11 +626,9 @@ static void bta_hh_le_open_cmpl(tBTA_HH_DEV_CB* p_cb) { bta_hh_le_register_input_notif(p_cb, p_cb->mode, true); bta_hh_sm_execute(p_cb, BTA_HH_OPEN_CMPL_EVT, NULL); #if (BTA_HH_LE_RECONN == TRUE) if (p_cb->status == BTA_HH_OK) { if (kBTA_HH_LE_RECONN && p_cb->status == BTA_HH_OK) { bta_hh_le_add_dev_bg_conn(p_cb, true); } #endif } } Loading Loading @@ -948,17 +937,15 @@ static void bta_hh_le_encrypt_cback(const RawAddress* bd_addr, UNUSED_ATTR tBT_TRANSPORT transport, UNUSED_ATTR void* p_ref_data, tBTM_STATUS result) { uint8_t idx = bta_hh_find_cb(*bd_addr); tBTA_HH_DEV_CB* p_dev_cb; if (idx != BTA_HH_IDX_INVALID) p_dev_cb = &bta_hh_cb.kdev[idx]; else { APPL_TRACE_ERROR("unexpected encryption callback, ignore"); tBTA_HH_DEV_CB* p_dev_cb = bta_hh_get_cb(*bd_addr); if (p_dev_cb == nullptr) { LOG_ERROR("unexpected encryption callback, ignore"); return; } // TODO Collapse the duplicated status values p_dev_cb->status = (result == BTM_SUCCESS) ? BTA_HH_OK : BTA_HH_ERR_SEC; p_dev_cb->reason = result; p_dev_cb->btm_status = result; bta_hh_sm_execute(p_dev_cb, BTA_HH_ENC_CMPL_EVT, NULL); } Loading Loading @@ -1003,9 +990,11 @@ void bta_hh_security_cmpl(tBTA_HH_DEV_CB* p_cb, bta_hh_le_pri_service_discovery(p_cb); } } else { APPL_TRACE_ERROR("%s() - encryption failed; status=0x%04x, reason=0x%04x", __func__, p_cb->status, p_cb->reason); if (!(p_cb->status == BTA_HH_ERR_SEC && p_cb->reason == BTM_ERR_PROCESSING)) LOG_ERROR("Encryption failed status:%s btm_status:%s", bta_hh_status_text(p_cb->status).c_str(), btm_status_text(p_cb->btm_status).c_str()); if (!(p_cb->status == BTA_HH_ERR_SEC && p_cb->btm_status == BTM_ERR_PROCESSING)) bta_hh_le_api_disc_act(p_cb); } } Loading Loading @@ -1618,7 +1607,6 @@ void bta_hh_le_open_fail(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) { * ******************************************************************************/ void bta_hh_gatt_close(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) { tBTA_HH_CBDATA disc_dat = {BTA_HH_OK, 0}; /* deregister all notification */ bta_hh_le_deregister_input_notif(p_cb); Loading @@ -1627,23 +1615,19 @@ void bta_hh_gatt_close(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) { /* update total conn number */ bta_hh_cb.cnt_num--; disc_dat.handle = p_cb->hid_handle; disc_dat.status = p_cb->status; tBTA_HH_CBDATA disc_dat = { .status = p_cb->status, .handle = p_cb->hid_handle, }; (*bta_hh_cb.p_cback)(BTA_HH_CLOSE_EVT, (tBTA_HH*)&disc_dat); /* if no connection is active and HH disable is signaled, disable service */ if (bta_hh_cb.cnt_num == 0 && bta_hh_cb.w4_disable) { bta_hh_disc_cmpl(); } else { #if (BTA_HH_LE_RECONN == TRUE) if (p_data->le_close.reason == HCI_ERR_CONNECTION_TOUT) { } else if (kBTA_HH_LE_RECONN && p_data->le_close.reason == HCI_ERR_CONNECTION_TOUT) { bta_hh_le_add_dev_bg_conn(p_cb, false); } #endif } return; } /******************************************************************************* Loading Loading
system/bta/gatt/bta_gattc_act.cc +1 −1 Original line number Diff line number Diff line Loading @@ -546,7 +546,7 @@ void bta_gattc_close(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { cb_data.close.client_if = p_clcb->p_rcb->client_if; cb_data.close.conn_id = p_clcb->bta_conn_id; cb_data.close.reason = 0; cb_data.close.reason = GATT_CONN_OK; cb_data.close.remote_bda = p_clcb->bda; cb_data.close.status = GATT_SUCCESS; Loading
system/bta/gatt/bta_gattc_int.h +1 −3 Original line number Diff line number Diff line Loading @@ -133,13 +133,11 @@ typedef struct { uint16_t cid; } tBTA_GATTC_API_CONFIRM; typedef tGATT_CL_COMPLETE tBTA_GATTC_CMPL; typedef struct { BT_HDR_RIGID hdr; uint8_t op_code; tGATT_STATUS status; tBTA_GATTC_CMPL* p_cmpl; tGATT_CL_COMPLETE* p_cmpl; } tBTA_GATTC_OP_CMPL; typedef struct { Loading
system/bta/hh/bta_hh_act.cc +4 −2 Original line number Diff line number Diff line Loading @@ -314,7 +314,8 @@ void bta_hh_start_sdp(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) { p_cb->mode = p_data->api_conn.mode; bta_hh_cb.p_cur = p_cb; if (bta_hh_is_le_device(p_cb, p_data->api_conn.bd_addr)) { if (BTM_UseLeLink(p_data->api_conn.bd_addr)) { p_cb->is_le_device = true; bta_hh_le_open_conn(p_cb, p_data->api_conn.bd_addr); return; } Loading Loading @@ -932,7 +933,8 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) { dev_info.bda = p_dev_info->bda; /* initialize callback data */ if (p_cb->hid_handle == BTA_HH_INVALID_HANDLE) { if (bta_hh_is_le_device(p_cb, p_data->api_conn.bd_addr)) { if (BTM_UseLeLink(p_data->api_conn.bd_addr)) { p_cb->is_le_device = true; dev_info.handle = bta_hh_le_add_device(p_cb, p_dev_info); if (dev_info.handle != BTA_HH_INVALID_HANDLE) dev_info.status = BTA_HH_OK; Loading
system/bta/hh/bta_hh_int.h +3 −6 Original line number Diff line number Diff line Loading @@ -130,9 +130,7 @@ typedef struct { typedef struct { BT_HDR_RIGID hdr; uint16_t conn_id; tBTA_GATT_REASON reason; /* disconnect reason code, not useful when connect event is reported */ tGATT_DISCONN_REASON reason; } tBTA_HH_LE_CLOSE; typedef struct { Loading Loading @@ -226,7 +224,7 @@ typedef struct { uint8_t disc_active; tBTA_HH_STATUS status; tBTA_GATT_REASON reason; tBTM_STATUS btm_status; bool is_le_device; tBTA_HH_LE_HID_SRVC hid_srvc; uint16_t conn_id; Loading Loading @@ -310,6 +308,7 @@ extern void bta_hh_open_failure(tBTA_HH_DEV_CB* p_cb, /* utility functions */ extern uint8_t bta_hh_find_cb(const RawAddress& bda); extern tBTA_HH_DEV_CB* bta_hh_get_cb(const RawAddress& bda); extern void bta_hh_parse_keybd_rpt(tBTA_HH_BOOT_RPT* p_kb_data, uint8_t* p_report, uint16_t report_len); extern void bta_hh_parse_mice_rpt(tBTA_HH_BOOT_RPT* p_kb_data, Loading Loading @@ -342,8 +341,6 @@ extern tBTA_HH_STATUS bta_hh_read_ssr_param(const RawAddress& bd_addr, extern void bta_hh_le_enable(void); extern bool bta_hh_le_is_hh_gatt_if(tGATT_IF client_if); extern void bta_hh_le_deregister(void); extern bool bta_hh_is_le_device(tBTA_HH_DEV_CB* p_cb, const RawAddress& remote_bda); extern void bta_hh_le_open_conn(tBTA_HH_DEV_CB* p_cb, const RawAddress& remote_bda); extern void bta_hh_le_api_disc_act(tBTA_HH_DEV_CB* p_cb); Loading
system/bta/hh/bta_hh_le.cc +26 −42 Original line number Diff line number Diff line Loading @@ -39,10 +39,16 @@ using bluetooth::Uuid; using std::vector; namespace { #ifndef BTA_HH_LE_RECONN #define BTA_HH_LE_RECONN TRUE constexpr bool kBTA_HH_LE_RECONN = true; #else constexpr bool kBTA_HH_LE_RECONN = false; #endif } // namespace #define BTA_HH_APP_ID_LE 0xff #define BTA_HH_LE_PROTO_BOOT_MODE 0x00 Loading Loading @@ -206,21 +212,6 @@ bool bta_hh_le_is_hh_gatt_if(tGATT_IF client_if) { ******************************************************************************/ void bta_hh_le_deregister(void) { BTA_GATTC_AppDeregister(bta_hh_cb.gatt_if); } /******************************************************************************* * * Function bta_hh_is_le_device * * Description Check to see if the remote device is a LE only device * * Parameters: * ******************************************************************************/ bool bta_hh_is_le_device(tBTA_HH_DEV_CB* p_cb, const RawAddress& remote_bda) { p_cb->is_le_device = BTM_UseLeLink(remote_bda); return p_cb->is_le_device; } /****************************************************************************** * * Function bta_hh_le_get_le_cb Loading Loading @@ -635,11 +626,9 @@ static void bta_hh_le_open_cmpl(tBTA_HH_DEV_CB* p_cb) { bta_hh_le_register_input_notif(p_cb, p_cb->mode, true); bta_hh_sm_execute(p_cb, BTA_HH_OPEN_CMPL_EVT, NULL); #if (BTA_HH_LE_RECONN == TRUE) if (p_cb->status == BTA_HH_OK) { if (kBTA_HH_LE_RECONN && p_cb->status == BTA_HH_OK) { bta_hh_le_add_dev_bg_conn(p_cb, true); } #endif } } Loading Loading @@ -948,17 +937,15 @@ static void bta_hh_le_encrypt_cback(const RawAddress* bd_addr, UNUSED_ATTR tBT_TRANSPORT transport, UNUSED_ATTR void* p_ref_data, tBTM_STATUS result) { uint8_t idx = bta_hh_find_cb(*bd_addr); tBTA_HH_DEV_CB* p_dev_cb; if (idx != BTA_HH_IDX_INVALID) p_dev_cb = &bta_hh_cb.kdev[idx]; else { APPL_TRACE_ERROR("unexpected encryption callback, ignore"); tBTA_HH_DEV_CB* p_dev_cb = bta_hh_get_cb(*bd_addr); if (p_dev_cb == nullptr) { LOG_ERROR("unexpected encryption callback, ignore"); return; } // TODO Collapse the duplicated status values p_dev_cb->status = (result == BTM_SUCCESS) ? BTA_HH_OK : BTA_HH_ERR_SEC; p_dev_cb->reason = result; p_dev_cb->btm_status = result; bta_hh_sm_execute(p_dev_cb, BTA_HH_ENC_CMPL_EVT, NULL); } Loading Loading @@ -1003,9 +990,11 @@ void bta_hh_security_cmpl(tBTA_HH_DEV_CB* p_cb, bta_hh_le_pri_service_discovery(p_cb); } } else { APPL_TRACE_ERROR("%s() - encryption failed; status=0x%04x, reason=0x%04x", __func__, p_cb->status, p_cb->reason); if (!(p_cb->status == BTA_HH_ERR_SEC && p_cb->reason == BTM_ERR_PROCESSING)) LOG_ERROR("Encryption failed status:%s btm_status:%s", bta_hh_status_text(p_cb->status).c_str(), btm_status_text(p_cb->btm_status).c_str()); if (!(p_cb->status == BTA_HH_ERR_SEC && p_cb->btm_status == BTM_ERR_PROCESSING)) bta_hh_le_api_disc_act(p_cb); } } Loading Loading @@ -1618,7 +1607,6 @@ void bta_hh_le_open_fail(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) { * ******************************************************************************/ void bta_hh_gatt_close(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) { tBTA_HH_CBDATA disc_dat = {BTA_HH_OK, 0}; /* deregister all notification */ bta_hh_le_deregister_input_notif(p_cb); Loading @@ -1627,23 +1615,19 @@ void bta_hh_gatt_close(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) { /* update total conn number */ bta_hh_cb.cnt_num--; disc_dat.handle = p_cb->hid_handle; disc_dat.status = p_cb->status; tBTA_HH_CBDATA disc_dat = { .status = p_cb->status, .handle = p_cb->hid_handle, }; (*bta_hh_cb.p_cback)(BTA_HH_CLOSE_EVT, (tBTA_HH*)&disc_dat); /* if no connection is active and HH disable is signaled, disable service */ if (bta_hh_cb.cnt_num == 0 && bta_hh_cb.w4_disable) { bta_hh_disc_cmpl(); } else { #if (BTA_HH_LE_RECONN == TRUE) if (p_data->le_close.reason == HCI_ERR_CONNECTION_TOUT) { } else if (kBTA_HH_LE_RECONN && p_data->le_close.reason == HCI_ERR_CONNECTION_TOUT) { bta_hh_le_add_dev_bg_conn(p_cb, false); } #endif } return; } /******************************************************************************* Loading