Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp749421rwb; Thu, 27 Jul 2023 22:10:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlHC52tX6k7MNwuwVCapxUglZmLVIPOWDVevxZcLd+O9AxhpEvwzk/W74Kc2CBMLOv6FCR9Y X-Received: by 2002:aa7:d98a:0:b0:522:586d:6f3a with SMTP id u10-20020aa7d98a000000b00522586d6f3amr1138375eds.6.1690520999907; Thu, 27 Jul 2023 22:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690520999; cv=none; d=google.com; s=arc-20160816; b=MuIpMRhs6Eea2pcPsajQ/BYFR2PuKxqPXjXEzJ4tiOWBMB88Lc572XMg/PhmbUy2zV jELqE9Oo/0lRNE2wwQRNB6Ckqyn/BXdaP1O7MxW4Sam53cJeGCL40TU9yBLGmezZAaZx ZxaelPi/ky6ah79HP/WeUHZIzTVDUe5ylAuMVDybTNmBoslxUMg4bExgxBb3Rhttp5pc ySY/9MSBv+RtzS05BwwrMH6cbuX+uQWpKwlsRiXAsOBbCzrimycL9I8AiYfyEdpAwYif Iu4q62eOIcIdc9HidPhzB5oR58vb5tkLsVewbK9fpoaPFYB13mBX90xfkfcUAXTKVKF7 LUWQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=pj/GqzGX2IAih0jbhznhLXDcANwV3FRZT+cStd1a3/o=; fh=Jg5b3SlU0kriz7dG9TxlX0lcLkpuhdKAkKJU/Cg3tjc=; b=xojaji6rkzqQipb+G5Io3y8cLNICTShsrvP2d9UF90AmHF2gu6HLn8js7Ukv82Fv/U /Zf7zKB/jGAPtRbTzDBZlCVPWF+wQarzlVoD/rzQWb09oAprVVsR92STTaP1DpioaaY0 QpWanGv2po+83C8qln1ETltPSqxz3j1xI+wsBeWtlXaAytZBnJd8f703QS0c83PJW/lM 2CNA5vmzSz2puphOadTTW8rQQWg5AaVX91DwPaQGhL7UsOfipt+TFQU3P8pSJr05AZSn PNaP0b1KprDmYBB1/GbeZ+48lJ97G6I4rNeMGJvFxGnp3Z+XpawVi/WiVjLqWBeoxC59 sl7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@streamunlimited.com header.s=google header.b=K7m3F+DK; 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 ay24-20020a056402203800b00522805b25b2si2079239edb.523.2023.07.27.22.09.36; Thu, 27 Jul 2023 22:09:59 -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=K7m3F+DK; 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 S233062AbjG1Euv (ORCPT + 99 others); Fri, 28 Jul 2023 00:50:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233420AbjG1Eu2 (ORCPT ); Fri, 28 Jul 2023 00:50:28 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C72713AB9 for ; Thu, 27 Jul 2023 21:49:50 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-992dcae74e0so237846866b.3 for ; Thu, 27 Jul 2023 21:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamunlimited.com; s=google; t=1690519788; x=1691124588; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pj/GqzGX2IAih0jbhznhLXDcANwV3FRZT+cStd1a3/o=; b=K7m3F+DK6U4pxOYM+UZha12xGAsy3cFdMd22nshh467MBV/Yjvrb+EhhusLlYoZlwn bJHGrTsLKelFKDPRIUTulIer7wYA/pz6VCue0NrmOtgD3z7JkOErV9uSkrhLXQWtbhb5 hkZEyk3rurYVIsIedeW315flrI5UQo2YZyy5A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690519788; x=1691124588; h=content-transfer-encoding:mime-version: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=dPV7FpIOLuGBFQu71sp/KhWjGqgoWIvusS/4xQoWZjR0Q99Enkj1SbjpItumjil9EA /sTDHe3/XOqKCWKt9E8EgYPjf20ck9zsAXMMMRZgXe7ijqNUCjMshoK+yZ+YDjdirOUO +vq0lswfhqEfqA6UnGpvXJfMPLAzPW+085gemWc2hTQAlSD7RvaFdcWehaAKAF083SAs R4bwKnANKtl+N1vCPftpBSoKzatUKQ62nk6ILClJPi8Xk4MuSaykrvL7MFfFM/3VoTDR +crPGyeoe/YYFjHVmNvjtv7UqO7YLy7ktvoNXc4NuC6qovqRels002NYsfMummpl0Gvo 5Wpg== X-Gm-Message-State: ABy/qLbhEBRFsLLh3L5D54bNpGLiOUZjCkIsLcwwIrChzEKREkDUcW7X dYdG/W3cCCY1VZgtpH5EWbCIbErMywdmMe1yVOs= X-Received: by 2002:a17:907:a0c6:b0:99b:c985:cf7e with SMTP id hw6-20020a170907a0c600b0099bc985cf7emr1176037ejc.54.1690519788514; Thu, 27 Jul 2023 21:49:48 -0700 (PDT) Received: from smi-ubuntu.sueba ([2a01:390:0:101:45e3:52d2:7d93:f842]) by smtp.gmail.com with ESMTPSA id ov38-20020a170906fc2600b009929ab17bdfsm1554270ejb.168.2023.07.27.21.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 21:49:48 -0700 (PDT) From: Simon Mikuda To: linux-bluetooth@vger.kernel.org Cc: Simon Mikuda Subject: [PATCH BlueZ] gatt-client: Add read-only handles to dbus Date: Fri, 28 Jul 2023 06:49:44 +0200 Message-Id: <20230728044944.576220-1-simon.mikuda@streamunlimited.com> X-Mailer: git-send-email 2.34.1 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