gatt-client: Add debug logs 82/307382/5 accepted/tizen/7.0/unified/20240308.120333
authorWootak Jung <wootak.jung@samsung.com>
Thu, 7 Mar 2024 23:35:40 +0000 (08:35 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Fri, 8 Mar 2024 02:39:41 +0000 (11:39 +0900)
Change-Id: Id46df448a9bf77b00ae6168dd04b0e4f38fa3ebe
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
src/gatt-client.c

index 0759b098bae1c8e63c365472058c8b9cc2720b84..50f775a4219d0711bf7a5bd8516349b6036b43e0 100644 (file)
@@ -1502,6 +1502,10 @@ static void notify_client_disconnect(DBusConnection *conn, void *user_data)
 
        queue_remove(chrc->notify_clients, client);
        queue_remove(chrc->service->client->all_notify_clients, client);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       DBG("Removed client from notify_clients. length: %d", queue_length(chrc->notify_clients));
+       DBG("Removed client from all_notify_clients. length: %d", queue_length(chrc->service->client->all_notify_clients));
+#endif
 
        update_notifying(chrc);
 
@@ -1608,6 +1612,10 @@ static void register_notify_cb(uint16_t att_ecode, void *user_data)
        if (att_ecode) {
                queue_remove(chrc->notify_clients, client);
                queue_remove(chrc->service->client->all_notify_clients, client);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+               DBG("Removed client from notify_clients. length: %d", queue_length(chrc->notify_clients));
+               DBG("Removed client from all_notify_clients. length: %d", queue_length(chrc->service->client->all_notify_clients));
+#endif
                notify_client_free(client);
 
                create_notify_reply(op, false, att_ecode);
@@ -1658,6 +1666,9 @@ static void register_notify_io_cb(uint16_t att_ecode, void *user_data)
 
        if (att_ecode) {
                queue_remove(chrc->notify_clients, client);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+               DBG("Removed client from notify_clients. length: %d", queue_length(chrc->notify_clients));
+#endif
                notify_client_free(client);
                return;
        }
@@ -1677,8 +1688,18 @@ static void notify_io_destroy(void *data)
 {
        struct notify_client *client = data;
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       DBG("notify_io destroyed. length: %d", queue_length(client->chrc->notify_clients));
+       if (queue_remove(client->chrc->notify_clients, client)) {
+               DBG("Removed client from notify_clients. length: %d", queue_length(client->chrc->notify_clients));
+               notify_client_unref(client);
+       } else {
+               DBG("Failed to remove client");
+       }
+#else
        if (queue_remove(client->chrc->notify_clients, client))
                notify_client_unref(client);
+#endif
 }
 
 static DBusMessage *characteristic_acquire_notify(DBusConnection *conn,
@@ -1728,6 +1749,10 @@ static DBusMessage *characteristic_acquire_notify(DBusConnection *conn,
        }
 
        queue_push_tail(chrc->notify_clients, client);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       DBG("Registered noti with id: %d", client->notify_id);
+       DBG("Added client to notify_clients. length: %d", queue_length(chrc->notify_clients));
+#endif
 
 #ifndef TIZEN_FEATURE_BLUEZ_MODIFY
        chrc->notify_io = new0(struct sock_io, 1);
@@ -1774,6 +1799,10 @@ static DBusMessage *characteristic_start_notify(DBusConnection *conn,
 
        queue_push_tail(chrc->notify_clients, client);
        queue_push_tail(chrc->service->client->all_notify_clients, client);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       DBG("Added client to notify_clients. length: %d", queue_length(chrc->notify_clients));
+       DBG("Added client to all_notify_clients. length: %d", queue_length(chrc->service->client->all_notify_clients));
+#endif
 
        /*
         * If the device is currently not connected, return success. We will
@@ -1801,14 +1830,25 @@ static DBusMessage *characteristic_start_notify(DBusConnection *conn,
                                                chrc->value_handle,
                                                register_notify_cb, notify_cb,
                                                op, async_dbus_op_free);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       if (client->notify_id) {
+               DBG("Registered noti with id: %d", client->notify_id);
+               return NULL;
+       }
+#else
        if (client->notify_id)
                return NULL;
+#endif
 
        async_dbus_op_free(op);
 
 fail:
        queue_remove(chrc->notify_clients, client);
        queue_remove(chrc->service->client->all_notify_clients, client);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       DBG("Removed client from notify_clients. length: %d", queue_length(chrc->notify_clients));
+       DBG("Removed client from all_notify_clients. length: %d", queue_length(chrc->service->client->all_notify_clients));
+#endif
 
        /* Directly free the client */
        notify_client_free(client);
@@ -1836,6 +1876,11 @@ static DBusMessage *characteristic_stop_notify(DBusConnection *conn,
                return btd_error_failed(msg, "No notify session started");
 
        queue_remove(chrc->service->client->all_notify_clients, client);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       DBG("Removed client from notify_clients. length: %d", queue_length(chrc->notify_clients));
+       DBG("Removed client from all_notify_clients. length: %d", queue_length(chrc->service->client->all_notify_clients));
+       DBG("Unregister noti with id: %d", client->notify_id);
+#endif
        bt_gatt_client_unregister_notify(gatt, client->notify_id);
        update_notifying(chrc);
 
@@ -1971,6 +2016,9 @@ static void characteristic_free(void *data)
        }
 
        queue_destroy(chrc->notify_clients, remove_client);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       DBG("Destroyed notify_clients. length: %d", queue_length(chrc->notify_clients));
+#endif
 
        att = bt_gatt_client_get_att(gatt);
        if (att)
@@ -2056,6 +2104,11 @@ static struct characteristic *characteristic_create(
                                                                chrc, NULL);
 
        DBG("Exported GATT characteristic: %s", chrc->path);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       char uuid_str[MAX_LEN_UUID_STR + 1];
+       bt_uuid_to_string(&uuid, uuid_str, sizeof(uuid_str));
+       DBG("- uuid: %s", uuid_str);
+#endif
 
        return chrc;
 }
@@ -2576,6 +2629,10 @@ static void register_notify(void *data, void *user_data)
 
        queue_remove(notify_client->chrc->notify_clients, notify_client);
        queue_remove(client->all_notify_clients, notify_client);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       DBG("Removed client from notify_clients. lenth: %d", queue_length(notify_client->chrc->notify_clients));
+       DBG("Removed client from all_notify_clients. length: %d", queue_length(client->all_notify_clients));
+#endif
 
        notify_client_free(notify_client);
 }
@@ -2821,6 +2878,10 @@ static void clear_notify_id(void *data, void *user_data)
 {
        struct notify_client *client = data;
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       DBG("Unregister noti with id: %d", client->notify_id);
+       bt_gatt_client_unregister_notify(client->chrc->service->client->gatt, client->notify_id);
+#endif
        client->notify_id = 0;
 }