Return-Path: From: Arman Uguray To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, Arman Uguray Subject: [PATCH BlueZ 2/5] core: gatt: Implement GattCharacteristic1.StopNotify Date: Wed, 28 Jan 2015 18:11:00 -0800 Message-Id: <1422497463-32539-3-git-send-email-armansito@chromium.org> In-Reply-To: <1422497463-32539-1-git-send-email-armansito@chromium.org> References: <1422497463-32539-1-git-send-email-armansito@chromium.org> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: This patch implements the StopNotify method of org.bluez.GattCharacteristic1. Change-Id: I2c941c9f1cdbfb1e8a02257b01fc7377b035e28d --- src/gatt-client.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/gatt-client.c b/src/gatt-client.c index 2f187ad..a3cebca 100644 --- a/src/gatt-client.c +++ b/src/gatt-client.c @@ -1165,8 +1165,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) -- 2.2.0.rc0.207.ga3a616c