All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhengping Jiang <jiangzp@google.com>
To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com
Cc: chromeos-bluetooth-upstreaming@chromium.org,
	Zhengping Jiang <jiangzp@google.com>,
	Sonny Sasaka <sonnysasaka@chromium.org>,
	Yun-Hao Chung <howardchung@chromium.org>
Subject: [Bluez PATCH v2 2/2] client: Add bonded-devices and show Bonded flag in info
Date: Mon, 18 Apr 2022 17:49:29 +0000	[thread overview]
Message-ID: <20220418174914.Bluez.v2.2.I29a0e38364a8d5854342019b607fa049c74248a3@changeid> (raw)
In-Reply-To: <20220418174929.2777339-1-jiangzp@google.com>

Add "bonded-devices" to the menu and show the "Bonded" property for
command "info".

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Reviewed-by: Yun-Hao Chung <howardchung@chromium.org>

Signed-off-by: Zhengping Jiang <jiangzp@google.com>
---

(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"},
 	{ "system-alias", "<name>",   cmd_system_alias,
 					"Set controller alias" },
 	{ "reset-alias",  NULL,       cmd_reset_alias,
-- 
2.36.0.rc0.470.gd361397f0d-goog


  parent reply	other threads:[~2022-04-18 17:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-18 17:49 [Bluez PATCH v2 0/2] Adding bonded flag to D-Bus property Zhengping Jiang
2022-04-18 17:49 ` [Bluez PATCH v2 1/2] device: Add "Bonded" flag to dbus property Zhengping Jiang
2022-04-18 20:42   ` Adding bonded flag to D-Bus property bluez.test.bot
2022-04-18 22:41   ` [Bluez PATCH v2 1/2] device: Add "Bonded" flag to dbus property Luiz Augusto von Dentz
2022-05-02 21:11     ` Luiz Augusto von Dentz
     [not found]       ` <CAB4PzUpJmkXsgH_w++U0i8g_YvUbmae5n37acF3=q+3P0nJX2g@mail.gmail.com>
2022-05-02 21:23         ` Luiz Augusto von Dentz
2022-04-18 17:49 ` Zhengping Jiang [this message]
2022-04-18 23:59   ` [Bluez PATCH v2 2/2] client: Add bonded-devices and show Bonded flag in info Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220418174914.Bluez.v2.2.I29a0e38364a8d5854342019b607fa049c74248a3@changeid \
    --to=jiangzp@google.com \
    --cc=chromeos-bluetooth-upstreaming@chromium.org \
    --cc=howardchung@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=sonnysasaka@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.