From f81d02c4312a649771a3d94897c77453da17b2e8 Mon Sep 17 00:00:00 2001 From: "h.sandeep" Date: Tue, 23 May 2017 22:33:21 +0530 Subject: [PATCH] GATT-Clinet: Fix the Write and read dbus reply parameter mismatch. This patch fixes the dbus reply parameter mismatch issue, in the case where the att request reply is success. Change-Id: I8abc38f55ce94cb0fc1621912ac8a3ac293aff18 Signed-off-by: h.sandeep --- src/gatt-client.c | 57 +++++++++++++++---------------------------------------- 1 file changed, 15 insertions(+), 42 deletions(-) mode change 100755 => 100644 src/gatt-client.c diff --git a/src/gatt-client.c b/src/gatt-client.c old mode 100755 new mode 100644 index fde8ae9..9ed62cf --- a/src/gatt-client.c +++ b/src/gatt-client.c @@ -354,45 +354,11 @@ static void async_dbus_op_reply(struct async_dbus_op *op, int err, return; } - if (length >= 0) - message_append_byte_array(reply, value, length); - -send_reply: - g_dbus_send_message(btd_get_dbus_connection(), reply); - } -} - #ifdef TIZEN_FEATURE_BLUEZ_MODIFY -static void async_dbus_op_write_reply(struct async_dbus_op *op, int err, - const uint8_t *value, ssize_t length) -{ - const struct queue_entry *entry; - DBusMessage *reply; - - op->id = 0; - - for (entry = queue_get_entries(op->msgs); entry; entry = entry->next) { - DBusMessage *msg = entry->data; - - if (err) { - reply = err > 0 ? create_gatt_dbus_error(msg, err) : - btd_error_failed(msg, strerror(-err)); - if (err > 0) - dbus_message_append_args(reply, - DBUS_TYPE_BYTE, &err, - DBUS_TYPE_INVALID); - goto send_reply; - } - - reply = g_dbus_create_reply(msg, DBUS_TYPE_INVALID); - if (!reply) { - error("Failed to allocate D-Bus message reply"); - return; - } - dbus_message_append_args(reply, - DBUS_TYPE_BYTE, &err, - DBUS_TYPE_INVALID); + DBUS_TYPE_BYTE, &err, + DBUS_TYPE_INVALID); +#endif if (length >= 0) message_append_byte_array(reply, value, length); @@ -401,7 +367,6 @@ send_reply: g_dbus_send_message(btd_get_dbus_connection(), reply); } } -#endif static void read_op_cb(struct gatt_db_attribute *attrib, int err, const uint8_t *value, size_t length, @@ -565,11 +530,7 @@ static void write_result_cb(bool success, bool reliable_error, } done: -#ifdef TIZEN_FEATURE_BLUEZ_MODIFY - async_dbus_op_write_reply(op, err, NULL, -1); -#else async_dbus_op_reply(op, err, NULL, -1); -#endif } static void write_cb(bool success, uint8_t att_ecode, void *user_data) @@ -724,7 +685,11 @@ static const GDBusPropertyTable descriptor_properties[] = { static const GDBusMethodTable descriptor_methods[] = { { GDBUS_ASYNC_METHOD("ReadValue", GDBUS_ARGS({ "options", "a{sv}" }), +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY + GDBUS_ARGS({ "value", "yay" }), +#else GDBUS_ARGS({ "value", "ay" }), +#endif descriptor_read_value) }, { GDBUS_ASYNC_METHOD("WriteValue", GDBUS_ARGS({ "value", "ay" }, { "options", "a{sv}" }), @@ -1508,11 +1473,19 @@ static const GDBusPropertyTable characteristic_properties[] = { static const GDBusMethodTable characteristic_methods[] = { { GDBUS_ASYNC_METHOD("ReadValue", GDBUS_ARGS({ "options", "a{sv}" }), +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY + GDBUS_ARGS({ "value", "yay" }), +#else GDBUS_ARGS({ "value", "ay" }), +#endif characteristic_read_value) }, { GDBUS_ASYNC_METHOD("WriteValue", GDBUS_ARGS({ "value", "ay" }, { "options", "a{sv}" }), +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY + GDBUS_ARGS({ "result", "y" }), +#else NULL, +#endif characteristic_write_value) }, { GDBUS_ASYNC_METHOD("WriteValuebyType", GDBUS_ARGS({ "type", "y" }, { "value", "ay" }, -- 2.7.4