Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4188574rwo; Tue, 25 Jul 2023 01:56:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlEt9bQoAG0L4Rzv+2BU56Vq7SlulF8x2TtNCZCxQ/3LKLGhwiKnCf17kP7sMfuwMyCJPN8D X-Received: by 2002:a05:6a00:1344:b0:666:7ec0:22d7 with SMTP id k4-20020a056a00134400b006667ec022d7mr14219180pfu.24.1690275411324; Tue, 25 Jul 2023 01:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690275411; cv=none; d=google.com; s=arc-20160816; b=m7KSWSJ7T50wMmbFFo2u3jqXQf8qboS9rYE7d6yq0kJ6VLTSnk0Ml6lfQFs/V+tafI 2kKOGJLqay3Rum3g1CfTC1BXe4cVDJ0QUAOXIvv9YbPNSprs71SnwLAgGb9hLOWdLtJ+ 6A0QG7bATK42fnrQZg3Xaao8oMGHJXo6+MVYuqem+X1vroGNG9Iy12e58jFHjUI7Cx8o 2+d94+WO8EKTe745po3GVvSd2D2N6gpMBRs8mqBhOxdX7EqiCGumCObeV3WT4s5HSrD1 7K/kakRhsyowp5UOeb/dmNm9sfbv1VdZTn2cGYLs2FZJuFYM+rMf+UOY+WYMOw8+gNlb qsgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pj/GqzGX2IAih0jbhznhLXDcANwV3FRZT+cStd1a3/o=; fh=Jg5b3SlU0kriz7dG9TxlX0lcLkpuhdKAkKJU/Cg3tjc=; b=ll5+AscgMiwJmjfYu9sqJYcGp6b77Jgu0dxuS68JJERK9FJJaYpodmN2FqQCBa8uKz 1FIy8PE7tfgj6wXh8eRUEJf6PI3CIs+gWJm2WPW8/hSBRJOY1qXdZBAg494JWpeySsSc Y6YK810pEpgo7aDS8MBw7vTof4UEBb++Ix8hseaBBablNxI57nEV9ytqCfkWIlR8Xa+n wj4z/mtHqeJk/mRngO45SWU4PX2WGM/KWzkbkhzARg1Xde4P7x6wxSDxO2pFE/BruhMM GDIupJ9VSjvf4QKPr1urW4TQuivR455rwRQPp5yYwaT+3iLZYoObdRWKbKD4NJSf2AE1 JWcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@streamunlimited.com header.s=google header.b=rsCGCj70; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=streamunlimited.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e2-20020a637442000000b00563814df056si8603505pgn.38.2023.07.25.01.56.37; Tue, 25 Jul 2023 01:56:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@streamunlimited.com header.s=google header.b=rsCGCj70; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=streamunlimited.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230480AbjGYIrT (ORCPT + 99 others); Tue, 25 Jul 2023 04:47:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230474AbjGYIql (ORCPT ); Tue, 25 Jul 2023 04:46:41 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D29F4214 for ; Tue, 25 Jul 2023 01:45:19 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-99357737980so871777866b.2 for ; Tue, 25 Jul 2023 01:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamunlimited.com; s=google; t=1690274697; x=1690879497; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pj/GqzGX2IAih0jbhznhLXDcANwV3FRZT+cStd1a3/o=; b=rsCGCj70CF289K3uXYWqWvnYVXb597zi4h+6s4vzo+SCELqK1eZ+uTCaQ5yI7cv+R9 3KEJmSzkRMr1TmGd3+eChfYcp9NNlO72W1gO5oYv8gLtPRtsuO5s81FbZcfvrsdN4FOk uxrc9egPS8OwNpXrr1OU/ks4I00whIU3hPbO8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690274697; x=1690879497; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pj/GqzGX2IAih0jbhznhLXDcANwV3FRZT+cStd1a3/o=; b=DW1LZWduk0wPcKpHynZdqEm5wwjyAvODGCnp3Xg7TU6XUQcapCEaxK6YsYMkbeSbl1 pmWsdhyPGd8JAisipZP7zCVztS99NxsbWijsuw9UEpJCo/LAa9OqxKtKyBQIzuf9Nw0P 1eggqt9BIyBfu0Pd4Vd4YpQLqIMUpKvOqmqQTZH8v7O1AGLEPH2XPJHKl+qRGaWS9DRW 5zfeXgsqzBv//y+ezF3FqDwnivPNewtBScuegqLB8D/fjt9ZE0G9vE+kjZwVkkE2c7/j przomk/a45dlLnkP6dX/v3xIIvDmoclzdyoOg2TfC2MG2V6RjlrUsG/JGEF/+ew5b6BB tbMQ== X-Gm-Message-State: ABy/qLYce1YtL/CCiWB88muf32Mt4n5TgxkQ2S3yV0KbEKmm8NQx02Mr t+kazDAujPmRU06eSVhsec05mg/fD1ms3LArJow= X-Received: by 2002:a17:907:7616:b0:965:9602:1f07 with SMTP id jx22-20020a170907761600b0096596021f07mr10907773ejc.39.1690274696964; Tue, 25 Jul 2023 01:44:56 -0700 (PDT) Received: from Legionbuntu.. ([2a01:c846:10c0:200:ed64:7921:ba0:11aa]) by smtp.gmail.com with ESMTPSA id n10-20020a170906164a00b00977cad140a8sm7866577ejd.218.2023.07.25.01.44.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 01:44:56 -0700 (PDT) From: Simon Mikuda To: linux-bluetooth@vger.kernel.org Cc: Simon Mikuda Subject: [PATCH BlueZ 7/8] gatt-client: Add read-only handles to dbus Date: Tue, 25 Jul 2023 10:44:30 +0200 Message-Id: <20230725084431.640332-8-simon.mikuda@streamunlimited.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230725084431.640332-1-simon.mikuda@streamunlimited.com> References: <20230725084431.640332-1-simon.mikuda@streamunlimited.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This can be usefull when mapping names for services and characteristics to their handle numbers. --- doc/gatt-api.txt | 3 +++ src/gatt-client.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/doc/gatt-api.txt b/doc/gatt-api.txt index 5042c5470..f29308aec 100644 --- a/doc/gatt-api.txt +++ b/doc/gatt-api.txt @@ -51,6 +51,7 @@ Properties string UUID [read-only] services of this service. uint16 Handle [read-write, optional] (Server Only) + [read-only] (Client Only) Service handle. When available in the server it would attempt to use to allocate into the database @@ -291,6 +292,7 @@ Properties string UUID [read-only] "authorize" uint16 Handle [read-write, optional] (Server Only) + [read-only] (Client Only) Characteristic handle. When available in the server it would attempt to use to allocate into the database @@ -380,6 +382,7 @@ Properties string UUID [read-only] "authorize" uint16 Handle [read-write, optional] (Server Only) + [read-only] (Client Only) Characteristic handle. When available in the server it would attempt to use to allocate into the database diff --git a/src/gatt-client.c b/src/gatt-client.c index a54d65e30..60a21e3f6 100644 --- a/src/gatt-client.c +++ b/src/gatt-client.c @@ -137,6 +137,17 @@ static bool uuid_cmp(const bt_uuid_t *uuid, uint16_t u16) return bt_uuid_cmp(uuid, &uuid16) == 0; } +static gboolean descriptor_get_handle(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct service *desc = data; + uint16_t handle = desc->start_handle; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &handle); + + return TRUE; +} + static gboolean descriptor_get_uuid(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -635,6 +646,7 @@ static DBusMessage *descriptor_write_value(DBusConnection *conn, } static const GDBusPropertyTable descriptor_properties[] = { + { "Handle", "q", descriptor_get_handle }, { "UUID", "s", descriptor_get_uuid }, { "Characteristic", "o", descriptor_get_characteristic, }, { "Value", "ay", descriptor_get_value, NULL, descriptor_value_exists }, @@ -713,6 +725,17 @@ static void unregister_descriptor(void *data) GATT_DESCRIPTOR_IFACE); } +static gboolean characteristic_get_handle(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct characteristic *chrc = data; + uint16_t handle = chrc->handle; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &handle); + + return TRUE; +} + static gboolean characteristic_get_uuid(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -1660,6 +1683,7 @@ static DBusMessage *characteristic_stop_notify(DBusConnection *conn, } static const GDBusPropertyTable characteristic_properties[] = { + { "Handle", "q", characteristic_get_handle }, { "UUID", "s", characteristic_get_uuid, NULL, NULL }, { "Service", "o", characteristic_get_service, NULL, NULL }, { "Value", "ay", characteristic_get_value, NULL, @@ -1821,6 +1845,17 @@ static void unregister_characteristic(void *data) GATT_CHARACTERISTIC_IFACE); } +static gboolean service_get_handle(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct service *service = data; + uint16_t handle = service->start_handle; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &handle); + + return TRUE; +} + static gboolean service_get_uuid(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -1884,6 +1919,7 @@ static gboolean service_get_includes(const GDBusPropertyTable *property, } static const GDBusPropertyTable service_properties[] = { + { "Handle", "q", service_get_handle }, { "UUID", "s", service_get_uuid }, { "Device", "o", service_get_device }, { "Primary", "b", service_get_primary }, -- 2.34.1