diff options
author | Arun Kumar Singh <arunkat@gmail.com> | 2011-02-28 15:18:50 -0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2011-03-01 16:16:35 -0300 |
commit | 265059a149c78e780bdbed275feb250ab5276a65 (patch) | |
tree | d652e526d89e97d4a61d886d557bdad55e985e3b /tools/hcitool.c | |
parent | a0ba561d9077d6e43ebbd124c2f3959b8695fb24 (diff) | |
download | bluez-265059a149c78e780bdbed275feb250ab5276a65.tar.gz |
hcitool: Add command to add a device to LE White List
Diffstat (limited to 'tools/hcitool.c')
-rw-r--r-- | tools/hcitool.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tools/hcitool.c b/tools/hcitool.c index ebc8448b3..1184b6bc2 100644 --- a/tools/hcitool.c +++ b/tools/hcitool.c @@ -2564,6 +2564,52 @@ static void cmd_lecc(int dev_id, int argc, char **argv) hci_close_dev(dd); } +static struct option lewladd_options[] = { + { "help", 0, 0, 'h' }, + { 0, 0, 0, 0 } +}; + +static const char *lewladd_help = + "Usage:\n" + "\tlewladd <bdaddr>\n"; + +static void cmd_lewladd(int dev_id, int argc, char **argv) +{ + int err, opt, dd; + bdaddr_t bdaddr; + + for_each_opt(opt, lewladd_options, NULL) { + switch (opt) { + default: + printf("%s", lewladd_help); + return; + } + } + + helper_arg(1, 1, &argc, &argv, lewladd_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_add_white_list(dd, &bdaddr, LE_PUBLIC_ADDRESS, 1000); + hci_close_dev(dd); + + if (err < 0) { + err = errno; + fprintf(stderr, "Can't add to white list: %s(%d)\n", + strerror(err), err); + exit(1); + } +} + static struct option ledc_options[] = { { "help", 0, 0, 'h' }, { 0, 0, 0, 0 } @@ -2725,6 +2771,7 @@ static struct { { "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" }, |