Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3858912pxb; Tue, 19 Apr 2022 11:13:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQz70CyVBDdLUQLsnGkdTli7R1r2BKU1OV6K6JWU4ZTavWpnZUDcrQIbT3QytSa4z/6ofH X-Received: by 2002:a05:6402:2056:b0:41d:70c3:2904 with SMTP id bc22-20020a056402205600b0041d70c32904mr18992210edb.397.1650392011431; Tue, 19 Apr 2022 11:13:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650392011; cv=none; d=google.com; s=arc-20160816; b=Wj9I0kyiDHS2dPKV7UnYK9VNwvrGk60ZJU7GSjdMBZqFe0qHI2pBrH4DP9RDaaY/M1 d/qm/hmX/pIHHkmJWE3dBZlv4M+Kajyj8R381m+XVHCJuYCbCjMPF7rug66fUoT/NgbH 5HCfQ+G5iWdYEcalBgiHVZtyFlcppyByCWD2n0Xvw48joKhqldm5gWCzb+1HstH062Dv w8qwfEs448tf6mtsTQKH1+fETq98yUHivcz8wANTqrws81yAHI/PaH9e4VOUXErWI+2h QWB1ozKbWQdAeCeCTIXr0tVrtTs3Y3kwrm9SbloTMVeWz1KwAC5iCdpkoMJXdpLUBLSL it6g== 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=XNhEj6yQXEf8EzMPjLuIxRDR2ydDTYwBFv9bpimUglk=; b=0UWWehyGlBdWRF2p/A1nkyStLV15KZPvKnMH7Fj1jhSbmWO/TKZ6E2fuMbz1Hdo/6H +12Yn0qAk+5uv2lWfLda21dnT3Rm8HBFKg/ad1hnSCBJMx423lvHkeb3g3PIaaHO/UwL XMRziQTLuUZ2FBbJRlRIHMYy1rL6rldSYn7VWxasKh42CBJjk5HuSEhzTMEIGF2p/5lJ sKygEgf6BHjwGN9jRqqDRXfDajaLHFAfB6oGXZhZWPQEP5MMAI/t4S2axmpbTyPXy9Sl 1A7fXAME7nzeYrq0YNaHr5wQ41YcIk7k5x+Knjf5YwpkNty8WijHDzAh0HT/X/l+a4N8 ra9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MDQfJBj3; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a05640208c500b00418c2b5befdsi8397158edz.479.2022.04.19.11.12.49; Tue, 19 Apr 2022 11:13:31 -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=@gmail.com header.s=20210112 header.b=MDQfJBj3; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236001AbiDSACI (ORCPT + 99 others); Mon, 18 Apr 2022 20:02:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235925AbiDSACG (ORCPT ); Mon, 18 Apr 2022 20:02:06 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D923029CA7 for ; Mon, 18 Apr 2022 16:59:24 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id r8so16465112oib.5 for ; Mon, 18 Apr 2022 16:59:24 -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=XNhEj6yQXEf8EzMPjLuIxRDR2ydDTYwBFv9bpimUglk=; b=MDQfJBj3MEAwUtq9QPREFz1h5XcDDQxVdPXL7/gPb2EQ0qQIhru6P3j80J1EeIQlc4 EJWvoVtch7OJ6DdV8f6agPKFixuk7KchoZzPrcLw0ifRKZDYHdZDGE2aruWc5BEYelJB w0DkNzPa5Ez7ZQuHmAjtBlNIYd/68+T6BkTd6K2Xe7A3wcdKdB/GDygT485lbaa8azq/ KJkUhjI8yXCKFvpDy6V550MqC30zGvhYRtAMijL1TObfPfERrYxEhLBom5RmQvfM7gyg o0gRUOzNLw7wLSrETBOrjGwv/atnXiBHxsFyAUMkO/nQZ2k2+49JqSCxOVGHwZKcES0b QjPg== 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=XNhEj6yQXEf8EzMPjLuIxRDR2ydDTYwBFv9bpimUglk=; b=rqeekKTp2uVjiNGAUQVdBS/vSrGjLLUgnJkCoBfSSmB7Q/h+hD5ISNW/O4+i6e5vIu cYALYWuyrW3v+w0l1F1sv45wBcTCGwfQKUe6UoN+Q8ESxwVw5sDF4/lsYkuBAlWZFFmp zDiTpn/qyrsPS60O+RFNBRxyi7o68J3FbRdbqnGHUvxuE7XV4n9bfn9AQsLyqai3L91x nV1/5qWJ3Bxz1OKoqzRjnMBY0N+5sKtIIR86DSXkffo9E/YBkLuHqGoW6Qp/9i0HrRnI rU44d2NKcuu1dpAoDMZE0AXTeueHiV6gB8nxrv+Dw6CAFAuNBTuDUM8mryZEDbDEh7Qr PDFQ== X-Gm-Message-State: AOAM531rfU/aSyEB8fXT2S8xbp4ZRo5i053ax4LvPGHefB8DeiomCXAe USui8bAi3Jk4c9K5VHRRL+fd0NJGbLei5lVxPiPxr/CJ X-Received: by 2002:a05:6808:1115:b0:2ec:e78e:3fc0 with SMTP id e21-20020a056808111500b002ece78e3fc0mr8160291oih.207.1650326364134; Mon, 18 Apr 2022 16:59:24 -0700 (PDT) MIME-Version: 1.0 References: <20220418174929.2777339-1-jiangzp@google.com> <20220418174914.Bluez.v2.2.I29a0e38364a8d5854342019b607fa049c74248a3@changeid> In-Reply-To: <20220418174914.Bluez.v2.2.I29a0e38364a8d5854342019b607fa049c74248a3@changeid> From: Luiz Augusto von Dentz Date: Mon, 18 Apr 2022 16:59:12 -0700 Message-ID: Subject: Re: [Bluez PATCH v2 2/2] client: Add bonded-devices and show Bonded flag in info 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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi Zhengping, On Mon, Apr 18, 2022 at 10:49 AM Zhengping Jiang wrote: > > Add "bonded-devices" to the menu and show the "Bonded" property for > command "info". > > Reviewed-by: Sonny Sasaka > Reviewed-by: Yun-Hao Chung > > Signed-off-by: Zhengping Jiang > --- > > (no changes since v1) > > Changes in v1: > - Show the status of the "Bonded" flag in bluetoothctl > - Add option to show list of bonded devices > > client/main.c | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/client/main.c b/client/main.c > index 589268c3a68c..45c89a1de37b 100644 > --- a/client/main.c > +++ b/client/main.c > @@ -1090,6 +1090,32 @@ static void cmd_paired_devices(int argc, char *argv[]) > return bt_shell_noninteractive_quit(EXIT_SUCCESS); > } > > +static void cmd_bonded_devices(int argc, char *argv[]) > +{ > + GList *ll; > + > + if (check_default_ctrl() == FALSE) > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > + > + for (ll = g_list_first(default_ctrl->devices); > + ll; ll = g_list_next(ll)) { > + GDBusProxy *proxy = ll->data; > + DBusMessageIter iter; > + dbus_bool_t bonded; > + > + if (g_dbus_proxy_get_property(proxy, "Bonded", &iter) == FALSE) > + continue; > + > + dbus_message_iter_get_basic(&iter, &bonded); > + if (!bonded) > + continue; > + > + print_device(proxy, NULL); > + } > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > static void generic_callback(const DBusError *error, void *user_data) > { > char *str = user_data; > @@ -1781,6 +1807,7 @@ static void cmd_info(int argc, char *argv[]) > print_property(proxy, "Appearance"); > print_property(proxy, "Icon"); > print_property(proxy, "Paired"); > + print_property(proxy, "Bonded"); > print_property(proxy, "Trusted"); > print_property(proxy, "Blocked"); > print_property(proxy, "Connected"); > @@ -3116,6 +3143,8 @@ static const struct bt_shell_menu main_menu = { > { "devices", NULL, cmd_devices, "List available devices" }, > { "paired-devices", NULL, cmd_paired_devices, > "List paired devices"}, > + { "bonded-devices", NULL, cmd_bonded_devices, > + "List bonded devices"}, I would have done it a little be different, make devices command create different lists: bluetoothctl> devices [Trusted/Paired/Bonded/Connected] Device XX:... Name (Trusted, Paired, Bonded...) ... That way we don't have to create a command for each possible device filter. > { "system-alias", "", cmd_system_alias, > "Set controller alias" }, > { "reset-alias", NULL, cmd_reset_alias, > -- > 2.36.0.rc0.470.gd361397f0d-goog > -- Luiz Augusto von Dentz