Diff between 127f4029df77315caf667253a8b5e23d5e50f080 and 05e877aaca14a2ce3a150bfaf05c3f23a497ccf2

Changed Files

File Additions Deletions Status
src/gatt-client.c +19 -2 modified

Full Patch

diff --git a/src/gatt-client.c b/src/gatt-client.c
index cb98793..98804a3 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -1161,8 +1161,25 @@ static DBusMessage *characteristic_start_notify(DBusConnection *conn,
 static DBusMessage *characteristic_stop_notify(DBusConnection *conn,
 					DBusMessage *msg, void *user_data)
 {
-	/* TODO: Implement */
-	return btd_error_failed(msg, "Not implemented");
+	struct characteristic *chrc = user_data;
+	struct bt_gatt_client *gatt = chrc->service->client->gatt;
+	const char *sender = dbus_message_get_sender(msg);
+	struct notify_client *client;
+
+	if (!chrc->notifying)
+		return btd_error_failed(msg, "Not notifying");
+
+	client = queue_remove_if(chrc->notify_clients, match_notify_sender,
+							(void *) sender);
+	if (!client)
+		return btd_error_failed(msg, "No notify session started");
+
+	bt_gatt_client_unregister_notify(gatt, client->notify_id);
+	update_notifying(chrc);
+
+	notify_client_unref(client);
+
+	return dbus_message_new_method_return(msg);
 }
 
 static void append_desc_path(void *data, void *user_data)