2014-05-27 15:17:45

by Lukasz Rymanowski

[permalink] [raw]
Subject: [PATCH 1/2] tools/btmgmt: Add set-io-cap command

This is needed for testing e.g. PTS
---
tools/btmgmt.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 0618de1..ca16d85 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -2225,6 +2225,49 @@ 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,
+ void *user_data)
+{
+ if (status != 0)
+ fprintf(stderr, "Could not set IO Capability with "
+ "status 0x%02x (%s)\n",
+ status, mgmt_errstr(status));
+ else
+ printf("IO Capabilities successfully set\n");
+
+ mainloop_quit();
+}
+
+static void set_io_cap_usage(void)
+{
+ printf("Usage: btmgmt [cap]\n");
+}
+
+static void cmd_set_io_cap(struct mgmt *mgmt, uint16_t index,
+ int argc, char **argv)
+{
+ struct mgmt_cp_set_io_capability cp;
+ uint8_t cap = 0x01;
+
+ if (argc < 2) {
+ set_io_cap_usage();
+ exit(EXIT_FAILURE);
+ }
+
+ if (index == MGMT_INDEX_NONE)
+ index = 0;
+
+ cap = atoi(argv[1]);
+ memset(&cp, 0, sizeof(cp));
+ cp.io_capability = cap;
+
+ if (mgmt_send(mgmt, MGMT_OP_SET_IO_CAPABILITY, index, sizeof(cp), &cp,
+ set_io_cap_rsp, NULL, NULL) == 0) {
+ fprintf(stderr, "Unable to send set-io-cap cmd\n");
+ exit(EXIT_FAILURE);
+ }
+}
+
static struct {
char *cmd;
void (*func)(struct mgmt *mgmt, uint16_t index, int argc, char **argv);
@@ -2268,6 +2311,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" },
{ }
};

--
1.8.4



2014-05-31 16:22:40

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH 1/2] tools/btmgmt: Add set-io-cap command

Hi Lukasz,

On Tue, May 27, 2014, Lukasz Rymanowski wrote:
> +static void cmd_set_io_cap(struct mgmt *mgmt, uint16_t index,
> + int argc, char **argv)
> +{
> + struct mgmt_cp_set_io_capability cp;
> + uint8_t cap = 0x01;

No reason to set this here as you anyway overwrite it later.

> + cap = atoi(argv[1]);

strtol makes more sense (to support hex too) and is consistent to how
this is decoded for the pair command.

Since I needed this feature myself I fixed these things up with --amend
and pushed the patch. Thanks.

Johan

2014-05-27 15:17:46

by Lukasz Rymanowski

[permalink] [raw]
Subject: [PATCH 2/2] android/pts: Update SM PTS test results

Rerun TC_JW_* test cases
---
android/pts-sm.txt | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/android/pts-sm.txt b/android/pts-sm.txt
index 0792de8..8f750bb 100644
--- a/android/pts-sm.txt
+++ b/android/pts-sm.txt
@@ -18,11 +18,12 @@ TC_PROT_BV_01_C PASS
TC_PROT_BV_02_C FAIL JIRA: BZ-24
btmgmt advertising on
TC_JW_BV_01_C FAIL JIRA: BZ-25
-TC_JW_BV_02_C INC JIRA: BZ-26
+TC_JW_BV_02_C PASS
TC_JW_BV_05_C INC
TC_JW_BI_01_C PASS
-TC_JW_BI_02_C INC
-TC_JW_BI_03_C INC
+TC_JW_BI_02_C PASS
+TC_JW_BI_03_C PASS btmgmt:
+ btmgmt set-io-cap 3
TC_JW_BI_04_C FAIL
TC_PKE_BV_01_C FAIL
TC_PKE_BV_02_C INC
--
1.8.4