shared/gatt-client: Add PTS certification logic 46/275046/1
authorWootak Jung <wootak.jung@samsung.com>
Mon, 16 May 2022 01:22:52 +0000 (10:22 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Mon, 16 May 2022 01:23:41 +0000 (10:23 +0900)
Change-Id: Id256ce2dd79bceeb8242b0ae2c93a2262bc4d4e7

src/shared/gatt-client.c

index 1d5112d..376ec2c 100644 (file)
@@ -1783,10 +1783,46 @@ static bool notify_data_write_ccc(struct notify_data *notify_data, bool enable,
                        return false;
        }
 
+#ifndef TIZEN_CERTIFICATE
        att_id = bt_att_send(notify_data->client->att, BT_ATT_OP_WRITE_REQ,
                                                pdu, sizeof(pdu), callback,
                                                notify_data_ref(notify_data),
                                                notify_data_unref);
+#else
+       /* GAP/SEC/SEM/BV-56-C, GAP/SEC/SEM/BV-59-C
+          PTS expects to recieve the sperated value for notify and indicate
+          So seperate the value and send it
+       */
+       bool notify = false;
+       bool indicate = false;
+
+       att_id = 0;
+
+       if (pdu[2] & 0x01)
+               notify = true;
+
+       if (pdu[2] & 0x02)
+               indicate = true;
+
+       if (notify == true) {
+               pdu[2] = 0x01;
+
+               att_id = bt_att_send(notify_data->client->att, BT_ATT_OP_WRITE_REQ,
+                                                       pdu, sizeof(pdu), callback,
+                                                       notify_data_ref(notify_data),
+                                                       notify_data_unref);
+       }
+
+       if (indicate == true) {
+               pdu[2] = 0x02;
+
+               att_id = bt_att_send(notify_data->client->att, BT_ATT_OP_WRITE_REQ,
+                                                       pdu, sizeof(pdu), callback,
+                                                       NULL,
+                                                       NULL);
+       }
+#endif
+
        notify_data->chrc->ccc_write_id = notify_data->att_id = att_id;
 
        return !!att_id;
@@ -1819,6 +1855,11 @@ static void enable_ccc_callback(uint8_t opcode, const void *pdu,
 {
        struct notify_data *notify_data = user_data;
 
+#ifdef TIZEN_CERTIFICATE
+       if (notify_data == NULL)
+               return;
+#endif
+
        assert(notify_data->chrc->ccc_write_id);
 
        notify_data->chrc->ccc_write_id = 0;