@@ -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);
}
@@ -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);
+}
@@ -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);
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> 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(-)