Diff between 9bb8fbe51aee36117a760c1f7b5ad33a32e89299 and 3a6b5f5ec14c7b1f06bf7008eb4f7aa00ec65240

Changed Files

File Additions Deletions Status
src/gatt-client.c +22 -0 modified

Full Patch

diff --git a/src/gatt-client.c b/src/gatt-client.c
index 5b10cbf..de18bea 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -104,6 +104,7 @@ struct characteristic {
 	char *path;
 
 	unsigned int ready_id;
+	unsigned int exchange_id;
 	struct sock_io *write_io;
 	struct sock_io *notify_io;
 
@@ -1707,6 +1708,8 @@ static void remove_client(void *data)
 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);
@@ -1723,15 +1726,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);
@@ -1770,6 +1787,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;