Skip to contentSkip to conversation

client/print: Add decoding for UUID properties

PATCH Applied Luiz Augusto von Dentz 3 participants 3 messages Sep 18, 2024 – Sep 19, 2024 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 client/print: Add decoding for UUID properties

From: Luiz Augusto von Dentz <[email protected]>

This adds proper decoding for UUID properties with usage of bt_uuidstr_to_str so it can print the 'friendly' name as bellow:

bluetoothctl# transport.show /org/bluez/hci0/dev_94_DB_56_F7_F2_88/sep4/fd0 Transport /org/bluez/hci0/dev_94_DB_56_F7_F2_88/sep4/fd0

	UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
...
---
 client/main.c  | 33 +++------------------------------
 client/print.c | 33 +++++++++++++++++++++++++++++++++
 client/print.h |  1 +
 3 files changed, 37 insertions(+), 30 deletions(-)
client/main.c +3 -30
index a6217e03327b..50aa3e7a6cbe 100644
@@ -221,33 +221,6 @@ done:
 					address, name);
 }
 
-static void print_uuid(const char *label, const char *uuid)
-{
-	const char *text;
-
-	text = bt_uuidstr_to_str(uuid);
-	if (text) {
-		char str[26];
-		unsigned int n;
-
-		str[sizeof(str) - 1] = '\0';
-
-		n = snprintf(str, sizeof(str), "%s", text);
-		if (n > sizeof(str) - 1) {
-			str[sizeof(str) - 2] = '.';
-			str[sizeof(str) - 3] = '.';
-			if (str[sizeof(str) - 4] == ' ')
-				str[sizeof(str) - 4] = '.';
-
-			n = sizeof(str) - 1;
-		}
-
-		bt_shell_printf("\t%s: %s%*c(%s)\n", label, str, 26 - n, ' ',
-									uuid);
-	} else
-		bt_shell_printf("\t%s: %*c(%s)\n", label, 26, ' ', uuid);
-}
-
 static void print_uuids(GDBusProxy *proxy)
 {
 	DBusMessageIter iter, value;
@@ -262,7 +235,7 @@ static void print_uuids(GDBusProxy *proxy)
 
 		dbus_message_iter_get_basic(&value, &uuid);
 
-		print_uuid("UUID", uuid);
+		print_uuid("\t", "UUID", uuid);
 
 		dbus_message_iter_next(&value);
 	}
@@ -283,7 +256,7 @@ static void print_experimental(GDBusProxy *proxy)
 
 		dbus_message_iter_get_basic(&value, &uuid);
 
-		print_uuid("ExperimentalFeatures", uuid);
+		print_uuid("\t", "ExperimentalFeatures", uuid);
 
 		dbus_message_iter_next(&value);
 	}
@@ -1376,7 +1349,7 @@ static void cmd_scan_filter_uuids(int argc, char *argv[])
 		char **uuid;
 
 		for (uuid = filter.uuids; uuid && *uuid; uuid++)
-			print_uuid("UUID", *uuid);
+			print_uuid("\t", "UUID", *uuid);
 
 		return bt_shell_noninteractive_quit(EXIT_SUCCESS);
 	}
client/print.c +33 -0
index 8d721e21df4b..39f8567eedd3 100644
@@ -116,6 +116,12 @@ void print_iter(const char *label, const char *name, DBusMessageIter *iter)
 		bt_shell_printf("%s%s is invalid\n", label, name);
 		break;
 	case DBUS_TYPE_STRING:
+		if (!strcasecmp(name, "UUID")) {
+			dbus_message_iter_get_basic(iter, &valstr);
+			print_uuid(label, name, valstr);
+			break;
+		}
+		/* fall through */
 	case DBUS_TYPE_OBJECT_PATH:
 		dbus_message_iter_get_basic(iter, &valstr);
 		bt_shell_printf("%s%s: %s\n", label, name, valstr);
@@ -203,3 +209,30 @@ void print_property(GDBusProxy *proxy, const char *name)
 {
 	print_property_with_label(proxy, name, NULL);
 }
+
+void print_uuid(const char *label, const char *name, const char *uuid)
+{
+	const char *text;
+
+	text = bt_uuidstr_to_str(uuid);
+	if (text) {
+		char str[26];
+		unsigned int n;
+
+		str[sizeof(str) - 1] = '\0';
+
+		n = snprintf(str, sizeof(str), "%s", text);
+		if (n > sizeof(str) - 1) {
+			str[sizeof(str) - 2] = '.';
+			str[sizeof(str) - 3] = '.';
+			if (str[sizeof(str) - 4] == ' ')
+				str[sizeof(str) - 4] = '.';
+
+			n = sizeof(str) - 1;
+		}
+
+		bt_shell_printf("%s%s: %s%*c(%s)\n", label, name, str, 26 - n,
+								' ', uuid);
+	} else
+		bt_shell_printf("%s%s: %*c(%s)\n", label, name, 26, ' ', uuid);
+}
client/print.h +1 -0
index c0866d06c504..56bcce16a661 100644
@@ -12,3 +12,4 @@ void print_property(GDBusProxy *proxy, const char *name);
 void print_property_with_label(GDBusProxy *proxy, const char *name,
 					const char *label);
 void print_iter(const char *label, const char *name, DBusMessageIter *iter);
+void print_uuid(const char *label, const char *name, const char *uuid);
Signature · 1 line
2.46.0
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=891253

---Test result---

Test Summary:

CheckPatch                    FAIL      0.69 seconds
GitLint                       FAIL      0.53 seconds
BuildEll                      PASS      24.06 seconds
BluezMake                     PASS      1598.31 seconds
MakeCheck                     PASS      13.09 seconds
MakeDistcheck                 PASS      176.33 seconds
CheckValgrind                 PASS      247.69 seconds
CheckSmatch                   PASS      349.49 seconds
bluezmakeextell               PASS      118.02 seconds
IncrementalBuild              PASS      1475.52 seconds
ScanBuild                     PASS      1010.27 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,v1] client/print: Add decoding for UUID properties WARNING:PREFER_FALLTHROUGH: Prefer 'fallthrough;' over fallthrough comment #182: FILE: client/print.c:124:
+ /* fall through */

/github/workspace/src/src/13807128.patch total: 0 errors, 1 warnings, 103 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/src/13807128.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ,v1] client/print: Add decoding for UUID properties

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
10: B3 Line contains hard tab characters (\t): " UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb)"

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Luiz Augusto von Dentz
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 11 lines · On Wed, 18 Sep 2024 15:27:07 -0400 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

This adds proper decoding for UUID properties with usage of bt_uuidstr_to_str so it can print the 'friendly' name as bellow:

bluetoothctl# transport.show /org/bluez/hci0/dev_94_DB_56_F7_F2_88/sep4/fd0 Transport /org/bluez/hci0/dev_94_DB_56_F7_F2_88/sep4/fd0

	UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)

...

[...]

Here is the summary with links:
- [BlueZ,v1] client/print: Add decoding for UUID properties

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=b22859e3cc0b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html