Diff between b916c9decccc34a557e99be35b9a1c643a82b65a and 6f20dba32d398c5bdae56abc1ce7c234e5a047ca

Changed Files

File Additions Deletions Status
client/advertising.c +36 -3 modified
client/main.c +3 -3 modified

Full Patch

diff --git a/client/advertising.c b/client/advertising.c
index f0fd359..5174417 100644
--- a/client/advertising.c
+++ b/client/advertising.c
@@ -32,6 +32,7 @@
 #include <string.h>
 
 #include "gdbus/gdbus.h"
+#include "src/shared/util.h"
 #include "src/shared/shell.h"
 #include "advertising.h"
 
@@ -434,15 +435,47 @@ void ad_unregister(DBusConnection *conn, GDBusProxy *manager)
 	}
 }
 
+static void print_uuid(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("\tUUID: %s(%s)\n", str, uuid);
+	} else
+		bt_shell_printf("\tUUID: (%s)\n", uuid);
+}
+
 void ad_advertise_uuids(DBusConnection *conn, int argc, char *argv[])
 {
+	if (argc < 2 || !strlen(argv[1])) {
+		char **uuid;
+
+		for (uuid = ad.uuids; uuid && *uuid; uuid++)
+			print_uuid(*uuid);
+
+		return;
+	}
+
 	g_strfreev(ad.uuids);
 	ad.uuids = NULL;
 	ad.uuids_len = 0;
 
-	if (argc < 2 || !strlen(argv[1]))
-		return;
-
 	ad.uuids = g_strdupv(&argv[1]);
 	if (!ad.uuids) {
 		bt_shell_printf("Failed to parse input\n");
diff --git a/client/main.c b/client/main.c
index a52599d..d13dabd 100644
--- a/client/main.c
+++ b/client/main.c
@@ -2191,7 +2191,7 @@ static char *ad_generator(const char *text, int state)
 	return argument_generator(text, state, ad_arguments);
 }
 
-static void cmd_set_advertise_uuids(int argc, char *argv[])
+static void cmd_advertise_uuids(int argc, char *argv[])
 {
 	ad_advertise_uuids(dbus_conn, argc, argv);
 }
@@ -2287,8 +2287,8 @@ static const struct bt_shell_menu advertise_menu = {
 	.name = "advertise",
 	.desc = "Advertise Options Submenu",
 	.entries = {
-	{ "set-uuids", "[uuid1 uuid2 ...]",
-			cmd_set_advertise_uuids, "Set advertise uuids" },
+	{ "uuids", "[uuid1 uuid2 ...]", cmd_advertise_uuids,
+			"Set advertise uuids" },
 	{ "set-service", "[uuid] [data=xx xx ...]", cmd_set_advertise_service,
 			"Set advertise service data" },
 	{ "set-manufacturer", "[id] [data=xx xx ...]",