Diff between bf94ea8e69faa317418c3b8ad2464a7e6d85edfb and 59c07d9d2ab55d28eea8d7ad8806dccf1c57861a

Changed Files

File Additions Deletions Status
src/device.c +2 -2 modified
src/gatt-client.c +31 -4 modified

Full Patch

diff --git a/src/device.c b/src/device.c
index e22f92d..1236698 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2703,7 +2703,7 @@ static void gatt_service_added(struct gatt_db_attribute *attr, void *user_data)
 	if (l)
 		service_accept(l->data);
 
-	store_services(device);
+	store_device_info(device);
 
 	btd_gatt_client_service_added(device->client_dbus, attr);
 }
@@ -2776,7 +2776,7 @@ static void gatt_service_removed(struct gatt_db_attribute *attr,
 
 	g_free(prim);
 
-	store_services(device);
+	store_device_info(device);
 
 	btd_gatt_client_service_removed(device->client_dbus, attr);
 }
diff --git a/src/gatt-client.c b/src/gatt-client.c
index fe51997..a488821 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -1224,6 +1224,11 @@ static void unregister_service(void *data)
 
 static void notify_chrcs(struct service *service)
 {
+
+	if (service->chrcs_ready ||
+				!queue_isempty(service->pending_ext_props))
+		return;
+
 	service->chrcs_ready = true;
 
 	g_dbus_emit_property_changed(btd_get_dbus_connection(), service->path,
@@ -1280,8 +1285,7 @@ static void read_ext_props_cb(bool success, uint8_t att_ecode,
 
 	queue_remove(service->pending_ext_props, chrc);
 
-	if (queue_isempty(service->pending_ext_props))
-		notify_chrcs(service);
+	notify_chrcs(service);
 }
 
 static void read_ext_props(void *data, void *user_data)
@@ -1463,13 +1467,36 @@ void btd_gatt_client_ready(struct btd_gatt_client *client)
 void btd_gatt_client_service_added(struct btd_gatt_client *client,
 					struct gatt_db_attribute *attrib)
 {
-	/* TODO */
+	if (!client)
+		return;
+
+	export_service(attrib, client);
+}
+
+static bool match_service_handle(const void *a, const void *b)
+{
+	const struct service *service = a;
+	uint16_t start_handle = PTR_TO_UINT(b);
+
+	return service->start_handle == start_handle;
 }
 
 void btd_gatt_client_service_removed(struct btd_gatt_client *client,
 					struct gatt_db_attribute *attrib)
 {
-	/* TODO */
+	uint16_t start_handle, end_handle;
+
+	if (!client || !attrib)
+		return;
+
+	gatt_db_attribute_get_service_handles(attrib, &start_handle,
+								&end_handle);
+
+	DBG("GATT Services Removed - start: 0x%04x, end: 0x%04x", start_handle,
+								end_handle);
+	queue_remove_all(client->services, match_service_handle,
+						UINT_TO_PTR(start_handle),
+						unregister_service);
 }
 
 void btd_gatt_client_disconnected(struct btd_gatt_client *client)