OSDN Git Service

Bluetooth: Proper gatt disconnection after ccc process
authorNitin Arora <niarora@codeaurora.org>
Fri, 6 May 2016 22:26:13 +0000 (15:26 -0700)
committerLinux Build Service Account <lnxbuild@localhost>
Wed, 24 Aug 2016 14:09:32 +0000 (08:09 -0600)
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

index 9a2c6fa..fd25fac 100644 (file)
@@ -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);
 }
 
 /*******************************************************************************