From: Andre Guedes <andre.guedes@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] tools/btmgmt: Add command to set scan parameters
Date: Mon, 24 Feb 2014 19:32:27 -0300 [thread overview]
Message-ID: <1393281147-14390-1-git-send-email-andre.guedes@openbossa.org> (raw)
---
tools/btmgmt.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 9a5e971..dd90f34 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -2073,6 +2073,47 @@ static void cmd_debug_keys(struct mgmt *mgmt, uint16_t index,
cmd_setting(mgmt, index, MGMT_OP_SET_DEBUG_KEYS, argc, argv);
}
+static void set_scan_params_usage(void)
+{
+ printf("Usage: btmgmt set-scan-params <window> <interval>");
+}
+
+static void set_scan_params_rsp(uint8_t status, uint16_t len, const void *param,
+ void *user_data)
+{
+ if (status != 0)
+ fprintf(stderr, "Set scan parameters failed "
+ "with status 0x%02x (%s)\n",
+ status, mgmt_errstr(status));
+ else
+ printf("Scan parameters successfully set\n");
+
+ mainloop_quit();
+}
+
+static void cmd_set_scan_params(struct mgmt *mgmt, uint16_t index, int argc,
+ char **argv)
+{
+ struct mgmt_cp_set_scan_params cp;
+
+ if (argc != 3) {
+ set_scan_params_usage();
+ exit(EXIT_FAILURE);
+ }
+
+ if (index == MGMT_INDEX_NONE)
+ index = 0;
+
+ cp.window = strtol(argv[1], NULL, 16);
+ cp.interval = strtol(argv[2], NULL, 16);
+
+ if (mgmt_send(mgmt, MGMT_OP_SET_SCAN_PARAMS, index, sizeof(cp), &cp,
+ set_scan_params_rsp, NULL, NULL) == 0) {
+ fprintf(stderr, "Unable to send set_scan_params cmd\n");
+ exit(EXIT_FAILURE);
+ }
+}
+
static struct {
char *cmd;
void (*func)(struct mgmt *mgmt, uint16_t index, int argc, char **argv);
@@ -2115,6 +2156,7 @@ static struct {
{ "did", cmd_did, "Set Device ID" },
{ "static-addr",cmd_static_addr,"Set static address" },
{ "debug-keys", cmd_debug_keys, "Toogle debug keys" },
+ { "set-scan-params", cmd_set_scan_params, "Set scan parameters" },
{ }
};
--
1.8.5.4
reply other threads:[~2014-02-24 22:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1393281147-14390-1-git-send-email-andre.guedes@openbossa.org \
--to=andre.guedes@openbossa.org \
--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