GATT Server : Handle response_needed by write request & command 61/215761/2
authorDeokhyun Kim <dukan.kim@samsung.com>
Tue, 15 Oct 2019 11:23:34 +0000 (20:23 +0900)
committerDeokhyun Kim <dukan.kim@samsung.com>
Wed, 16 Oct 2019 01:34:03 +0000 (10:34 +0900)
Change-Id: I962b9a512d9114e80ca9b5c39d62f4d76e22fce4
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
src/gatt-database.c

index 1aad011..e612205 100644 (file)
@@ -153,6 +153,9 @@ struct external_desc {
 struct pending_op {
        struct btd_device *device;
        unsigned int id;
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       uint8_t opcode;
+#endif
        uint16_t offset;
        uint8_t link_type;
        struct gatt_db_attribute *attrib;
@@ -2395,7 +2398,7 @@ static void write_setup_cb(DBusMessageIter *iter, void *user_data)
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        char dst_addr[18] = { 0 };
        char *addr_value = dst_addr;
-       gboolean response_needed = TRUE;
+       gboolean response_needed = FALSE;
 
        if (device_get_rpa_exist(op->device) == true) {
                ba2str(device_get_rpa(op->device), dst_addr);
@@ -2406,6 +2409,8 @@ static void write_setup_cb(DBusMessageIter *iter, void *user_data)
        dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &addr_value);
        dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &op->id);
        dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &op->offset);
+       if (op->opcode == BT_ATT_OP_WRITE_REQ)
+               response_needed = TRUE;
        dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &response_needed);
 #endif
 
@@ -2493,6 +2498,9 @@ static struct pending_op *pending_write_new(struct btd_device *device,
                                        struct gatt_db_attribute *attrib,
                                        unsigned int id,
                                        const uint8_t *value, size_t len,
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+                                       uint8_t opcode,
+#endif
                                        uint16_t offset, uint8_t link_type,
                                        bool is_characteristic,
                                        bool prep_authorize)
@@ -2523,6 +2531,9 @@ static struct pending_op *send_write(struct btd_device *device,
                                         struct queue *owner_queue,
                                         unsigned int id,
                                         const uint8_t *value, size_t len,
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+                                       uint8_t opcode,
+#endif
                                        uint16_t offset, uint8_t link_type,
                                        bool is_characteristic,
                                        bool prep_authorize)
@@ -2530,6 +2541,9 @@ static struct pending_op *send_write(struct btd_device *device,
        struct pending_op *op;
 
        op = pending_write_new(device, owner_queue, attrib, id, value, len,
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+                                       opcode,
+#endif
                                        offset, link_type, is_characteristic,
                                        prep_authorize);
 
@@ -2652,7 +2666,11 @@ static void acquire_write_reply(DBusMessage *message, void *user_data)
 
 retry:
        send_write(op->device, op->attrib, chrc->proxy, NULL, op->id,
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+                               op->data.iov_base, op->data.iov_len, 0, 0,
+#else
                                op->data.iov_base, op->data.iov_len, 0,
+#endif
                                op->link_type, false, false);
 }
 
@@ -2690,7 +2708,11 @@ static struct pending_op *acquire_write(struct external_chrc *chrc,
 {
        struct pending_op *op;
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       op = pending_write_new(device, NULL, attrib, id, value, len, 0, 0,
+#else
        op = pending_write_new(device, NULL, attrib, id, value, len, 0,
+#endif
                                                link_type, false, false);
 
        if (g_dbus_proxy_method_call(chrc->proxy, "AcquireWrite",
@@ -3083,6 +3105,9 @@ static void desc_write_cb(struct gatt_db_attribute *attrib,
                                                desc->req_prep_authorization)
                        send_write(device, attrib, desc->proxy,
                                        desc->pending_writes, id, value, len,
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+                                       opcode,
+#endif
                                        offset, bt_att_get_link_type(att),
                                        false, true);
                else
@@ -3095,7 +3120,11 @@ static void desc_write_cb(struct gatt_db_attribute *attrib,
                desc->prep_authorized = false;
 
        if (send_write(device, attrib, desc->proxy, desc->pending_writes, id,
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+                       value, len, opcode, offset, bt_att_get_link_type(att), false,
+#else
                        value, len, offset, bt_att_get_link_type(att), false,
+#endif
                        false))
                return;
 
@@ -3185,7 +3214,11 @@ static void chrc_write_cb(struct gatt_db_attribute *attrib,
                if (!device_is_trusted(device) && !chrc->prep_authorized &&
                                                chrc->req_prep_authorization)
                        send_write(device, attrib, chrc->proxy, queue,
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+                                       id, value, len, opcode, offset,
+#else
                                        id, value, len, offset,
+#endif
                                        bt_att_get_link_type(att), true, true);
                else
                        gatt_db_attribute_write_result(attrib, id, 0);
@@ -3213,6 +3246,9 @@ static void chrc_write_cb(struct gatt_db_attribute *attrib,
        }
 
        if (send_write(device, attrib, chrc->proxy, queue, id, value, len,
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+                       opcode,
+#endif
                        offset, bt_att_get_link_type(att), false, false))
                return;