From 921f650bdb008f621ee16571b0b775979e205db8 Mon Sep 17 00:00:00 2001 From: Nitin Arora Date: Fri, 6 May 2016 15:26:13 -0700 Subject: [PATCH] Bluetooth: Proper gatt disconnection after ccc process This change allows for an operation complete of the client configuration registeration process. In the current code, the successful completion of the process where host writes the client configuration descriptor of the service changed characteristic of the remote device, the connection id (1) is never disconnected. Hence, for those remote devices with the service changed characteristic that allows Indications, there will always be a remaining connection which will prevent disconnection of the remote device. This change fixes that issue and also the issue related to early notifications/registerations causing disconnects of HOGP devices CRs-Fixed: 1014919 Change-Id: I04273f6a1ab5e2d74f49687c9a70670e40db9d39 --- stack/gatt/gatt_attr.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/stack/gatt/gatt_attr.c b/stack/gatt/gatt_attr.c index 9a2c6fa80..fd25facdc 100644 --- a/stack/gatt/gatt_attr.c +++ b/stack/gatt/gatt_attr.c @@ -371,12 +371,27 @@ static void gatt_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGA ** *******************************************************************************/ static void gatt_cl_op_cmpl_cback (UINT16 conn_id, tGATTC_OPTYPE op, - tGATT_STATUS status, tGATT_CL_COMPLETE *p_data) + tGATT_STATUS status, tGATT_CL_COMPLETE *p_data) { - UNUSED(conn_id); - UNUSED(op); - UNUSED(status); - UNUSED(p_data); + tGATT_PROFILE_CLCB *p_clcb = gatt_profile_find_clcb_by_conn_id(conn_id); + + if (p_clcb == NULL) + return; + + if (op == GATTC_OPTYPE_WRITE) + { + GATT_TRACE_DEBUG("%s() - ccc write status : %d", __FUNCTION__, status); + } + + /* Do not disconnect in case of notification or Indication (Unexpected events)*/ + if (op == GATTC_OPTYPE_NOTIFICATION || op == GATTC_OPTYPE_INDICATION) + { + GATT_TRACE_DEBUG("%s: Unexpected event received. Ignore", __func__); + return; + } + + /* free the connection */ + gatt_config_ccc_complete (p_clcb); } /******************************************************************************* -- 2.11.0