Allow AcquireNotify without CCC 67/245367/1 accepted/tizen/unified/20201029.125002 submit/tizen/20201016.014746 submit/tizen/20201027.003129
authorWootak Jung <wootak.jung@samsung.com>
Thu, 8 Oct 2020 00:57:47 +0000 (09:57 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 8 Oct 2020 00:57:47 +0000 (09:57 +0900)
This patch fixes this behavior so that AcquireNotify
immediately registers the callback and returns success for
characteristics with no CCC

Change-Id: I4077ec021b52cb88cd302a94b5ceaedf15ab833d
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
src/gatt-client.c

index 0b1380b..a96be57 100644 (file)
@@ -1685,6 +1685,12 @@ static DBusMessage *characteristic_acquire_notify(DBusConnection *conn,
        if (!client)
                return btd_error_failed(msg, "Failed allocate notify session");
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       chrc->notify_io = new0(struct sock_io, 1);
+       chrc->notify_io->data = client;
+       chrc->notify_io->msg = dbus_message_ref(msg);
+       chrc->notify_io->destroy = notify_io_destroy;
+#endif
        client->notify_id = bt_gatt_client_register_notify(gatt,
                                                chrc->value_handle,
                                                register_notify_io_cb,
@@ -1692,15 +1698,22 @@ static DBusMessage *characteristic_acquire_notify(DBusConnection *conn,
                                                client, NULL);
        if (!client->notify_id) {
                notify_client_unref(client);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+               dbus_message_unref(chrc->notify_io->msg);
+               g_free(chrc->notify_io);
+               chrc->notify_io = NULL;
+#endif
                return btd_error_failed(msg, "Failed to subscribe");
        }
 
        queue_push_tail(chrc->notify_clients, client);
 
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
        chrc->notify_io = new0(struct sock_io, 1);
        chrc->notify_io->data = client;
        chrc->notify_io->msg = dbus_message_ref(msg);
        chrc->notify_io->destroy = notify_io_destroy;
+#endif
 
        return NULL;
 }