Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp204521iob; Mon, 2 May 2022 17:09:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwswt1sboDyHQPoN+IUjx+f8V9Ll4/3l734rWisbb9MDht3zwn3D0yQxp3ZQxXrtXJlWmMW X-Received: by 2002:a17:902:c946:b0:15e:9c09:715a with SMTP id i6-20020a170902c94600b0015e9c09715amr9652964pla.168.1651536540043; Mon, 02 May 2022 17:09:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651536540; cv=none; d=google.com; s=arc-20160816; b=OMTu7issLJ694Y/698wxT4RVcnFsCZUljp9e7zEBnYSWikOLA97cU4m7mJBxb4SC4V 3emkmdntEnsr+5zn3erApzFHiLl/jRAlHnq6sJk8s4mozhJBnXZL1irObvYhiD+Q1Ve/ z4io74/k1dGAcl7h1T2AqOvd1oLYk3nvz0W4S2xQ4OxPkTtfXcKMa+pXI+cNER224YPO ksnyRdY9ikO79R35cJtGR1NmwuyNCg1RhlkVd2noMZfel5nrVkoMWWF/9LF5fvlZ9Zn8 C+M2B6WZE+yXYD3GTwPVtUVimBZmp2rGf39ebhA4NZTmI5rfTnEColUKFWcgEdDJ03ct voXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=w4Xf4PKul0dRDsR568hSrl1yewjJixrs+wilzON3J5k=; b=x1laJlQueMrRJCdRxqbNB5CKxIIydjy0F05QDtC+nImO1NjICLJSLc+rNqE60+nhzy zttWwOe1DqNZjMxE9QgkJv+dP45kXTsPvRZELUrnyZvFY6ldYNHkmkwsF2JUJwDZCKl2 hbiEO4dvhPHkCNSeb+d2vmqCKOxtNLN3sJEbxw3wAGhZ8/VbsDHSDrIWRqMi8xSap6BJ WW2wn/PN/unsvWDsNWdNEFl5RNacf0lX1DCYEWALCFBxk+s0FRmftNTPA5GKfmkqzINZ 2xEG2SmwQeGl335MpYh50hGP3Eflozr2f6rK7U9ohyupt9B1hDwfcP7UIXaHWHMRwEgg W7WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Vloap+d5; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i9-20020a170902c94900b00153ff064711si8937655pla.144.2022.05.02.17.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:09:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Vloap+d5; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AF23035841; Mon, 2 May 2022 17:08:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232204AbiEBV0x (ORCPT + 99 others); Mon, 2 May 2022 17:26:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379908AbiEBV0v (ORCPT ); Mon, 2 May 2022 17:26:51 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA1C9BC83 for ; Mon, 2 May 2022 14:23:20 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id e5so1504036pgc.5 for ; Mon, 02 May 2022 14:23:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w4Xf4PKul0dRDsR568hSrl1yewjJixrs+wilzON3J5k=; b=Vloap+d59YpFEzpyYdhOelx4lfy5BdZoHZq4hwU73wx940G3HiY9+cUCYekvM72TUd BOqkNrNCxFDBpHpVd4kzIAX17krlq/WzX6qznsLB8TajYmQQn7XzcxOB3y0rwzCbE70v /AeL5ck8iR0cZ815Q9pi1sqiFcoH4uCkK6/7BUhyiMfj4U091yWDAjp8bHbaztWkldZ4 TSDyQsC6DU/uDKlpmC6a/19Q2RKH6k89450I+/x6X9aQPfnQy0UiP4PAt6OJ6WkNqq86 SqAC8UbIGJGaps1TBKcTLkgTujoqICbsLMBlvIm3FwJgtM7M6BlI6WzIiWwp3vHYpxLJ 4oSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w4Xf4PKul0dRDsR568hSrl1yewjJixrs+wilzON3J5k=; b=FfrPu3WIAxe+sKE6jgiFlrplgIKQZNHY7ojd+xja0YuGAFdiAvrFo/EFMxv967NJts XMP+RVcQ43xYUTfKpU0yADHtRj0PD6AM7ZTdrgKEjKJmiGF74sH+9QtCleC5u62gqy5e d5oI5rxdBUrWnVb77C0zXYJH1ZgYfeksrBLLBLMb7+dQ0QjHSIrqfLTlb9IDcw0+NBy+ XXWG0o2OX/TnBXvQKvJcF4iUjNtHUksK9ADpRm0zCzLFv/YZxuv/CgZSuF+sW6MSMJUR 0nD9dNJwPYXtZlMrZI78gpCWgr83BExGCXEsR3P8+yr9LM/KqznCxDnAJTAfCXQ58JTO uz/A== X-Gm-Message-State: AOAM5333joG1tes1M0Uu09YZLaI5npu2pvP+Jlm8jt6F492sUiV9upXT LwGHwLDt0PwSrMRLy451hO05ByHqnzk/KNpr401j64eJ X-Received: by 2002:a63:8143:0:b0:3ab:6bb5:8642 with SMTP id t64-20020a638143000000b003ab6bb58642mr10986332pgd.591.1651526600247; Mon, 02 May 2022 14:23:20 -0700 (PDT) MIME-Version: 1.0 References: <20220418174929.2777339-1-jiangzp@google.com> <20220418174914.Bluez.v2.1.I6ab300fa4999c9310f4cb6fc09b1290edb6b2c2b@changeid> In-Reply-To: From: Luiz Augusto von Dentz Date: Mon, 2 May 2022 14:23:08 -0700 Message-ID: Subject: Re: [Bluez PATCH v2 1/2] device: Add "Bonded" flag to dbus property To: Zhengping Jiang Cc: "linux-bluetooth@vger.kernel.org" , ChromeOS Bluetooth Upstreaming , Sonny Sasaka , Yun-Hao Chung Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Zhengping, On Mon, May 2, 2022 at 2:20 PM Zhengping Jiang wrote: > > Hi Luiz, > > Sorry for the delay. I just submitted a new patch for internal review. Will be sent upstream very soon. > Just to confirm, I will remove the option "paired-devices" and add optional arguments to "devices" command, so it can generate a list of devices based on filters. Great, thanks for letting me know. And yes, I think listing devices based on filters is a better option than yet another command to list a subset of devices. > Thanks, > Zhengping > > On Mon, May 2, 2022 at 2:12 PM Luiz Augusto von Dentz wrote: >> >> Hi Zhengping, >> >> On Mon, Apr 18, 2022 at 3:41 PM Luiz Augusto von Dentz >> wrote: >> > >> > Hi Zhengping, >> > >> > On Mon, Apr 18, 2022 at 10:49 AM Zhengping Jiang wrote: >> > > >> > > Add "Bonded" to dbus device property table. When setting the "Bonded >> > > flag, check the status of the Bonded property first. If the Bonded >> > > property is changed, send property changed signal. >> > > >> > > Reviewed-by: Sonny Sasaka >> > > Reviewed-by: Yun-Hao Chung >> > > >> > > Signed-off-by: Zhengping Jiang >> > > --- >> > > >> > > Changes in v2: >> > > - Move one variable declaration to the top following C90 standard >> > > >> > > Changes in v1: >> > > - Add "Bonded" to D-Bus interface >> > > - Send property changed signal if the bonded flag is changed >> > > >> > > doc/device-api.txt | 4 ++++ >> > > src/device.c | 40 +++++++++++++++++++++++++++++++++++----- >> > > 2 files changed, 39 insertions(+), 5 deletions(-) >> > > >> > > diff --git a/doc/device-api.txt b/doc/device-api.txt >> > > index 4e824d2dec17..6162755f954c 100644 >> > > --- a/doc/device-api.txt >> > > +++ b/doc/device-api.txt >> > > @@ -171,6 +171,10 @@ Properties string Address [readonly] >> > > >> > > Indicates if the remote device is paired. >> > > >> > > + boolean Bonded [readonly] >> > > + >> > > + Indicates if the remote device is bonded. >> > >> > It is probably a good idea to add a description about Bonded vs >> > Paired. Btw, API documentation should be in a separate patch. >> >> Will you be updating following this comments or you are waiting more >> feedback from upstream? >> >> > > + >> > > boolean Connected [readonly] >> > > >> > > Indicates if the remote device is currently connected. >> > > diff --git a/src/device.c b/src/device.c >> > > index 8dc12d026827..868c41f025d9 100644 >> > > --- a/src/device.c >> > > +++ b/src/device.c >> > > @@ -1042,6 +1042,22 @@ static gboolean dev_property_get_paired(const GDBusPropertyTable *property, >> > > return TRUE; >> > > } >> > > >> > > +static gboolean dev_property_get_bonded(const GDBusPropertyTable *property, >> > > + DBusMessageIter *iter, void *data) >> > > +{ >> > > + struct btd_device *dev = data; >> > > + dbus_bool_t val; >> > > + >> > > + if (dev->bredr_state.bonded || dev->le_state.bonded) >> > > + val = TRUE; >> > > + else >> > > + val = FALSE; >> > > + >> > > + dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &val); >> > > + >> > > + return TRUE; >> > > +} >> > > + >> > > static gboolean dev_property_get_legacy(const GDBusPropertyTable *property, >> > > DBusMessageIter *iter, void *data) >> > > { >> > > @@ -3120,6 +3136,7 @@ static const GDBusPropertyTable device_properties[] = { >> > > { "Icon", "s", dev_property_get_icon, NULL, >> > > dev_property_exists_icon }, >> > > { "Paired", "b", dev_property_get_paired }, >> > > + { "Bonded", "b", dev_property_get_bonded }, >> > > { "Trusted", "b", dev_property_get_trusted, dev_property_set_trusted }, >> > > { "Blocked", "b", dev_property_get_blocked, dev_property_set_blocked }, >> > > { "LegacyPairing", "b", dev_property_get_legacy }, >> > > @@ -6114,17 +6131,30 @@ void btd_device_set_trusted(struct btd_device *device, gboolean trusted) >> > > >> > > void device_set_bonded(struct btd_device *device, uint8_t bdaddr_type) >> > > { >> > > + struct bearer_state *state; >> > > + >> > > if (!device) >> > > return; >> > > >> > > - DBG(""); >> > > + state = get_state(device, bdaddr_type); >> > > >> > > - if (bdaddr_type == BDADDR_BREDR) >> > > - device->bredr_state.bonded = true; >> > > - else >> > > - device->le_state.bonded = true; >> > > + if (state->bonded) >> > > + return; >> > > + >> > > + DBG("setting bonded for device to true"); >> > > + >> > > + state->bonded = true; >> > > >> > > btd_device_set_temporary(device, false); >> > > + >> > > + /* If the other bearer state was already true we don't need to >> > > + * send any property signals. >> > > + */ >> > > + if (device->bredr_state.bonded == device->le_state.bonded) >> > > + return; >> > > + >> > > + g_dbus_emit_property_changed(dbus_conn, device->path, >> > > + DEVICE_INTERFACE, "Bonded"); >> > > } >> > > >> > > void device_set_legacy(struct btd_device *device, bool legacy) >> > > -- >> > > 2.36.0.rc0.470.gd361397f0d-goog >> > > >> > >> > >> > -- >> > Luiz Augusto von Dentz >> >> >> >> -- >> Luiz Augusto von Dentz -- Luiz Augusto von Dentz