summaryrefslogtreecommitdiff
path: root/client/advertising.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-12-14 16:09:39 -0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2018-01-19 11:44:09 -0200
commit6f20dba32d398c5bdae56abc1ce7c234e5a047ca (patch)
treefef4ebb1e531f4f89f9f43b3ec47e0fed26b72c7 /client/advertising.c
parentb916c9decccc34a557e99be35b9a1c643a82b65a (diff)
downloadbluez-6f20dba32d398c5bdae56abc1ce7c234e5a047ca.tar.gz
client: Rename set-uuids to uuids
Make the command return the current value if no parameters: [bluetooth]# uuids 0x1820 [bluetooth]# uuids UUID: Internet Protocol Support (0x1820
Diffstat (limited to 'client/advertising.c')
-rw-r--r--client/advertising.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/client/advertising.c b/client/advertising.c
index f0fd3599e..5174417a8 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");