summaryrefslogtreecommitdiff
path: root/client/main.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2018-07-24 16:03:07 +0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2018-07-30 09:36:23 +0300
commit2796d545e82659541333050557d5dbb89a295ae7 (patch)
tree17ed70912f31a77e90dbcdcb9c3916381d501e49 /client/main.c
parent6e2eb99f666ea7084067196472ff8d49e06f90d9 (diff)
downloadbluez-2796d545e82659541333050557d5dbb89a295ae7.tar.gz
client: Add discoverable-timeout command
This adds discoverable-timeout command which can be used to get/set DiscoverableTimeout property: [bluetooth]# discoverable-timeout 180 Changing discoverable-timeout 180 succeeded
Diffstat (limited to 'client/main.c')
-rw-r--r--client/main.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/client/main.c b/client/main.c
index 87323d8f7..59820c6d9 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1061,6 +1061,47 @@ static void cmd_discoverable(int argc, char *argv[])
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
+static void cmd_discoverable_timeout(int argc, char *argv[])
+{
+ uint32_t value;
+ char *endptr = NULL;
+ char *str;
+
+ if (argc < 2) {
+ DBusMessageIter iter;
+
+ if (!g_dbus_proxy_get_property(default_ctrl->proxy,
+ "DiscoverableTimeout", &iter)) {
+ bt_shell_printf("Unable to get DiscoverableTimeout\n");
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ dbus_message_iter_get_basic(&iter, &value);
+
+ bt_shell_printf("DiscoverableTimeout: %d seconds\n", value);
+
+ return;
+ }
+
+ value = strtol(argv[1], &endptr, 0);
+ if (!endptr || *endptr != '\0' || value > UINT32_MAX) {
+ bt_shell_printf("Invalid argument\n");
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ str = g_strdup_printf("discoverable-timeout %d", value);
+
+ if (g_dbus_proxy_set_property_basic(default_ctrl->proxy,
+ "DiscoverableTimeout",
+ DBUS_TYPE_UINT32, &value,
+ generic_callback, str, g_free))
+ return;
+
+ g_free(str);
+
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+}
+
static void cmd_agent(int argc, char *argv[])
{
dbus_bool_t enable;
@@ -2549,6 +2590,8 @@ static const struct bt_shell_menu main_menu = {
{ "discoverable", "<on/off>", cmd_discoverable,
"Set controller discoverable mode",
NULL },
+ { "discoverable-timeout", "[value]", cmd_discoverable_timeout,
+ "Set discoverable timeout", NULL },
{ "agent", "<on/off/capability>", cmd_agent,
"Enable/disable agent with given capability",
capability_generator},