From: Gowtham Anandha Babu Date: Tue, 18 Jul 2017 13:25:08 +0000 (+0530) Subject: [GATT Client] Deliver ATT error code to higher layer X-Git-Tag: accepted/tizen/unified/20170721.201844^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F139375%2F3;p=platform%2Fupstream%2Fbluez.git [GATT Client] Deliver ATT error code to higher layer [Problem] ATT error code is not passed to application. [Cause & Measure] GATT application need to know ATT error code to handling error case. Specially application error code defined by a higher layer specification. [Checking Method] GATT error handling Change-Id: I6b8b689866f630fd40acbc822ca215807534ee60 Signed-off-by: Gowtham Anandha Babu --- diff --git a/src/gatt-client.c b/src/gatt-client.c index 9620ede..85e2367 100644 --- a/src/gatt-client.c +++ b/src/gatt-client.c @@ -285,6 +285,11 @@ static void message_append_byte_array(DBusMessage *msg, const uint8_t *bytes, static DBusMessage *create_gatt_dbus_error(DBusMessage *msg, uint8_t att_ecode) { +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY + return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed", + "Operation failed with ATT error: 0x%02x", + att_ecode); +#else switch (att_ecode) { case BT_ATT_ERROR_READ_NOT_PERMITTED: return btd_error_not_permitted(msg, "Read not permitted"); @@ -311,6 +316,7 @@ static DBusMessage *create_gatt_dbus_error(DBusMessage *msg, uint8_t att_ecode) } return NULL; +#endif } static void write_descriptor_cb(struct gatt_db_attribute *attr, int err, @@ -337,15 +343,9 @@ static void async_dbus_op_reply(struct async_dbus_op *op, int err, DBusMessage *msg = entry->data; if (err) { -#ifndef TIZEN_FEATURE_BLUEZ_MODIFY reply = err > 0 ? create_gatt_dbus_error(msg, err) : btd_error_failed(msg, strerror(-err)); -#else - if (err > 0) - dbus_message_append_args(reply, - DBUS_TYPE_BYTE, &err, - DBUS_TYPE_INVALID); -#endif + goto send_reply; } @@ -355,12 +355,6 @@ static void async_dbus_op_reply(struct async_dbus_op *op, int err, return; } -#ifdef TIZEN_FEATURE_BLUEZ_MODIFY - dbus_message_append_args(reply, - DBUS_TYPE_BYTE, &err, - DBUS_TYPE_INVALID); -#endif - if (length >= 0) message_append_byte_array(reply, value, length); @@ -686,11 +680,7 @@ 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}" }), @@ -1474,24 +1464,16 @@ 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" }, { "options", "a{sv}" }), - GDBUS_ARGS({ "result", "y" }), + NULL, characteristic_write_value_by_type) }, { GDBUS_ASYNC_METHOD("StartNotify", NULL, NULL, characteristic_start_notify) },