From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 1/4] client: Add discoverable-timeout command
Date: Wed, 25 Jul 2018 13:20:23 +0300 [thread overview]
Message-ID: <20180725102027.19319-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds discoverable-timeout command which can be used to get/set
DiscoverableTimeout property:
[bluetooth]# discoverable-timeout 180
Changing discoverable-timeout 180 succeeded
---
client/main.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
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},
--
2.17.1
next reply other threads:[~2018-07-25 10:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-25 10:20 Luiz Augusto von Dentz [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-07-25 10:20 [PATCH BlueZ 1/4] client: Add discoverable-timeout command Luiz Augusto von Dentz
2018-07-26 12:43 ` Bastien Nocera
2018-07-30 6:54 ` Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180725102027.19319-1-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).