From: David Krauser Date: Mon, 9 Jul 2018 16:25:01 +0000 (-0400) Subject: gatt: provide MTU in ReadValue and WriteValue X-Git-Tag: submit/tizen/20200220.012900~1^2~1^2~272 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f3c53958c7c5725dd3974d5ec86066e65d454e09;p=platform%2Fupstream%2Fbluez.git gatt: provide MTU in ReadValue and WriteValue This includes the MTU value in ReadValue and WriteValue when acting as a server. Note: The actual data can be bigger than the MTU in case of WriteValue in case of Long Value is written with Prepare + Execute. Change-Id: I718fe7378e5627aaf8c5680d5bf730c9b0f0ce0b Signed-off-by: himanshu --- diff --git a/src/gatt-database.c b/src/gatt-database.c index ea60c9a..b57ed5c 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -2312,7 +2312,9 @@ static void append_options(DBusMessageIter *iter, void *user_data) { struct pending_op *op = user_data; const char *path = device_get_path(op->device); + struct bt_gatt_server *server; const char *link; + uint16_t mtu; switch (op->link_type) { case BT_ATT_LINK_BREDR: @@ -2335,6 +2337,11 @@ static void append_options(DBusMessageIter *iter, void *user_data) if (op->prep_authorize) dict_append_entry(iter, "prepare-authorize", DBUS_TYPE_BOOLEAN, &op->prep_authorize); + + server = btd_device_get_gatt_server(op->device); + mtu = bt_gatt_server_get_mtu(server); + + dict_append_entry(iter, "mtu", DBUS_TYPE_UINT16, &mtu); } static void read_setup_cb(DBusMessageIter *iter, void *user_data) @@ -2682,8 +2689,6 @@ static void acquire_write_setup(DBusMessageIter *iter, void *user_data) { struct pending_op *op = user_data; DBusMessageIter dict; - struct bt_gatt_server *server; - uint16_t mtu; dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING @@ -2694,12 +2699,6 @@ static void acquire_write_setup(DBusMessageIter *iter, void *user_data) append_options(&dict, op); - server = btd_device_get_gatt_server(op->device); - - mtu = bt_gatt_server_get_mtu(server); - - dict_append_entry(&dict, "MTU", DBUS_TYPE_UINT16, &mtu); - dbus_message_iter_close_container(iter, &dict); } @@ -2772,8 +2771,6 @@ static void acquire_notify_setup(DBusMessageIter *iter, void *user_data) { DBusMessageIter dict; struct pending_op *op = user_data; - struct bt_gatt_server *server; - uint16_t mtu; dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING @@ -2784,12 +2781,6 @@ static void acquire_notify_setup(DBusMessageIter *iter, void *user_data) append_options(&dict, op); - server = btd_device_get_gatt_server(op->device); - - mtu = bt_gatt_server_get_mtu(server); - - dict_append_entry(&dict, "MTU", DBUS_TYPE_UINT16, &mtu); - dbus_message_iter_close_container(iter, &dict); }