diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2003-12-21 16:08:25 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2003-12-21 16:08:25 +0000 |
commit | 16e217b4b13b828a9bb6c372d544deafa0e01f24 (patch) | |
tree | 286460097b88dc85bf12d20cb09daa182f23d034 /tools | |
parent | 350e84f553eece612ba722c55f7b39c71b449994 (diff) |
Fix automatic connection creation for the info command
Diffstat (limited to 'tools')
-rw-r--r-- | tools/hcitool.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/tools/hcitool.c b/tools/hcitool.c index f8125f43..0194b650 100644 --- a/tools/hcitool.c +++ b/tools/hcitool.c @@ -410,10 +410,8 @@ static void cmd_info(int dev_id, int argc, char **argv) if (dev_id < 0) dev_id = hci_for_each_dev(HCI_UP, find_conn, (long) &bdaddr); - if (dev_id < 0) { + if (dev_id < 0) dev_id = hci_get_route(&bdaddr); - cc = 1; - } if (dev_id < 0) { fprintf(stderr, "Device is not available or not connected.\n"); @@ -428,26 +426,24 @@ static void cmd_info(int dev_id, int argc, char **argv) exit(1); } - if (cc) { + cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info)); + if (!cr) { + perror("Can't get connection info"); + close(dd); + exit(1); + } + + bacpy(&cr->bdaddr, &bdaddr); + cr->type = ACL_LINK; + if (ioctl(dd, HCIGETCONNINFO, (unsigned long) cr) < 0) { if (hci_create_connection(dd, &bdaddr, HCI_DM1 | HCI_DH1, 0, 0, &handle, 25000) < 0) { perror("Can't create connection"); close(dd); exit(1); } - } else { - cr = malloc(sizeof(*cr) + sizeof(struct hci_conn_info)); - if (!cr) - return; - - bacpy(&cr->bdaddr, &bdaddr); - cr->type = ACL_LINK; - if (ioctl(dd, HCIGETCONNINFO, (unsigned long) cr) < 0) { - perror("Get connection info failed"); - exit(1); - } - + cc = 1; + } else handle = cr->conn_info->handle; - } printf("\tBD Address: %s\n", argv[0]); |