From patchwork Tue Jul 25 08:44:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Mikuda X-Patchwork-Id: 706268 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F0DEC0015E for ; Tue, 25 Jul 2023 08:47:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231822AbjGYIrK (ORCPT ); Tue, 25 Jul 2023 04:47:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232228AbjGYIqi (ORCPT ); Tue, 25 Jul 2023 04:46:38 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7756B1BD1 for ; Tue, 25 Jul 2023 01:45:15 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-99313a34b2dso769338166b.1 for ; Tue, 25 Jul 2023 01:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamunlimited.com; s=google; t=1690274692; x=1690879492; 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=VaL2DgaNC+1z327qtfZ1KrQuYZxhQvPHWnqk5Q87V8k=; b=oI4kGqxgoVNrQROxKKw/FqtcrhcNUyfoSoU30wAFtfdxZMJgawHN96MlJZyP4bFAlG igTf5Cs/N34p0G+WXk/eXofUtZVfSj378GSZMYfL8VkWkFlXJnT3rkZniPB0fzdG7ePt 5kEKatSKd5gCmql8xfj6dwtibjhWB5fG5jcZo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690274692; x=1690879492; 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=VaL2DgaNC+1z327qtfZ1KrQuYZxhQvPHWnqk5Q87V8k=; b=W5hhdYEnP/BqNX3aBxhPeqyWsR2IqcFAEXt+7ecJFcicySEvl4QUzjgV00e7pDrSbF 8g53gYj1f9Cg3AWlAhfQHIfGCZA4ry25RSiw/uw0EEwu4Sfwpd5jcAF0FrgLcd73jOvh 33W0U7kCLUZ2cAE5FrOy0PRt2GiAKE+0kEmcKonnE75DUx9zEq1P00MN1bRjRIU4dYIl 2sdKU9j+bukcKxTljCHkc/N31/PmBUn2+Sr2+dkty3KIyBJwxxrAK/lLMkEoSpl/98+e fk8d8RQoPB+2X+IR5Mx7wUITTzKiA4GwsNFeev3Azjw482UP9ZT+1G69chllr6PD62HF 65zg== X-Gm-Message-State: ABy/qLZ81Tu+7xtngiF//jxuEGYLZTjbq0yh3qnjgDgaU8xQ46tZWclE d831Erhf9wft185/Wmj+Voo1KU8zHVP4e2goGtc= X-Google-Smtp-Source: APBJJlGOu98XeKUnao9zQqlO1TNjXeL0S1Q0cobuo1TnWmrKKBtuIp91xp6TzpP3FuQaPpY/TPCzHQ== X-Received: by 2002:a17:907:7895:b0:99a:7ff1:9b5a with SMTP id ku21-20020a170907789500b0099a7ff19b5amr12467744ejc.4.1690274692468; Tue, 25 Jul 2023 01:44:52 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 01:44:52 -0700 (PDT) From: Simon Mikuda To: linux-bluetooth@vger.kernel.org Cc: Simon Mikuda Subject: [PATCH BlueZ 1/8] advertising: Fix setting "BR/EDR not supported" flag Date: Tue, 25 Jul 2023 10:44:24 +0200 Message-Id: <20230725084431.640332-2-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org We need to check if adapter is connectable since remote device can connect to our device even when we are not discoverable according to advertised MAC address. --- src/advertising.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/advertising.c b/src/advertising.c index d959bf38f..b50900029 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -95,6 +95,8 @@ struct dbus_obj_match { const char *path; }; +static int get_adv_flags(struct btd_adv_client *client); + static bool match_client(const void *a, const void *b) { const struct btd_adv_client *client = a; @@ -736,11 +738,11 @@ static bool set_flags(struct btd_adv_client *client, uint8_t flags) if (!btd_adapter_get_bredr(client->manager->adapter)) flags |= BT_AD_FLAG_NO_BREDR; - /* Set BR/EDR Not Supported if adapter is not discoverable but the + /* Set BR/EDR Not Supported if adapter is not connectable but the * instance is. */ - if ((flags & (BT_AD_FLAG_GENERAL | BT_AD_FLAG_LIMITED)) && - !btd_adapter_get_discoverable(client->manager->adapter)) + if ((get_adv_flags(client) & MGMT_ADV_FLAG_CONNECTABLE) && + !btd_adapter_get_connectable(client->manager->adapter)) flags |= BT_AD_FLAG_NO_BREDR; if (!bt_ad_add_flags(client->data, &flags, 1)) From patchwork Tue Jul 25 08:44:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Mikuda X-Patchwork-Id: 706269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59912C0015E for ; Tue, 25 Jul 2023 08:47:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231959AbjGYIrE (ORCPT ); Tue, 25 Jul 2023 04:47:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232177AbjGYIqi (ORCPT ); Tue, 25 Jul 2023 04:46:38 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 137831FC6 for ; Tue, 25 Jul 2023 01:45:16 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-98dfb3f9af6so898302266b.2 for ; Tue, 25 Jul 2023 01:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamunlimited.com; s=google; t=1690274693; x=1690879493; 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=GzUjLzohbNEhHgBw32hCU4RFlK69VEaX+mca/4cUI38=; b=yK8mDbabyNk46H0Ki6PqYbIO99oKb4YpVJOodRypP3hjXvp20VD6pKT8FKgWP3Xf3U YGRo9m2eXvpStj6fPw5qdaNusPVnJYAJOVPMrlRUSgtcU8V60xnbtgHCbowAfB3wm55e ika7iE2tX/fDLR7Drfhz8KcNwNWrKikLYtZcI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690274693; x=1690879493; 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=GzUjLzohbNEhHgBw32hCU4RFlK69VEaX+mca/4cUI38=; b=Bvm+V096j+FDrl22zEPNJDK20tJDATTaaW2lf01vODcWnNZlYZ/VRxBdp+3reqTj/k Rtjn9Y+Qa83bT8Dn/j0dLGRD3Uul8yDLKiDo92K0IWawsLddCiKAOutsmbzar14E+2NT cJ25NuEcmePFT/zVU8qUm1u0ihMzYTYZKdagCA3fkRcL8YpPt8acR7WTbQj3xuNaneKg faqiuirKLYgiGdk8pBY2hexvgb3xvxzxeOVqFMxSm4K3FB7CMXQ9R7ZzD0XMYBYd2S92 Gcmtm1d2g/TJbvkc4+dBHqW5IX2vJ9nVdJDukKO4cVeYcKg8K+AfvsmKR1ZamKdjnAA1 Z2rQ== X-Gm-Message-State: ABy/qLZdJN4o+Z+6SQoyoCAGKPXvZsNuIqRbV5L9KI7EWuzrGZYs9yyc h36YodKANKUuFWPh/3+4GZbJpnUAIxfSmaBWDPw= X-Google-Smtp-Source: APBJJlHgLC2twt44z4jSuljYXXBWcgTxGLDlceQjTktWuqcBVe6nrUDHKp91E4CIa7e7mTyd+1Z06w== X-Received: by 2002:a17:906:76cd:b0:993:f12a:39ce with SMTP id q13-20020a17090676cd00b00993f12a39cemr12803927ejn.15.1690274693115; Tue, 25 Jul 2023 01:44:53 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 01:44:52 -0700 (PDT) From: Simon Mikuda To: linux-bluetooth@vger.kernel.org Cc: Simon Mikuda Subject: [PATCH BlueZ 2/8] adapter: Be able to use ConnectDevice for discovered devices Date: Tue, 25 Jul 2023 10:44:25 +0200 Message-Id: <20230725084431.640332-3-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This can be useful when you want to specify trasport type for already paired device (e.g. use LE transport for dual mode device). --- src/adapter.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 2679d4302..17f4a637d 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -3763,9 +3763,6 @@ static DBusMessage *connect_device(DBusConnection *conn, if (!bacmp(&addr, BDADDR_ANY)) return btd_error_invalid_args(msg); - if (btd_adapter_find_device(adapter, &addr, addr_type)) - return btd_error_already_exists(msg); - device_connect(adapter, &addr, addr_type, msg); return NULL; } From patchwork Tue Jul 25 08:44:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Mikuda X-Patchwork-Id: 706711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8E98C001E0 for ; Tue, 25 Jul 2023 08:47:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232021AbjGYIrG (ORCPT ); Tue, 25 Jul 2023 04:47:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232173AbjGYIqi (ORCPT ); Tue, 25 Jul 2023 04:46:38 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12BD81BD7 for ; Tue, 25 Jul 2023 01:45:16 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5221f193817so4088900a12.3 for ; Tue, 25 Jul 2023 01:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamunlimited.com; s=google; t=1690274694; x=1690879494; 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=n89ANJrt+y+ZXNxLi1rjyRRZmPrTl/SG2kXMM0plEO4=; b=JwN0+H0I/yhqyelNvYLlSYZHKR67V2wpcsi6wFiHALXsL+PX40n8YhXKRrfO88y8/e XWClJ+Q9SSuht62I5Bvb9Kvb2eBr9xgi83zr3r4Ep+3Ox6Ab6ANTJbi1R1TnSFXafdX9 ApvYyqBcAYXmuGglONf18bB5BLnQBOWNPRk+4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690274694; x=1690879494; 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=n89ANJrt+y+ZXNxLi1rjyRRZmPrTl/SG2kXMM0plEO4=; b=ApKgrrCglQCLVvjK3MkAGgLFsmRalyViBJmlRj2JvzWP9gaagTF0VZeIgA9GdoVOhz YpGAtzKmzetqgpLxMWmW6D72uHnyihXtY7ydhAEnLIEaO0+rOZ19pFAbfPs7fqyhSJnq cFKSiZLeatp+L9inU+EvtuWkOsCmliLM8i72CLInaBTUdcp6akts0XzjMkCXMX29xP63 XHzSASY7AEi/5c3VoHwCxmIWK5JOoPv9djKRBEJrh7V+an38giP62t+LGBSFD+UgtGlS V4xT1EIaZRF3jHdIoi7q6nrvZtKQgiKxSyyemKmpXmFsxQUAzgtafA2VYxqwq+eR6Op0 Tp+Q== X-Gm-Message-State: ABy/qLb8WTp3gN6Lz4CNo9QuGCWKJvN0PkfzdtfDeEF/1HmgBLgoCojn dZHO7ksrfFTyOoEtHRUq7wOZmlpZvM4UV73YaS0= X-Google-Smtp-Source: APBJJlE7rC2CrTmniYxlAKQi4RNlXl1m1lqpqvyoGMaAA7h+M3p828y6qb8eLmmdIg3xXpgPP475qA== X-Received: by 2002:a17:907:7846:b0:994:8e9:67fe with SMTP id lb6-20020a170907784600b0099408e967femr10806190ejc.35.1690274694021; Tue, 25 Jul 2023 01:44:54 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 01:44:53 -0700 (PDT) From: Simon Mikuda To: linux-bluetooth@vger.kernel.org Cc: Simon Mikuda Subject: [PATCH BlueZ 3/8] device: Refactor device_discover_services function Date: Tue, 25 Jul 2023 10:44:26 +0200 Message-Id: <20230725084431.640332-4-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org After refactoring we can reuse function once more in function void device_bonding_complete(...) --- profiles/input/server.c | 2 +- src/adapter.c | 2 +- src/device.c | 24 +++++++----------------- src/device.h | 3 ++- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/profiles/input/server.c b/profiles/input/server.c index 79cf08a66..12912cae6 100644 --- a/profiles/input/server.c +++ b/profiles/input/server.c @@ -102,7 +102,7 @@ static void sixaxis_browse_sdp(const bdaddr_t *src, const bdaddr_t *dst, data->psm = psm; if (psm == L2CAP_PSM_HIDP_CTRL) - device_discover_services(device); + device_discover_services(device, BDADDR_BREDR, NULL); device_wait_for_svc_complete(device, sixaxis_sdp_cb, data); } diff --git a/src/adapter.c b/src/adapter.c index 17f4a637d..4c3bb091d 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -3637,7 +3637,7 @@ static void device_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data) device_attach_att(device, io); } - device_discover_services(device); + device_discover_services(device, data->dst_type, NULL); device_wait_for_svc_complete(device, device_browse_cb, NULL); g_io_channel_unref(io); diff --git a/src/device.c b/src/device.c index b43ced8b5..82740216d 100644 --- a/src/device.c +++ b/src/device.c @@ -2446,10 +2446,7 @@ static DBusMessage *connect_profiles(struct btd_device *dev, uint8_t bdaddr_type resolve_services: DBG("Resolving services for %s", dev->path); - if (bdaddr_type == BDADDR_BREDR) - err = device_browse_sdp(dev, msg); - else - err = device_browse_gatt(dev, msg); + err = device_discover_services(dev, bdaddr_type, msg); if (err < 0) { return btd_error_failed(msg, bdaddr_type == BDADDR_BREDR ? ERR_BREDR_CONN_SDP_SEARCH : ERR_LE_CONN_GATT_BROWSE); @@ -5873,14 +5870,15 @@ static int device_browse_sdp(struct btd_device *device, DBusMessage *msg) return err; } -int device_discover_services(struct btd_device *device) +int device_discover_services(struct btd_device *device, + uint8_t bdaddr_type, DBusMessage *msg) { int err; - if (device->bredr) - err = device_browse_sdp(device, NULL); + if (bdaddr_type == BDADDR_BREDR) + err = device_browse_sdp(device, msg); else - err = device_browse_gatt(device, NULL); + err = device_browse_gatt(device, msg); if (err == 0 && device->discov_timer) { timeout_remove(device->discov_timer); @@ -6353,15 +6351,7 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, DBG("Proceeding with service discovery"); /* If we are initiators remove any discovery timer and just * start discovering services directly */ - if (device->discov_timer) { - timeout_remove(device->discov_timer); - device->discov_timer = 0; - } - - if (bdaddr_type == BDADDR_BREDR) - device_browse_sdp(device, bonding->msg); - else - device_browse_gatt(device, bonding->msg); + device_discover_services(device, bdaddr_type, bonding->msg); bonding_request_free(bonding); } else if (!state->svc_resolved) { diff --git a/src/device.h b/src/device.h index 3252e14ef..0393478df 100644 --- a/src/device.h +++ b/src/device.h @@ -176,7 +176,8 @@ bool device_remove_svc_complete_callback(struct btd_device *dev, struct btd_service *btd_device_get_service(struct btd_device *dev, const char *remote_uuid); -int device_discover_services(struct btd_device *device); +int device_discover_services(struct btd_device *device, + uint8_t bdaddr_type, DBusMessage *msg); int btd_device_connect_services(struct btd_device *dev, GSList *services); uint32_t btd_device_get_current_flags(struct btd_device *dev); From patchwork Tue Jul 25 08:44:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Mikuda X-Patchwork-Id: 706710 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44365C0015E for ; Tue, 25 Jul 2023 08:47:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232101AbjGYIrM (ORCPT ); Tue, 25 Jul 2023 04:47:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjGYIqk (ORCPT ); Tue, 25 Jul 2023 04:46:40 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88D041FD7 for ; Tue, 25 Jul 2023 01:45:17 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-51e28b299adso8369933a12.2 for ; Tue, 25 Jul 2023 01:45:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamunlimited.com; s=google; t=1690274694; x=1690879494; 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=Q90pg3qDzBvVPqD6CaJUpw83QakxOeK89A7ElltIbrY=; b=b/bELl+u9cAb6gssmCrAqNgn80T1vdQqXdUVzY80r2kcECrAv1Y6Ue2BKePme3mUyQ Ypnspl0J9yuA8Z24bAAEmVhv495uKpCTbVKjoCKQ2sQn/Kh5FtNR51CgGKKGDDW/cXSS hj3Y4H5g/hJwLH5BId0iAK+kH3ojyI9d4MI8Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690274694; x=1690879494; 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=Q90pg3qDzBvVPqD6CaJUpw83QakxOeK89A7ElltIbrY=; b=acwZqAM+WB3DxfyAoUUD14QdsGWZ0nUf/YcQMfCg18/6RUlxclNFt1rLIPLVPWNIOx 4bnFPniiAOe+n89FZquo7hqQ84iHAi2lmLiaY8W4lZfhJZ/1XT7kEMx5tRcX+brKaCs/ Q34oCUREmQYYh3mpbdsaejr+98DAZC2888aPgM9mMIV/ZNGdijqm+gdFDGPxlMoxDKZ7 1h8XqEI8h3/6Y9qf9L/uzlhf2xd6NJW/xUOe7FgCQlnd2tzN3eVqtYapMyml7CKQVpMW XRrgfM2g45Hq+Mk4hemmEV4hNb2Hi+aSbVVHjQVZbm5vG1l540sUYauO58IoF3D0076c SEBg== X-Gm-Message-State: ABy/qLY6wwPgtHnKMQN/t2ZwbMtAu9XHtJIuELGGPIPlXzINjTCjf7oS iVdmrKXr1p5T4+445w3t9ReXsZyohqSyjEbR9n8= X-Google-Smtp-Source: APBJJlFiJyy/2zFqyFGD/qlsVjJ4eHB1AqDKHmY+VldQVTBj/9d148Js2GHpgBxfym+PcZr8V55+Gw== X-Received: by 2002:a17:906:2216:b0:989:3e0d:89fb with SMTP id s22-20020a170906221600b009893e0d89fbmr13885411ejs.45.1690274694717; Tue, 25 Jul 2023 01:44:54 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 01:44:54 -0700 (PDT) From: Simon Mikuda To: linux-bluetooth@vger.kernel.org Cc: Simon Mikuda Subject: [PATCH BlueZ 4/8] device: Rename start_discovery function Date: Tue, 25 Jul 2023 10:44:27 +0200 Message-Id: <20230725084431.640332-5-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Rename it to start_discovery_cb to indicate that it is callback function from timer. --- src/device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/device.c b/src/device.c index 82740216d..6f28e261e 100644 --- a/src/device.c +++ b/src/device.c @@ -6203,7 +6203,7 @@ bool device_is_connectable(struct btd_device *device) return state->connectable; } -static bool start_discovery(gpointer user_data) +static bool start_discovery_cb(gpointer user_data) { struct btd_device *device = user_data; @@ -6363,7 +6363,7 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, DBG("setting timer for reverse service discovery"); device->discov_timer = timeout_add_seconds( DISCOVERY_TIMER, - start_discovery, + start_discovery_cb, device, NULL); } } @@ -6406,7 +6406,7 @@ unsigned int device_wait_for_svc_complete(struct btd_device *dev, timeout_remove(dev->discov_timer); dev->discov_timer = timeout_add_seconds( 0, - start_discovery, + start_discovery_cb, dev, NULL); } From patchwork Tue Jul 25 08:44:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Mikuda X-Patchwork-Id: 706267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A89DC001E0 for ; Tue, 25 Jul 2023 08:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232152AbjGYIrP (ORCPT ); Tue, 25 Jul 2023 04:47:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbjGYIqk (ORCPT ); Tue, 25 Jul 2023 04:46:40 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7349C420C for ; Tue, 25 Jul 2023 01:45:18 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-98377c5d53eso841417966b.0 for ; Tue, 25 Jul 2023 01:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamunlimited.com; s=google; t=1690274695; x=1690879495; 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=JyB/UXv/9yVmn9xMLGcOhjRpTTudWve/pgKegPw0FUc=; b=Bsbcb7Ip66w006uYvhXRjIB+ydNcGZXYUz9iCOnaFf3d0CD18B9AjkdEvlNwmISUfb tPwifc3akIX2/4NaWbMJi88ExnAgqF1FuT1x7/V2MIk+grxUsRVFadfPl1FhfLhEk7YY R4ElUS6UQqTaeGL1F2CP1MROmjTE4xZ00+kLY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690274695; x=1690879495; 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=JyB/UXv/9yVmn9xMLGcOhjRpTTudWve/pgKegPw0FUc=; b=FaDlwV7oy/eq33MK/85aw6fMmZV4yFDm3JNmwmDOpOeGGikJ0raaTQODskA4oqdsnm nggxIcszNV6cZTeIqE8S6uFC2ISgRZ86NoLEsgiePY9Hd6nWnpiphxYMODVqnVKlA69g 0+2LiqW/5SbM0+DMvwr3kERuZ273Rc3c4hv+Tt4XQiv1n+rqyT5wb1XXiDXIzNbTO0V7 5Y6hv926PN5+eIA0wGY672oAsscAhhYRwNlIDCRPUol4ItMiZOkawGB3YFlToBDFtRsp T37ss7c23MIiSDI2beIbKRLOcxzA/nAJNrNTq/NCeqXmY8ZbBvo2lVdWSWnWBodtMvy4 kFXw== X-Gm-Message-State: ABy/qLZEr/FMIeA0fHM6eejWOMmCa6Dgz1raJjS3mPnqDZwbr8l5Ug+b 2kj+a+owFfhHJgfoAW1UyFt/cGgN7Uc6lpcUhAg= X-Google-Smtp-Source: APBJJlEND45VPtrmrWjPJXj3xgYPr74tl+rn+HIDLVPn9Njfw4Rv61h+nGx2+p9Kvnh6hdGq87UV6A== X-Received: by 2002:a17:906:76d6:b0:993:f497:adc2 with SMTP id q22-20020a17090676d600b00993f497adc2mr11757236ejn.18.1690274695321; Tue, 25 Jul 2023 01:44:55 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 01:44:54 -0700 (PDT) From: Simon Mikuda To: linux-bluetooth@vger.kernel.org Cc: Simon Mikuda Subject: [PATCH BlueZ 5/8] device: Fix pairing and discovery with dual mode devices Date: Tue, 25 Jul 2023 10:44:28 +0200 Message-Id: <20230725084431.640332-6-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org We'll prefer to pair and discover services on connected bearer first. There was a problem with pairing, that select_conn_bearer returned BR/EDR even when we have connection to LE bearer only. In these situation we should pair over connected bearer, since connection to another bearer can fail. Similar problem with discovery that after connection on LE bearer discovery was requested on BR/EDR bearer which can cause connection error (e.g. Page Timeout). --- src/device.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/device.c b/src/device.c index 6f28e261e..446e978ee 100644 --- a/src/device.c +++ b/src/device.c @@ -2504,6 +2504,16 @@ static uint8_t select_conn_bearer(struct btd_device *dev) return dev->bdaddr_type; } +static uint8_t select_active_bearer(struct btd_device *dev) +{ + if (dev->bredr_state.connected) + return BDADDR_BREDR; + else if (dev->le_state.connected) + return dev->bdaddr_type == BDADDR_BREDR + ? BDADDR_LE_PUBLIC : dev->bdaddr_type; + return select_conn_bearer(dev); +} + static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg, void *user_data) { @@ -3018,7 +3028,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg, else if (device->le_state.bonded) bdaddr_type = BDADDR_BREDR; else - bdaddr_type = select_conn_bearer(device); + bdaddr_type = select_active_bearer(device); state = get_state(device, bdaddr_type); @@ -3055,7 +3065,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg, err = device_connect_le(device); else err = adapter_create_bonding(adapter, &device->bdaddr, - device->bdaddr_type, + bdaddr_type, io_cap); } else { err = adapter_create_bonding(adapter, &device->bdaddr, @@ -6207,12 +6217,9 @@ static bool start_discovery_cb(gpointer user_data) { struct btd_device *device = user_data; - if (device->bredr) - device_browse_sdp(device, NULL); - else - device_browse_gatt(device, NULL); - device->discov_timer = 0; + device_discover_services(device, select_active_bearer(device), + NULL); return FALSE; } From patchwork Tue Jul 25 08:44:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Mikuda X-Patchwork-Id: 706709 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49C6BC0015E for ; Tue, 25 Jul 2023 08:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231837AbjGYIrR (ORCPT ); Tue, 25 Jul 2023 04:47:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232234AbjGYIqk (ORCPT ); Tue, 25 Jul 2023 04:46:40 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D6324210 for ; Tue, 25 Jul 2023 01:45:18 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-98377c5d53eso841420866b.0 for ; Tue, 25 Jul 2023 01:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamunlimited.com; s=google; t=1690274696; x=1690879496; 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=ZSkJantJe5ant6WDLniA5WbG6ARZppIgsiumlG3ocv4=; b=u0bYL9FZ4auw1EPCtLTpBwiUo2Js7OBpQuj8h8Wf5pjXxI6oEOBzI9Ta2liL7zLgRa HHfGVwHTw3bc/8w1fc8NhzPsjE9kiM0pN5sBm1mNmp0GG8P17P36BJCihdDCSUSzV1lM TZtsgxstsWQrh+5TgTx70TtCXfcH5cfodj5AQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690274696; x=1690879496; 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=ZSkJantJe5ant6WDLniA5WbG6ARZppIgsiumlG3ocv4=; b=aNfVdn1UCJKNzxRyh4wdmtiYaLbAv3V53YtOPwvSG7ZlPjUBVQ7z7+es0JwK7U+g/N 47FZk56zMmO56xluZNMD14JrAwfpAbPu4ZMK1OIZwF8+jt3pLo42SkT1ABdSd6x0MJoI FB52LA2UGn9OARgUm3BCpyRN5KaLHXGB7UQwkFOW3aAOvub0LzED+omWQkqBrv+jq7fP sxjZY7DLQDJrLuzJh7HBgSbuaJOMWkVStjEbEdRZPKhAAMFh5hCgQdupf6YaM39NK3s1 V9ybO1Jg/nV/0IrnAWwCNgXL2a0OLZ4KtxMBxuUwVy7UZx9R+1TCSe1ZaGgoceaGoOAH KZkA== X-Gm-Message-State: ABy/qLYo4DuGW8CVZlWGKKvUmucYAdhuJ6fMNsNxSEKKC/9QT9N/zT/7 Uew0BkZt/dw8mWsVa6QxkH1NRNRU4Cmkoy4lyMI= X-Google-Smtp-Source: APBJJlF5tJrLMnWvqHcDQuuBB16ZChDYp3kE8VfshbFi1gzXqbVcvxGVyBSq/zwwJiJt6e048AZ5hg== X-Received: by 2002:a17:907:2713:b0:993:fe68:569d with SMTP id w19-20020a170907271300b00993fe68569dmr10361335ejk.17.1690274696169; 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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 01:44:55 -0700 (PDT) From: Simon Mikuda To: linux-bluetooth@vger.kernel.org Cc: Simon Mikuda Subject: [PATCH BlueZ 6/8] device: Handle error from discover services request after pair Date: Tue, 25 Jul 2023 10:44:29 +0200 Message-Id: <20230725084431.640332-7-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org If discovery was requesed from pair request we will report successfull pairing even if there was an error during discovery. --- src/device.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/device.c b/src/device.c index 446e978ee..35c46e451 100644 --- a/src/device.c +++ b/src/device.c @@ -6309,6 +6309,7 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, struct bonding_req *bonding = device->bonding; struct authentication_req *auth = device->authr; struct bearer_state *state = get_state(device, bdaddr_type); + int err; DBG("bonding %p status 0x%02x", bonding, status); @@ -6358,8 +6359,16 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, DBG("Proceeding with service discovery"); /* If we are initiators remove any discovery timer and just * start discovering services directly */ - device_discover_services(device, bdaddr_type, bonding->msg); - + err = device_discover_services(device, bdaddr_type, bonding->msg); + if (err) { + if (device->pending_paired) { + g_dbus_emit_property_changed(dbus_conn, device->path, + DEVICE_INTERFACE, "Paired"); + device->pending_paired = false; + } + /* Disregard browse errors in case of Pair */ + g_dbus_send_reply(dbus_conn, bonding->msg, DBUS_TYPE_INVALID); + } bonding_request_free(bonding); } else if (!state->svc_resolved) { if (!device->browse && !device->discov_timer && From patchwork Tue Jul 25 08:44:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Mikuda X-Patchwork-Id: 706266 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B6DEC0015E for ; Tue, 25 Jul 2023 08:47:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231972AbjGYIrU (ORCPT ); Tue, 25 Jul 2023 04:47:20 -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-Google-Smtp-Source: APBJJlHZoEkpltNz80tQB3p8GfkuV1jdb7ipHZCpiY0YzxpKy6EchlqlddwQjefc2nhMeFGm61BDyA== 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 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 }, From patchwork Tue Jul 25 08:44:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Mikuda X-Patchwork-Id: 706708 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EAC3C001E0 for ; Tue, 25 Jul 2023 08:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229568AbjGYIrW (ORCPT ); Tue, 25 Jul 2023 04:47:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231249AbjGYIql (ORCPT ); Tue, 25 Jul 2023 04:46:41 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F7F34215 for ; Tue, 25 Jul 2023 01:45:19 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2b74310566cso76904671fa.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=t4Jhtve8i1N+ldqV//aP+0i7v5Dzki1fWBpJO4+fkmI=; b=jRJMA1+6kR8Bg7hBlX2DVwrOMVw+BycPwKt1bdMPwPGhBh2YtsXhXmxN0rbVYwMpsl zIDeBjGdfpP6kfHW4QRIMkwzj53TQ0NRX2d+1wbINJMaz6++xtH6p78tktjm6nPRS0t8 ShRI2w3AGtQYbO1OVtt1LzMy3rm4wQGeez1lM= 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=t4Jhtve8i1N+ldqV//aP+0i7v5Dzki1fWBpJO4+fkmI=; b=InPYaQqbZRhq0HMwjN6BH+AlsgxWTE8n9H/20dZ0BdIm8hOe5Ss6gu1v0RGUVZRXcx 58+muwI8cu/9YUIvbWFmStR7Uf3lDEMD2FiJdz6hVWFldEa/DclNtgqNtVA0gbeQ86bq UVweyEx+3Aq6E24RvpRhfFtfb5OFRHbpoUKG0xuyYFFgg6ZANC0lRSXfvQAUZkj6RRP1 o1gcdezs+I9ONNBskdItasee5ocAeAi1aYSsTlnDUPvLtuE+h8U2AtAoiD9jHAZJqOIw JJ7yIa04e2zqw3wBGnta8DhpzIkHH7DBCJLngtPR0uVqeqwPP17DgTq2x5B0rWwHSiCO E1HA== X-Gm-Message-State: ABy/qLZGkQ+IPwgUVg8RFy/8I+l8X8aGyj52egpICeq/7PcjnTXaWieI Sbmwzi2mNnnFl+M9AqpRX9BlZW1z+QkYVoo1hvE= X-Google-Smtp-Source: APBJJlGWf+61fQGEqxbjRy9gB8ozeWBbRAIZj9AklhxFW5KoXQJM7E9wGh75UvqcgXyWACdPlmSWIw== X-Received: by 2002:a2e:8707:0:b0:2b9:4aa1:71e1 with SMTP id m7-20020a2e8707000000b002b94aa171e1mr7580879lji.50.1690274697779; Tue, 25 Jul 2023 01:44:57 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 01:44:57 -0700 (PDT) From: Simon Mikuda To: linux-bluetooth@vger.kernel.org Cc: Simon Mikuda Subject: [PATCH BlueZ 8/8] adapter: Ensure that file exists on IRK write Date: Tue, 25 Jul 2023 10:44:31 +0200 Message-Id: <20230725084431.640332-9-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- src/adapter.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 4c3bb091d..fe8ae7604 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -8823,6 +8823,8 @@ static void store_irk(struct btd_adapter *adapter, const bdaddr_t *peer, g_key_file_set_string(key_file, "IdentityResolvingKey", "Key", str); + create_file(filename, 0600); + store_data = g_key_file_to_data(key_file, &length, NULL); if (!g_file_set_contents(filename, store_data, length, &gerr)) { error("Unable set contents for %s: (%s)", filename,