public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: "Frédéric Danis" <frederic.danis@collabora.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v4 4/4] client: Display disconnection reason
Date: Fri, 23 May 2025 09:26:47 +0200	[thread overview]
Message-ID: <20250523072647.689324-5-frederic.danis@collabora.com> (raw)
In-Reply-To: <20250523072647.689324-1-frederic.danis@collabora.com>

The new org.bluez.Device1.Disconnected signal propagates the
disconnection reason.
---
v1->v2: Display disconnect reason in numerical and text
v2->v3: Display disconnect reason name and message instead of numerical value

 client/main.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/client/main.c b/client/main.c
index ad35ae1fb..14d5686fb 100644
--- a/client/main.c
+++ b/client/main.c
@@ -709,6 +709,24 @@ static void property_changed(GDBusProxy *proxy, const char *name,
 static void message_handler(DBusConnection *connection,
 					DBusMessage *message, void *user_data)
 {
+	if (!strcmp(dbus_message_get_member(message), "Disconnected")) {
+		const char *name;
+		const char *msg;
+
+		if (!dbus_message_get_args(message, NULL,
+					DBUS_TYPE_STRING, &name,
+					DBUS_TYPE_STRING, &msg,
+					DBUS_TYPE_INVALID))
+			goto failed;
+
+		bt_shell_printf("[SIGNAL] %s.%s %s %s\n",
+					dbus_message_get_interface(message),
+					dbus_message_get_member(message),
+					name, msg);
+		return;
+	}
+
+failed:
 	bt_shell_printf("[SIGNAL] %s.%s\n", dbus_message_get_interface(message),
 					dbus_message_get_member(message));
 }
-- 
2.43.0


  parent reply	other threads:[~2025-05-23  7:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-23  7:26 [PATCH BlueZ v4 0/4] Propagate disconnection reason Frédéric Danis
2025-05-23  7:26 ` [PATCH BlueZ v4 1/4] lib/mgmt: Add MGMT_DEV_DISCONN_AUTH_FAILURE define Frédéric Danis
2025-05-23  8:46   ` Propagate disconnection reason bluez.test.bot
2025-05-23  7:26 ` [PATCH BlueZ v4 2/4] src/device: Add Disconnected signal to propagate " Frédéric Danis
2025-05-23  7:26 ` [PATCH BlueZ v4 3/4] doc/device: Add Disconnected signal Frédéric Danis
2025-05-23  7:26 ` Frédéric Danis [this message]
2025-05-23 15:20 ` [PATCH BlueZ v4 0/4] Propagate disconnection reason patchwork-bot+bluetooth

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=20250523072647.689324-5-frederic.danis@collabora.com \
    --to=frederic.danis@collabora.com \
    --cc=linux-bluetooth@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox