2014-06-03 10:13:33

by Andrzej Kaczmarek

[permalink] [raw]
Subject: [PATCH 1/4] tools/btmgmt: Add scan-params command

---
tools/btmgmt.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 0c42e17..2742dfc 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -2383,6 +2383,46 @@ static void cmd_set_io_cap(struct mgmt *mgmt, uint16_t index,
}
}

+static void 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 scan_params_usage(void)
+{
+ printf("Usage: btmgmt scan-params <interval> <window>\n");
+}
+
+static void cmd_scan_params(struct mgmt *mgmt, uint16_t index,
+ int argc, char **argv)
+{
+ struct mgmt_cp_set_scan_params cp;
+
+ if (argc < 3) {
+ scan_params_usage();
+ exit(EXIT_FAILURE);
+ }
+
+ if (index == MGMT_INDEX_NONE)
+ index = 0;
+
+ cp.interval = strtol(argv[1], NULL, 0);
+ cp.window = strtol(argv[2], NULL, 0);
+
+ if (mgmt_send(mgmt, MGMT_OP_SET_SCAN_PARAMS, index, sizeof(cp), &cp,
+ 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);
@@ -2427,6 +2467,7 @@ static struct {
{ "debug-keys", cmd_debug_keys, "Toogle debug keys" },
{ "conn-info", cmd_conn_info, "Get connection information" },
{ "set-io-cap", cmd_set_io_cap, "Set IO Capability" },
+ { "scan-params",cmd_scan_params,"Set Scan Parameters" },
{ }
};

--
1.9.3



2014-06-03 10:41:27

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH 1/4] tools/btmgmt: Add scan-params command

Hi Andrzej,

On Tue, Jun 03, 2014, Andrzej Kaczmarek wrote:
> ---
> tools/btmgmt.c | 41 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)

All four patches have been applied. Thanks.

Johan

2014-06-03 10:13:36

by Andrzej Kaczmarek

[permalink] [raw]
Subject: [PATCH 4/4] tools/btmgmt: Trival whitespace fix

---
tools/btmgmt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 22fc547..8f5a981 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -2443,7 +2443,7 @@ static struct {
{ "hs", cmd_hs, "Toggle HS support" },
{ "le", cmd_le, "Toggle LE support" },
{ "advertising",cmd_advertising,"Toggle LE advertising", },
- { "bredr", cmd_bredr, "Toggle BR/EDR support", },
+ { "bredr", cmd_bredr, "Toggle BR/EDR support", },
{ "privacy", cmd_privacy, "Toggle privacy support" },
{ "class", cmd_class, "Set device major/minor class" },
{ "disconnect", cmd_disconnect, "Disconnect device" },
--
1.9.3


2014-06-03 10:13:35

by Andrzej Kaczmarek

[permalink] [raw]
Subject: [PATCH 3/4] tools/btmgmt: Fix io-cap usage message

---
tools/btmgmt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 412856d..22fc547 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -2355,7 +2355,7 @@ static void io_cap_rsp(uint8_t status, uint16_t len, const void *param,

static void io_cap_usage(void)
{
- printf("Usage: btmgmt [cap]\n");
+ printf("Usage: btmgmt io-cap <cap>\n");
}

static void cmd_io_cap(struct mgmt *mgmt, uint16_t index,
--
1.9.3


2014-06-03 10:13:34

by Andrzej Kaczmarek

[permalink] [raw]
Subject: [PATCH 2/4] tools/btmgmt: Rename set-io-cap to io-cap

Every other 'set-something' command is just called 'something', so
let's keep this consistent.
---
tools/btmgmt.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 2742dfc..412856d 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -2340,7 +2340,7 @@ static void cmd_conn_info(struct mgmt *mgmt, uint16_t index,
}
}

-static void set_io_cap_rsp(uint8_t status, uint16_t len, const void *param,
+static void io_cap_rsp(uint8_t status, uint16_t len, const void *param,
void *user_data)
{
if (status != 0)
@@ -2353,19 +2353,19 @@ static void set_io_cap_rsp(uint8_t status, uint16_t len, const void *param,
mainloop_quit();
}

-static void set_io_cap_usage(void)
+static void io_cap_usage(void)
{
printf("Usage: btmgmt [cap]\n");
}

-static void cmd_set_io_cap(struct mgmt *mgmt, uint16_t index,
+static void cmd_io_cap(struct mgmt *mgmt, uint16_t index,
int argc, char **argv)
{
struct mgmt_cp_set_io_capability cp;
uint8_t cap;

if (argc < 2) {
- set_io_cap_usage();
+ io_cap_usage();
exit(EXIT_FAILURE);
}

@@ -2377,7 +2377,7 @@ static void cmd_set_io_cap(struct mgmt *mgmt, uint16_t index,
cp.io_capability = cap;

if (mgmt_send(mgmt, MGMT_OP_SET_IO_CAPABILITY, index, sizeof(cp), &cp,
- set_io_cap_rsp, NULL, NULL) == 0) {
+ io_cap_rsp, NULL, NULL) == 0) {
fprintf(stderr, "Unable to send set-io-cap cmd\n");
exit(EXIT_FAILURE);
}
@@ -2466,7 +2466,7 @@ static struct {
{ "static-addr",cmd_static_addr,"Set static address" },
{ "debug-keys", cmd_debug_keys, "Toogle debug keys" },
{ "conn-info", cmd_conn_info, "Get connection information" },
- { "set-io-cap", cmd_set_io_cap, "Set IO Capability" },
+ { "io-cap", cmd_io_cap, "Set IO Capability" },
{ "scan-params",cmd_scan_params,"Set Scan Parameters" },
{ }
};
--
1.9.3