OSDN Git Service

Process Gatt read multiple response properly
authorSubramanian Srinivasan <subrsrin@codeaurora.org>
Mon, 16 May 2016 18:14:03 +0000 (11:14 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Fri, 15 Jul 2016 17:18:36 +0000 (10:18 -0700)
The Gatt server multi response queue is made NULL after each Gatt
server response is sent by BT stack in response to the remote Gatt
client's request. But the multi response queue is not initialized
again to process subsequent read multiple Gatt server responses.
Hence, the BT stack does not send Gatt server responses for the
subsequent read multiple requests from remote device which inturn
leads to disconnection. This change would process read multiple
responses by initializing the queue when it is null.

Some of Bluetooth certification test cases involve testing
Gatt server's capability to process and send read multiple
response.

Test case: TC_GAR_SR_BV_05_C

This change also cleans up unnecessary initialization and freeing
of multi rsp queue. This change makes sure that the stack initializes
multi rsp queue only when it is necessary(ie only when the Gatt
multiple read response is being processed).

Bug: 29011255

Change-Id: Ia3e2e1569ee16cac9c518f95501945257b9fb7fd
(cherry picked from commit 3737592a7846766083041e81d72a2fab0b27fb38)

stack/gatt/gatt_main.c
stack/gatt/gatt_sr.c
stack/gatt/gatt_utils.c

index bda5b41..8bbd650 100644 (file)
@@ -403,7 +403,6 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT trans
                 GATT_TRACE_ERROR("gatt_connect failed");
                 fixed_queue_free(p_tcb->pending_enc_clcb, NULL);
                 fixed_queue_free(p_tcb->pending_ind_q, NULL);
-                fixed_queue_free(p_tcb->sr_cmd.multi_rsp_q, NULL);
                 memset(p_tcb, 0, sizeof(tGATT_TCB));
             }
             else
index f5c5f0f..11ef79c 100644 (file)
@@ -122,13 +122,16 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
                                        tGATTS_RSP *p_msg, UINT16 mtu)
 {
     UINT16          ii, total_len, len;
-    BT_HDR          *p_buf = (BT_HDR *)osi_malloc(sizeof(tGATTS_RSP));
     UINT8           *p;
     BOOLEAN         is_overflow = FALSE;
 
-    GATT_TRACE_DEBUG ("process_read_multi_rsp status=%d mtu=%d", status, mtu);
+    GATT_TRACE_DEBUG ("%s status=%d mtu=%d", __func__, status, mtu);
+
+    if (p_cmd->multi_rsp_q == NULL)
+        p_cmd->multi_rsp_q = fixed_queue_new(SIZE_MAX);
 
     /* Enqueue the response */
+    BT_HDR  *p_buf = (BT_HDR *)osi_malloc(sizeof(tGATTS_RSP));
     memcpy((void *)p_buf, (const void *)p_msg, sizeof(tGATTS_RSP));
     fixed_queue_enqueue(p_cmd->multi_rsp_q, p_buf);
 
index f56925d..c2db770 100644 (file)
@@ -972,7 +972,6 @@ tGATT_TCB * gatt_allocate_tcb_by_bdaddr(BD_ADDR bda, tBT_TRANSPORT transport)
             p_tcb->pending_ind_q = fixed_queue_new(SIZE_MAX);
             p_tcb->conf_timer = alarm_new("gatt.conf_timer");
             p_tcb->ind_ack_timer = alarm_new("gatt.ind_ack_timer");
-            p_tcb->sr_cmd.multi_rsp_q = fixed_queue_new(SIZE_MAX);
             p_tcb->in_use = TRUE;
             p_tcb->tcb_idx = i;
             p_tcb->transport = transport;