From: Luiz Augusto von Dentz Date: Tue, 28 Sep 2021 23:42:58 +0000 (-0700) Subject: gatt: Emit PropertiesChanged("MTU") when MTU is exchanged X-Git-Tag: submit/tizen/20220313.220938~119 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ee7c638a69486dfef6bbcef98d3a893f202488fe;p=platform%2Fupstream%2Fbluez.git gatt: Emit PropertiesChanged("MTU") when MTU is exchanged This notifies client when the ATT MTU changes. Signed-off-by: Anuj Jain Signed-off-by: Ayush Garg --- diff --git a/src/gatt-client.c b/src/gatt-client.c index 64227e23..229b82fa 100644 --- a/src/gatt-client.c +++ b/src/gatt-client.c @@ -111,6 +111,7 @@ struct characteristic { char *path; unsigned int ready_id; + unsigned int exchange_id; struct sock_io *write_io; struct sock_io *notify_io; @@ -1948,6 +1949,8 @@ static const GDBusSignalTable characteristic_signals[] = { static void characteristic_free(void *data) { struct characteristic *chrc = data; + struct bt_gatt_client *gatt = chrc->service->client->gatt; + struct bt_att *att; /* List should be empty here */ queue_destroy(chrc->descs, NULL); @@ -1964,15 +1967,29 @@ static void characteristic_free(void *data) queue_destroy(chrc->notify_clients, remove_client); + att = bt_gatt_client_get_att(gatt); + if (att) + bt_att_unregister_exchange(att, chrc->exchange_id); + g_free(chrc->path); free(chrc); } +static void att_exchange(uint16_t mtu, void *user_data) +{ + struct characteristic *chrc = user_data; + + g_dbus_emit_property_changed(btd_get_dbus_connection(), chrc->path, + GATT_CHARACTERISTIC_IFACE, "MTU"); +} + static struct characteristic *characteristic_create( struct gatt_db_attribute *attr, struct service *service) { struct characteristic *chrc; + struct bt_gatt_client *gatt = service->client->gatt; + struct bt_att *att; bt_uuid_t uuid; chrc = new0(struct characteristic, 1); @@ -2028,6 +2045,11 @@ static struct characteristic *characteristic_create( return NULL; } + att = bt_gatt_client_get_att(gatt); + if (att) + chrc->exchange_id = bt_att_register_exchange(att, att_exchange, + chrc, NULL); + DBG("Exported GATT characteristic: %s", chrc->path); return chrc;