summaryrefslogtreecommitdiff
path: root/tools/hcitool.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2014-09-29 11:55:22 +0200
committerMarcel Holtmann <marcel@holtmann.org>2014-09-29 11:55:22 +0200
commit9838cb51c36c58036858b19df9804275e33cd36f (patch)
tree33f89f32d0d0beba77d7d6e90a471560ba1aec57 /tools/hcitool.c
parent212245a0976be6afde0d046482cea1af923bf0a9 (diff)
downloadbluez-9838cb51c36c58036858b19df9804275e33cd36f.tar.gz
tools: Add comment for retrieving LE remote features
Diffstat (limited to 'tools/hcitool.c')
-rw-r--r--tools/hcitool.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 41386a6d4..d51c6885f 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -2557,6 +2557,90 @@ static void cmd_lescan(int dev_id, int argc, char **argv)
hci_close_dev(dd);
}
+static struct option leinfo_options[] = {
+ { "help", 0, 0, 'h' },
+ { "random", 0, 0, 'r' },
+ { 0, 0, 0, 0 }
+};
+
+static const char *leinfo_help =
+ "Usage:\n"
+ "\tleinfo [--random] <bdaddr>\n";
+
+static void cmd_leinfo(int dev_id, int argc, char **argv)
+{
+ bdaddr_t bdaddr;
+ uint8_t bdaddr_type;
+ uint16_t handle;
+ uint8_t features[8];
+ uint16_t interval, latency, max_ce_length, max_interval, min_ce_length;
+ uint16_t min_interval, supervision_timeout, window;
+ uint8_t initiator_filter, own_type;
+ int opt, err, dd;
+
+ bdaddr_type = LE_PUBLIC_ADDRESS;
+
+ for_each_opt(opt, leinfo_options, NULL) {
+ switch (opt) {
+ case 'r':
+ bdaddr_type = LE_RANDOM_ADDRESS;
+ break;
+ default:
+ printf("%s", leinfo_help);
+ return;
+ }
+ }
+ helper_arg(1, 1, &argc, &argv, leinfo_help);
+
+ str2ba(argv[0], &bdaddr);
+
+ printf("Requesting information ...\n");
+
+ 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);
+ }
+
+ interval = htobs(0x0004);
+ window = htobs(0x0004);
+ initiator_filter = 0;
+ own_type = LE_PUBLIC_ADDRESS;
+ min_interval = htobs(0x000F);
+ max_interval = htobs(0x000F);
+ latency = htobs(0x0000);
+ supervision_timeout = htobs(0x0C80);
+ min_ce_length = htobs(0x0000);
+ max_ce_length = htobs(0x0000);
+
+ err = hci_le_create_conn(dd, interval, window, initiator_filter,
+ bdaddr_type, bdaddr, own_type, min_interval,
+ max_interval, latency, supervision_timeout,
+ min_ce_length, max_ce_length, &handle, 25000);
+ if (err < 0) {
+ perror("Could not create connection");
+ exit(1);
+ }
+
+ printf("\tHandle: %d (0x%04x)\n", handle, handle);
+
+ memset(features, 0, sizeof(features));
+ hci_le_read_remote_features(dd, handle, features, 20000);
+
+ printf("\tFeatures: 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x "
+ "0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x\n",
+ features[0], features[1], features[2], features[3],
+ features[4], features[5], features[6], features[7]);
+
+ usleep(10000);
+ hci_disconnect(dd, handle, HCI_OE_USER_ENDED_CONNECTION, 10000);
+
+ hci_close_dev(dd);
+}
+
static struct option lecc_options[] = {
{ "help", 0, 0, 'h' },
{ "random", 0, 0, 'r' },
@@ -2979,6 +3063,7 @@ static struct {
{ "clkoff", cmd_clkoff, "Read clock offset" },
{ "clock", cmd_clock, "Read local or remote clock" },
{ "lescan", cmd_lescan, "Start LE scan" },
+ { "leinfo", cmd_leinfo, "Get LE remote information" },
{ "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" },