From c1c2c3fd672aa9ae5615b4608a098715753fe7d7 Mon Sep 17 00:00:00 2001 From: Nagarjuna Kristam <nkristam@nvidia.com> Date: Tue, 13 Dec 2016 14:30:45 +0530 Subject: [PATCH] Update error check for LE read remote feature event When a BLE remote read remote feature complete event is received initial commands flow is proceeding if error code is not connection failed to establish (0x3E). Instead, the flow should fail on any error. Test: Re-connection stress tests with LE device Change-Id: I4ab80b6601f5f852fcf8da2911807438584fd3f4 --- system/stack/btm/btm_ble_gap.cc | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/system/stack/btm/btm_ble_gap.cc b/system/stack/btm/btm_ble_gap.cc index c75851038dc..8a8627e9f97 100644 --- a/system/stack/btm/btm_ble_gap.cc +++ b/system/stack/btm/btm_ble_gap.cc @@ -2512,29 +2512,28 @@ void btm_ble_refresh_raddr_timer_timeout(UNUSED_ATTR void* data) { * ******************************************************************************/ void btm_ble_read_remote_features_complete(uint8_t* p) { - tACL_CONN* p_acl_cb = &btm_cb.acl_db[0]; + BTM_TRACE_EVENT("%s", __func__); + uint16_t handle; uint8_t status; - int xx; - - BTM_TRACE_EVENT("btm_ble_read_remote_features_complete "); - STREAM_TO_UINT8(status, p); + STREAM_TO_UINT16(handle, p); + handle = handle & 0x0FFF; // only 12 bits meaningful - // if LE read remote feature failed for HCI_ERR_CONN_FAILED_ESTABLISHMENT, - // expect disconnect complete to be received - if (status != HCI_ERR_CONN_FAILED_ESTABLISHMENT) { - STREAM_TO_UINT16(handle, p); + if (status != HCI_SUCCESS) { + BTM_TRACE_ERROR("%s: failed for handle: 0x%04d", __func__, handle); + return; + } - /* Look up the connection by handle and copy features */ - for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_acl_cb++) { - if ((p_acl_cb->in_use) && (p_acl_cb->hci_handle == handle)) { - STREAM_TO_ARRAY(p_acl_cb->peer_le_features, p, BD_FEATURES_LEN); - btsnd_hcic_rmt_ver_req(p_acl_cb->hci_handle); - break; - } - } + int idx = btm_handle_to_acl_index(handle); + if (idx == MAX_L2CAP_LINKS) { + BTM_TRACE_ERROR("%s: can't find acl for handle: 0x%04d", __func__, handle); + return; } + + STREAM_TO_ARRAY(btm_cb.acl_db[idx].peer_le_features, p, BD_FEATURES_LEN); + + btsnd_hcic_rmt_ver_req(handle); } /******************************************************************************* -- GitLab