* [PATCH 2/5] hcitool: Change commands struct formating
2011-02-28 18:18 [PATCH 1/5] hcitool: Add command to add a device to LE White List Claudio Takahasi
@ 2011-02-28 18:18 ` Claudio Takahasi
2011-02-28 18:18 ` [PATCH 3/5] hcitool: Add command to remove a device from LE white list Claudio Takahasi
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Claudio Takahasi @ 2011-02-28 18:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
---
tools/hcitool.c | 58 +++++++++++++++++++++++++++---------------------------
1 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 1184b6b..8945156 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -2746,35 +2746,35 @@ static struct {
void (*func)(int dev_id, int argc, char **argv);
char *doc;
} command[] = {
- { "dev", cmd_dev, "Display local devices" },
- { "inq", cmd_inq, "Inquire remote devices" },
- { "scan", cmd_scan, "Scan for remote devices" },
- { "name", cmd_name, "Get name from remote device" },
- { "info", cmd_info, "Get information from remote device" },
- { "spinq", cmd_spinq, "Start periodic inquiry" },
- { "epinq", cmd_epinq, "Exit periodic inquiry" },
- { "cmd", cmd_cmd, "Submit arbitrary HCI commands" },
- { "con", cmd_con, "Display active connections" },
- { "cc", cmd_cc, "Create connection to remote device" },
- { "dc", cmd_dc, "Disconnect from remote device" },
- { "sr", cmd_sr, "Switch master/slave role" },
- { "cpt", cmd_cpt, "Change connection packet type" },
- { "rssi", cmd_rssi, "Display connection RSSI" },
- { "lq", cmd_lq, "Display link quality" },
- { "tpl", cmd_tpl, "Display transmit power level" },
- { "afh", cmd_afh, "Display AFH channel map" },
- { "lp", cmd_lp, "Set/display link policy settings" },
- { "lst", cmd_lst, "Set/display link supervision timeout" },
- { "auth", cmd_auth, "Request authentication" },
- { "enc", cmd_enc, "Set connection encryption" },
- { "key", cmd_key, "Change connection link key" },
- { "clkoff", cmd_clkoff, "Read clock offset" },
- { "clock", cmd_clock, "Read local or remote clock" },
- { "lescan", cmd_lescan, "Start LE scan" },
- { "lewladd", cmd_lewladd, "Add device to LE White List" },
- { "lecc", cmd_lecc, "Create a LE Connection" },
- { "ledc", cmd_ledc, "Disconnect a LE Connection" },
- { "lecup", cmd_lecup, "LE Connection Update" },
+ { "dev", cmd_dev, "Display local devices" },
+ { "inq", cmd_inq, "Inquire remote devices" },
+ { "scan", cmd_scan, "Scan for remote devices" },
+ { "name", cmd_name, "Get name from remote device" },
+ { "info", cmd_info, "Get information from remote device" },
+ { "spinq", cmd_spinq, "Start periodic inquiry" },
+ { "epinq", cmd_epinq, "Exit periodic inquiry" },
+ { "cmd", cmd_cmd, "Submit arbitrary HCI commands" },
+ { "con", cmd_con, "Display active connections" },
+ { "cc", cmd_cc, "Create connection to remote device" },
+ { "dc", cmd_dc, "Disconnect from remote device" },
+ { "sr", cmd_sr, "Switch master/slave role" },
+ { "cpt", cmd_cpt, "Change connection packet type" },
+ { "rssi", cmd_rssi, "Display connection RSSI" },
+ { "lq", cmd_lq, "Display link quality" },
+ { "tpl", cmd_tpl, "Display transmit power level" },
+ { "afh", cmd_afh, "Display AFH channel map" },
+ { "lp", cmd_lp, "Set/display link policy settings" },
+ { "lst", cmd_lst, "Set/display link supervision timeout" },
+ { "auth", cmd_auth, "Request authentication" },
+ { "enc", cmd_enc, "Set connection encryption" },
+ { "key", cmd_key, "Change connection link key" },
+ { "clkoff", cmd_clkoff, "Read clock offset" },
+ { "clock", cmd_clock, "Read local or remote clock" },
+ { "lescan", cmd_lescan, "Start LE scan" },
+ { "lewladd", cmd_lewladd, "Add device to LE White List" },
+ { "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] 6+ messages in thread* [PATCH 3/5] hcitool: Add command to remove a device from LE white list
2011-02-28 18:18 [PATCH 1/5] hcitool: Add command to add a device to LE White List Claudio Takahasi
2011-02-28 18:18 ` [PATCH 2/5] hcitool: Change commands struct formating Claudio Takahasi
@ 2011-02-28 18:18 ` Claudio Takahasi
2011-02-28 18:18 ` [PATCH 4/5] hcitool: Add command to read size of LE White List Claudio Takahasi
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Claudio Takahasi @ 2011-02-28 18:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Arun Kumar Singh
From: Arun Kumar Singh <arunkat@gmail.com>
---
lib/hci.c | 29 +++++++++++++++++++++++++++++
lib/hci_lib.h | 1 +
tools/hcitool.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/lib/hci.c b/lib/hci.c
index fc710f4..0e1518c 100644
--- a/lib/hci.c
+++ b/lib/hci.c
@@ -1320,6 +1320,35 @@ int hci_le_add_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type, int to)
return 0;
}
+int hci_le_rm_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type, int to)
+{
+ struct hci_request rq;
+ le_remove_device_from_white_list_cp cp;
+ uint8_t status;
+
+ memset(&cp, 0, sizeof(cp));
+ cp.bdaddr_type = type;
+ bacpy(&cp.bdaddr, bdaddr);
+
+ memset(&rq, 0, sizeof(rq));
+ rq.ogf = OGF_LE_CTL;
+ rq.ocf = OCF_LE_REMOVE_DEVICE_FROM_WHITE_LIST;
+ rq.cparam = &cp;
+ rq.clen = LE_REMOVE_DEVICE_FROM_WHITE_LIST_CP_SIZE;
+ rq.rparam = &status;
+ rq.rlen = 1;
+
+ if (hci_send_req(dd, &rq, to) < 0)
+ return -1;
+
+ if (status) {
+ errno = EIO;
+ return -1;
+ }
+
+ return 0;
+}
+
int hci_read_local_name(int dd, int len, char *name, int to)
{
read_local_name_rp rp;
diff --git a/lib/hci_lib.h b/lib/hci_lib.h
index fb2c7cb..e894e8e 100644
--- a/lib/hci_lib.h
+++ b/lib/hci_lib.h
@@ -132,6 +132,7 @@ 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_le_add_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type, int to);
+int hci_le_rm_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type, 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);
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 8945156..bf0f25d 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -2610,6 +2610,52 @@ static void cmd_lewladd(int dev_id, int argc, char **argv)
}
}
+static struct option lewlrm_options[] = {
+ { "help", 0, 0, 'h' },
+ { 0, 0, 0, 0 }
+};
+
+static const char *lewlrm_help =
+ "Usage:\n"
+ "\tlewlrm <bdaddr>\n";
+
+static void cmd_lewlrm(int dev_id, int argc, char **argv)
+{
+ int err, opt, dd;
+ bdaddr_t bdaddr;
+
+ for_each_opt(opt, lewlrm_options, NULL) {
+ switch (opt) {
+ default:
+ printf("%s", lewlrm_help);
+ return;
+ }
+ }
+
+ helper_arg(1, 1, &argc, &argv, lewlrm_help);
+
+ if (dev_id < 0)
+ dev_id = hci_get_route(NULL);
+
+ dd = hci_open_dev(dev_id);
+ if (dd < 0) {
+ perror("Could not open device");
+ exit(1);
+ }
+
+ str2ba(argv[0], &bdaddr);
+
+ err = hci_le_rm_white_list(dd, &bdaddr, LE_PUBLIC_ADDRESS, 1000);
+ hci_close_dev(dd);
+
+ if (err < 0) {
+ err = errno;
+ fprintf(stderr, "Can't remove from white list: %s(%d)\n",
+ strerror(err), err);
+ exit(1);
+ }
+}
+
static struct option ledc_options[] = {
{ "help", 0, 0, 'h' },
{ 0, 0, 0, 0 }
@@ -2772,6 +2818,7 @@ static struct {
{ "clock", cmd_clock, "Read local or remote clock" },
{ "lescan", cmd_lescan, "Start LE scan" },
{ "lewladd", cmd_lewladd, "Add device to LE White List" },
+ { "lewlrm", cmd_lewlrm, "Remove device from LE White List" },
{ "lecc", cmd_lecc, "Create a LE Connection" },
{ "ledc", cmd_ledc, "Disconnect a LE Connection" },
{ "lecup", cmd_lecup, "LE Connection Update" },
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 4/5] hcitool: Add command to read size of LE White List
2011-02-28 18:18 [PATCH 1/5] hcitool: Add command to add a device to LE White List Claudio Takahasi
2011-02-28 18:18 ` [PATCH 2/5] hcitool: Change commands struct formating Claudio Takahasi
2011-02-28 18:18 ` [PATCH 3/5] hcitool: Add command to remove a device from LE white list Claudio Takahasi
@ 2011-02-28 18:18 ` Claudio Takahasi
2011-02-28 18:18 ` [PATCH 5/5] hcitool: Add command to clear " Claudio Takahasi
2011-03-01 19:19 ` [PATCH 1/5] hcitool: Add command to add a device to " Johan Hedberg
4 siblings, 0 replies; 6+ messages in thread
From: Claudio Takahasi @ 2011-02-28 18:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Arun Kumar Singh
From: Arun Kumar Singh <arunkat@gmail.com>
---
lib/hci.c | 27 +++++++++++++++++++++++++++
lib/hci_lib.h | 1 +
tools/hcitool.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/lib/hci.c b/lib/hci.c
index 0e1518c..9184e09 100644
--- a/lib/hci.c
+++ b/lib/hci.c
@@ -1349,6 +1349,33 @@ int hci_le_rm_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type, int to)
return 0;
}
+int hci_le_read_white_list_size(int dd, uint8_t *size, int to)
+{
+ struct hci_request rq;
+ le_read_white_list_size_rp rp;
+
+ memset(&rp, 0, sizeof(rp));
+ memset(&rq, 0, sizeof(rq));
+
+ rq.ogf = OGF_LE_CTL;
+ rq.ocf = OCF_LE_READ_WHITE_LIST_SIZE;
+ rq.rparam = &rp;
+ rq.rlen = LE_READ_WHITE_LIST_SIZE_RP_SIZE;
+
+ if (hci_send_req(dd, &rq, to) < 0)
+ return -1;
+
+ if (rp.status) {
+ errno = EIO;
+ return -1;
+ }
+
+ if (size)
+ *size = rp.size;
+
+ return 0;
+}
+
int hci_read_local_name(int dd, int len, char *name, int to)
{
read_local_name_rp rp;
diff --git a/lib/hci_lib.h b/lib/hci_lib.h
index e894e8e..ce1bb6c 100644
--- a/lib/hci_lib.h
+++ b/lib/hci_lib.h
@@ -133,6 +133,7 @@ int hci_le_conn_update(int dd, uint16_t handle, uint16_t min_interval,
uint16_t supervision_timeout, int to);
int hci_le_add_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type, int to);
int hci_le_rm_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type, int to);
+int hci_le_read_white_list_size(int dd, uint8_t *size, 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);
diff --git a/tools/hcitool.c b/tools/hcitool.c
index bf0f25d..427edc2 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -2656,6 +2656,52 @@ static void cmd_lewlrm(int dev_id, int argc, char **argv)
}
}
+static struct option lewlsz_options[] = {
+ { "help", 0, 0, 'h' },
+ { 0, 0, 0, 0 }
+};
+
+static const char *lewlsz_help =
+ "Usage:\n"
+ "\tlewlsz\n";
+
+static void cmd_lewlsz(int dev_id, int argc, char **argv)
+{
+ int err, dd, opt;
+ uint8_t size;
+
+ for_each_opt(opt, lewlsz_options, NULL) {
+ switch (opt) {
+ default:
+ printf("%s", lewlsz_help);
+ return;
+ }
+ }
+
+ helper_arg(0, 0, &argc, &argv, lewlsz_help);
+
+ if (dev_id < 0)
+ dev_id = hci_get_route(NULL);
+
+ dd = hci_open_dev(dev_id);
+ if (dd < 0) {
+ perror("Could not open device");
+ exit(1);
+ }
+
+ err = hci_le_read_white_list_size(dd, &size, 1000);
+ hci_close_dev(dd);
+
+ if (err < 0) {
+ err = errno;
+ fprintf(stderr, "Can't read white list size: %s(%d)\n",
+ strerror(err), err);
+ exit(1);
+ }
+
+ printf("White list size: %d\n", size);
+}
+
static struct option ledc_options[] = {
{ "help", 0, 0, 'h' },
{ 0, 0, 0, 0 }
@@ -2819,6 +2865,7 @@ static struct {
{ "lescan", cmd_lescan, "Start LE scan" },
{ "lewladd", cmd_lewladd, "Add device to LE White List" },
{ "lewlrm", cmd_lewlrm, "Remove device from LE White List" },
+ { "lewlsz", cmd_lewlsz, "Read size of LE White List" },
{ "lecc", cmd_lecc, "Create a LE Connection" },
{ "ledc", cmd_ledc, "Disconnect a LE Connection" },
{ "lecup", cmd_lecup, "LE Connection Update" },
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 5/5] hcitool: Add command to clear LE White List
2011-02-28 18:18 [PATCH 1/5] hcitool: Add command to add a device to LE White List Claudio Takahasi
` (2 preceding siblings ...)
2011-02-28 18:18 ` [PATCH 4/5] hcitool: Add command to read size of LE White List Claudio Takahasi
@ 2011-02-28 18:18 ` Claudio Takahasi
2011-03-01 19:19 ` [PATCH 1/5] hcitool: Add command to add a device to " Johan Hedberg
4 siblings, 0 replies; 6+ messages in thread
From: Claudio Takahasi @ 2011-02-28 18:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Arun Kumar Singh
From: Arun Kumar Singh <arunkat@gmail.com>
---
lib/hci.c | 22 ++++++++++++++++++++++
lib/hci_lib.h | 1 +
tools/hcitool.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/lib/hci.c b/lib/hci.c
index 9184e09..02fc0cf 100644
--- a/lib/hci.c
+++ b/lib/hci.c
@@ -1376,6 +1376,28 @@ int hci_le_read_white_list_size(int dd, uint8_t *size, int to)
return 0;
}
+int hci_le_clear_white_list(int dd, int to)
+{
+ struct hci_request rq;
+ uint8_t status;
+
+ memset(&rq, 0, sizeof(rq));
+ rq.ogf = OGF_LE_CTL;
+ rq.ocf = OCF_LE_CLEAR_WHITE_LIST;
+ rq.rparam = &status;
+ rq.rlen = 1;
+
+ if (hci_send_req(dd, &rq, to) < 0)
+ return -1;
+
+ if (status) {
+ errno = EIO;
+ return -1;
+ }
+
+ return 0;
+}
+
int hci_read_local_name(int dd, int len, char *name, int to)
{
read_local_name_rp rp;
diff --git a/lib/hci_lib.h b/lib/hci_lib.h
index ce1bb6c..de3e636 100644
--- a/lib/hci_lib.h
+++ b/lib/hci_lib.h
@@ -134,6 +134,7 @@ int hci_le_conn_update(int dd, uint16_t handle, uint16_t min_interval,
int hci_le_add_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type, int to);
int hci_le_rm_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type, int to);
int hci_le_read_white_list_size(int dd, uint8_t *size, int to);
+int hci_le_clear_white_list(int dd, 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);
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 427edc2..e79d76b 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -2702,6 +2702,49 @@ static void cmd_lewlsz(int dev_id, int argc, char **argv)
printf("White list size: %d\n", size);
}
+static struct option lewlclr_options[] = {
+ { "help", 0, 0, 'h' },
+ { 0, 0, 0, 0 }
+};
+
+static const char *lewlclr_help =
+ "Usage:\n"
+ "\tlewlclr\n";
+
+static void cmd_lewlclr(int dev_id, int argc, char **argv)
+{
+ int err, dd, opt;
+
+ for_each_opt(opt, lewlclr_options, NULL) {
+ switch (opt) {
+ default:
+ printf("%s", lewlclr_help);
+ return;
+ }
+ }
+
+ helper_arg(0, 0, &argc, &argv, lewlclr_help);
+
+ if (dev_id < 0)
+ dev_id = hci_get_route(NULL);
+
+ dd = hci_open_dev(dev_id);
+ if (dd < 0) {
+ perror("Could not open device");
+ exit(1);
+ }
+
+ err = hci_le_clear_white_list(dd, 1000);
+ hci_close_dev(dd);
+
+ if (err < 0) {
+ err = errno;
+ fprintf(stderr, "Can't clear white list: %s(%d)\n",
+ strerror(err), err);
+ exit(1);
+ }
+}
+
static struct option ledc_options[] = {
{ "help", 0, 0, 'h' },
{ 0, 0, 0, 0 }
@@ -2866,6 +2909,7 @@ static struct {
{ "lewladd", cmd_lewladd, "Add device to LE White List" },
{ "lewlrm", cmd_lewlrm, "Remove device from LE White List" },
{ "lewlsz", cmd_lewlsz, "Read size of LE White List" },
+ { "lewlclr", cmd_lewlclr, "Clear LE White list" },
{ "lecc", cmd_lecc, "Create a LE Connection" },
{ "ledc", cmd_ledc, "Disconnect a LE Connection" },
{ "lecup", cmd_lecup, "LE Connection Update" },
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 1/5] hcitool: Add command to add a device to LE White List
2011-02-28 18:18 [PATCH 1/5] hcitool: Add command to add a device to LE White List Claudio Takahasi
` (3 preceding siblings ...)
2011-02-28 18:18 ` [PATCH 5/5] hcitool: Add command to clear " Claudio Takahasi
@ 2011-03-01 19:19 ` Johan Hedberg
4 siblings, 0 replies; 6+ messages in thread
From: Johan Hedberg @ 2011-03-01 19:19 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth, Arun Kumar Singh
Hi Claudio,
On Mon, Feb 28, 2011, Claudio Takahasi wrote:
> From: Arun Kumar Singh <arunkat@gmail.com>
>
> ---
> lib/hci.c | 29 +++++++++++++++++++++++++++++
> lib/hci.h | 6 ++++++
> lib/hci_lib.h | 2 +-
> tools/hcitool.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 83 insertions(+), 1 deletions(-)
All five patches have been pushed upstream. Thanks for sorting them out
and resending.
Johan
^ permalink raw reply [flat|nested] 6+ messages in thread