* [PATCH 1/3] Remove unneeded comma in the hcitool commands declaration
@ 2011-02-22 21:42 Claudio Takahasi
2011-02-22 21:42 ` [PATCH 2/3] Add hci utility function to change LE connection parameters Claudio Takahasi
2011-02-22 21:42 ` [PATCH 3/3] Add hcitool command to change the parameters of a given LE connection Claudio Takahasi
0 siblings, 2 replies; 4+ messages in thread
From: Claudio Takahasi @ 2011-02-22 21:42 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
---
tools/hcitool.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/hcitool.c b/tools/hcitool.c
index d7a82cc..875e25e 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -2563,8 +2563,8 @@ static struct {
{ "clkoff", cmd_clkoff, "Read clock offset" },
{ "clock", cmd_clock, "Read local or remote clock" },
{ "lescan", cmd_lescan, "Start LE scan" },
- { "lecc", cmd_lecc, "Create a LE Connection", },
- { "ledc", cmd_ledc, "Disconnect a LE Connection", },
+ { "lecc", cmd_lecc, "Create a LE Connection" },
+ { "ledc", cmd_ledc, "Disconnect a LE Connection" },
{ NULL, NULL, 0 }
};
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] Add hci utility function to change LE connection parameters
2011-02-22 21:42 [PATCH 1/3] Remove unneeded comma in the hcitool commands declaration Claudio Takahasi
@ 2011-02-22 21:42 ` Claudio Takahasi
2011-02-22 21:42 ` [PATCH 3/3] Add hcitool command to change the parameters of a given LE connection Claudio Takahasi
1 sibling, 0 replies; 4+ messages in thread
From: Claudio Takahasi @ 2011-02-22 21:42 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
---
lib/hci.c | 37 +++++++++++++++++++++++++++++++++++++
lib/hci_lib.h | 4 ++++
2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/lib/hci.c b/lib/hci.c
index 048fda4..688b0b4 100644
--- a/lib/hci.c
+++ b/lib/hci.c
@@ -2767,3 +2767,40 @@ int hci_le_create_conn(int dd, uint16_t interval, uint16_t window,
return 0;
}
+
+int hci_le_conn_update(int dd, uint16_t handle, uint16_t min_interval,
+ uint16_t max_interval, uint16_t latency,
+ uint16_t supervision_timeout, int to)
+{
+ evt_le_connection_update_complete evt;
+ le_connection_update_cp cp;
+ struct hci_request rq;
+
+ memset(&cp, 0, sizeof(cp));
+ cp.handle = handle;
+ cp.min_interval = min_interval;
+ cp.max_interval = max_interval;
+ cp.latency = latency;
+ cp.supervision_timeout = supervision_timeout;
+ cp.min_ce_length = htobs(0x0001);
+ cp.max_ce_length = htobs(0x0001);
+
+ memset(&rq, 0, sizeof(rq));
+ rq.ogf = OGF_LE_CTL;
+ rq.ocf = OCF_LE_CONN_UPDATE;
+ rq.cparam = &cp;
+ rq.clen = LE_CONN_UPDATE_CP_SIZE;
+ rq.event = EVT_LE_CONN_UPDATE_COMPLETE;
+ rq.rparam = &evt;
+ rq.rlen = sizeof(evt);
+
+ if (hci_send_req(dd, &rq, to) < 0)
+ return -1;
+
+ if (evt.status) {
+ errno = EIO;
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/lib/hci_lib.h b/lib/hci_lib.h
index b63a2a4..5be8d50 100644
--- a/lib/hci_lib.h
+++ b/lib/hci_lib.h
@@ -128,6 +128,10 @@ int hci_le_create_conn(int dd, uint16_t interval, uint16_t window,
uint16_t min_ce_length, uint16_t max_ce_length,
uint16_t *handle, int to);
+int hci_le_conn_update(int dd, uint16_t handle, uint16_t min_interval,
+ uint16_t max_interval, uint16_t latency,
+ uint16_t supervision_timeout, int to);
+
int hci_for_each_dev(int flag, int(*func)(int dd, int dev_id, long arg), long arg);
int hci_get_route(bdaddr_t *bdaddr);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] Add hcitool command to change the parameters of a given LE connection
2011-02-22 21:42 [PATCH 1/3] Remove unneeded comma in the hcitool commands declaration Claudio Takahasi
2011-02-22 21:42 ` [PATCH 2/3] Add hci utility function to change LE connection parameters Claudio Takahasi
@ 2011-02-22 21:42 ` Claudio Takahasi
2011-02-23 3:29 ` Johan Hedberg
1 sibling, 1 reply; 4+ messages in thread
From: Claudio Takahasi @ 2011-02-22 21:42 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
Allows the LE master to start the Connection Parameter Update Procedure.
Parameters values consistency are not verified on purpose allowing
invalid values to test fail scenarios.
---
tools/hcitool.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 875e25e..8c147bf 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -2533,6 +2533,91 @@ static void cmd_ledc(int dev_id, int argc, char **argv)
hci_close_dev(dd);
}
+static struct option lecup_options[] = {
+ { "help", 0, 0, 'h' },
+ { "handle", 1, 0, 'H' },
+ { "min", 1, 0, 'm' },
+ { "max", 1, 0, 'M' },
+ { "latency", 1, 0, 'l' },
+ { "timeout", 1, 0, 't' },
+ { 0, 0, 0, 0 }
+};
+
+static const char *lecup_help =
+ "Usage:\n"
+ "\tlecup <handle> <min> <max> <latency> <timeout>\n"
+ "\tOptions:\n"
+ "\t -H, --handle <0xXXXX> LE connection handle\n"
+ "\t -m, --min <interval> Range: 0x0006 to 0x0C80\n"
+ "\t -M, --max <interval> Range: 0x0006 to 0x0C80\n"
+ "\t -l, --latency <range> Slave latency. Range: 0x0000 to 0x03E8\n"
+ "\t -t, --timeout <time> N * 10ms. Range: 0x000A to 0x0C80\n"
+ "\n\t min/max range: 7.5ms to 4s. Multiply factor: 1.25ms"
+ "\n\t timeout range: 100ms to 32.0s. Larger than max interval\n";
+
+static void cmd_lecup(int dev_id, int argc, char **argv)
+{
+ uint16_t handle = 0, min, max, latency, timeout;
+ int opt, dd, base;
+
+ /* Aleatory valid values */
+ min = 0x0C8;
+ max = 0x0960;
+ latency = 0x0007;
+ timeout = 0x0C80;
+
+ for_each_opt(opt, lecup_options, NULL) {
+ if (optarg && strncasecmp("0x", optarg, 2) == 0)
+ base = 16;
+ else
+ base = 10;
+
+ switch (opt) {
+ case 'H':
+ handle = strtoul(optarg, NULL, base);
+ break;
+ case 'm':
+ min = strtoul(optarg, NULL, base);
+ break;
+ case 'M':
+ max = strtoul(optarg, NULL, base);
+ break;
+ case 'l':
+ latency = strtoul(optarg, NULL, base);
+ break;
+ case 't':
+ timeout = strtoul(optarg, NULL, base);
+ break;
+ default:
+ printf("%s", lecup_help);
+ return;
+ }
+ }
+
+ if (handle == 0) {
+ printf("%s", lecup_help);
+ return;
+ }
+
+ if (dev_id < 0)
+ dev_id = hci_get_route(NULL);
+
+ dd = hci_open_dev(dev_id);
+ if (dd < 0) {
+ fprintf(stderr, "HCI device open failed\n");
+ exit(1);
+ }
+
+ if (hci_le_conn_update(dd, htobs(handle), htobs(min), htobs(max),
+ htobs(latency), htobs(timeout), 5000) < 0) {
+ int err = errno;
+ fprintf(stderr, "Could not change connection params: %s(%d)\n",
+ strerror(err), err);
+ }
+
+ hci_close_dev(dd);
+}
+
static struct {
char *cmd;
void (*func)(int dev_id, int argc, char **argv);
@@ -2565,6 +2650,7 @@ static struct {
{ "lescan", cmd_lescan, "Start LE scan" },
{ "lecc", cmd_lecc, "Create a LE Connection" },
{ "ledc", cmd_ledc, "Disconnect a LE Connection" },
+ { "lecup", cmd_lecup, "LE Connection Update" },
{ NULL, NULL, 0 }
};
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3] Add hcitool command to change the parameters of a given LE connection
2011-02-22 21:42 ` [PATCH 3/3] Add hcitool command to change the parameters of a given LE connection Claudio Takahasi
@ 2011-02-23 3:29 ` Johan Hedberg
0 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2011-02-23 3:29 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
Hi Claudio,
On Tue, Feb 22, 2011, Claudio Takahasi wrote:
> Allows the LE master to start the Connection Parameter Update Procedure.
> Parameters values consistency are not verified on purpose allowing
> invalid values to test fail scenarios.
> ---
> tools/hcitool.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
All three patches have been pushed upstream. Thanks.
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-02-23 3:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-22 21:42 [PATCH 1/3] Remove unneeded comma in the hcitool commands declaration Claudio Takahasi
2011-02-22 21:42 ` [PATCH 2/3] Add hci utility function to change LE connection parameters Claudio Takahasi
2011-02-22 21:42 ` [PATCH 3/3] Add hcitool command to change the parameters of a given LE connection Claudio Takahasi
2011-02-23 3:29 ` Johan Hedberg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.