Commit 9c29d08b authored by Priti Aghera's avatar Priti Aghera Committed by Prerepa Viswanadham
Browse files

Avoid premature LE connection notifaction to app

To avoid premature connection notification to app, always wait for
LE read remote feature complete with success before the connection
event is sent to application.
bug 17326529

Change-Id: Id731bf02e8d5d5a68db12e0478b8eb74723eb95d
parent 2bfa490a
No related merge requests found
......@@ -948,7 +948,8 @@ tBTA_GATTC_CLCB * bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg)
bta_gattc_conn_dealloc(p_msg->int_conn.remote_bda);
/* connection attempt timeout, send connection callback event */
if (reason == GATT_CONN_CANCEL || reason == GATT_CONN_L2C_FAILURE)
if (reason == GATT_CONN_CANCEL || reason == GATT_CONN_L2C_FAILURE
|| reason == GATT_CONN_FAIL_ESTABLISH)
{
p_clcb = bta_gattc_find_clcb_by_cif(p_msg->int_conn.client_if,
p_msg->int_conn.remote_bda,
......
......@@ -40,7 +40,6 @@
#include "bd.h"
#include "bt_utils.h"
static void btm_establish_continue (tACL_CONN *p_acl_cb);
static void btm_read_remote_features (UINT16 handle);
static void btm_read_remote_ext_features (UINT16 handle, UINT8 page_number);
static void btm_process_remote_ext_features_page (tACL_CONN *p_acl_cb, tBTM_SEC_DEV_REC *p_dev_rec,
......@@ -374,14 +373,16 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
btm_ble_get_acl_remote_addr (p_dev_rec, p->active_remote_addr,
&p->active_remote_addr_type);
#endif
btm_establish_continue(p);
#if (!defined(BTA_SKIP_BLE_READ_REMOTE_FEAT) || BTA_SKIP_BLE_READ_REMOTE_FEAT == FALSE)
if (link_role == HCI_ROLE_MASTER)
if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(btm_cb.devcb.local_le_features)
|| link_role == HCI_ROLE_MASTER)
{
btsnd_hcic_ble_read_remote_feat(p->hci_handle);
}
else
#endif
btm_establish_continue(p);
}
else
#endif
......@@ -1657,7 +1658,7 @@ void btm_read_remote_ext_features_failed (UINT8 status, UINT16 handle)
** Returns void
**
*******************************************************************************/
static void btm_establish_continue (tACL_CONN *p_acl_cb)
void btm_establish_continue (tACL_CONN *p_acl_cb)
{
#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
tBTM_BL_EVENT_DATA evt_data;
......
......@@ -36,7 +36,7 @@
#endif
#if BLE_INCLUDED == TRUE
#include "l2c_int.h"
#include "vendor_ble.h"
#include "gattdefs.h"
......@@ -2992,21 +2992,26 @@ void btm_ble_read_remote_features_complete(UINT8 *p)
{
tACL_CONN *p_acl_cb = &btm_cb.acl_db[0];
UINT16 handle;
UINT8 status;
int xx;
BTM_TRACE_EVENT ("btm_ble_read_remote_features_complete ");
/* Skip status */
p++;
STREAM_TO_UINT16 (handle, p);
/* Look up the connection by handle and copy features */
for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_acl_cb++)
STREAM_TO_UINT8(status, p);
/* if LE read remote feature failed, expect disconnect complete to be received */
if (status == HCI_SUCCESS)
{
if ((p_acl_cb->in_use) && (p_acl_cb->hci_handle == handle))
STREAM_TO_UINT16 (handle, p);
/* Look up the connection by handle and copy features */
for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_acl_cb++)
{
STREAM_TO_ARRAY(p_acl_cb->peer_le_features, p, BD_FEATURES_LEN);
break;
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);
l2cble_notify_le_connection (p_acl_cb->remote_addr);
break;
}
}
}
......
......@@ -1022,6 +1022,8 @@ extern void btm_read_remote_features_complete (UINT8 *p);
extern void btm_read_remote_ext_features_complete (UINT8 *p);
extern void btm_read_remote_ext_features_failed (UINT8 status, UINT16 handle);
extern void btm_read_remote_version_complete (UINT8 *p);
extern void btm_establish_continue (tACL_CONN *p_acl_cb);
// btla-specific ++
extern void btm_acl_chk_peer_pkt_type_support (tACL_CONN *p, UINT16 *p_pkt_type);
// btla-specific --
......
......@@ -268,6 +268,23 @@ UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transport)
return reason;
}
/*******************************************************************************
**
** Function l2cble_notify_le_connection
**
** Description This function notifiy the l2cap connection to the app layer
**
** Returns none
**
*******************************************************************************/
void l2cble_notify_le_connection (BD_ADDR bda)
{
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr (bda, BT_TRANSPORT_LE);
if (p_lcb != NULL)
l2cu_process_fixed_chnl_resp (p_lcb);
}
/*******************************************************************************
**
** Function l2cble_scanner_conn_comp
......@@ -356,9 +373,14 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type,
/* Tell BTM Acl management about the link */
btm_acl_created (bda, NULL, p_dev_rec->sec_bd_name, handle, p_lcb->link_role, BT_TRANSPORT_LE);
#if(defined(BTA_SKIP_BLE_READ_REMOTE_FEAT) && BTA_SKIP_BLE_READ_REMOTE_FEAT == TRUE)
{
l2cu_process_fixed_chnl_resp (p_lcb);
}
#endif
p_lcb->peer_chnl_mask[0] = L2CAP_FIXED_CHNL_ATT_BIT | L2CAP_FIXED_CHNL_BLE_SIG_BIT | L2CAP_FIXED_CHNL_SMP_BIT;
l2cu_process_fixed_chnl_resp (p_lcb);
btm_ble_set_conn_st(BLE_CONN_IDLE);
}
......@@ -423,7 +445,16 @@ void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE typ
p_lcb->peer_chnl_mask[0] = L2CAP_FIXED_CHNL_ATT_BIT | L2CAP_FIXED_CHNL_BLE_SIG_BIT | L2CAP_FIXED_CHNL_SMP_BIT;
l2cu_process_fixed_chnl_resp (p_lcb);
#if (defined(BTA_SKIP_BLE_READ_REMOTE_FEAT) && BTA_SKIP_BLE_READ_REMOTE_FEAT == TRUE)
{
l2cu_process_fixed_chnl_resp (p_lcb);
}
#else
if (!HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(btm_cb.devcb.local_le_features))
{
l2cu_process_fixed_chnl_resp (p_lcb);
}
#endif
/* when adv and initiating are both active, cancel the direct connection */
if (l2cb.is_ble_connecting && memcmp(bda, l2cb.ble_connecting_bda, BD_ADDR_LEN) == 0)
......
......@@ -768,6 +768,7 @@ extern void l2cble_conn_comp (UINT16 handle, UINT8 role, BD_ADDR bda, tBLE_ADDR_
UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout);
extern BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb);
extern void l2c_enable_conn_param_timeout(tL2C_LCB * p_lcb);
extern void l2cble_notify_le_connection (BD_ADDR bda);
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
extern void l2cble_process_rc_param_request_evt(UINT16 handle, UINT16 int_min, UINT16 int_max,
UINT16 latency, UINT16 timeout);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment