[PATCH BlueZ v2 5/5] client: Rework handling of Disconnected signal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

Print with color the signal to indicate there is a change, also rework
the order of the parameters and use bearer specific suffix if the signal
comes from org.bluez.Bearer.*.
---
 client/main.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/client/main.c b/client/main.c
index 09df7b37c46f..0a928efaa9bb 100644
--- a/client/main.c
+++ b/client/main.c
@@ -806,7 +806,11 @@ 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 *iface = dbus_message_get_interface(message);
+	const char *member = dbus_message_get_member(message);
+
+	if (!strcmp(member, "Disconnected")) {
+		const char *label;
 		const char *name;
 		const char *msg;
 
@@ -816,16 +820,22 @@ static void message_handler(DBusConnection *connection,
 					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);
+		if (!strcmp(iface, "org.bluez.Bearer.BREDR1"))
+			label = "BREDR.Disconnected";
+		else if (!strcmp(iface, "org.bluez.Bearer.LE1"))
+			label = "LE.Disconnected";
+		else
+			label = "Disconnected";
+
+		bt_shell_printf("[" COLOR_YELLOW "SIGNAL" COLOR_OFF"] "
+					"%s - %s, %s\n",
+					label, name, msg);
 		return;
 	}
 
 failed:
-	bt_shell_printf("[SIGNAL] %s.%s\n", dbus_message_get_interface(message),
-					dbus_message_get_member(message));
+	bt_shell_printf("[" COLOR_YELLOW "SIGNAL" COLOR_OFF"] %s.%s\n",
+					iface, member);
 }
 
 static struct adapter *find_ctrl_by_address(GList *source, const char *address)
-- 
2.50.0





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux