From 9942261d0febb9ef243ffe810421451e97925e68 Mon Sep 17 00:00:00 2001 From: Max Krasnyansky Date: Tue, 18 Jun 2002 18:32:44 +0000 Subject: improved hci_devid --- include/hci_lib.h | 2 +- src/hci.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/hci_lib.h b/include/hci_lib.h index 982c7608..b988de5f 100644 --- a/include/hci_lib.h +++ b/include/hci_lib.h @@ -62,7 +62,7 @@ int hci_disconnect(int dd, uint16_t handle, uint8_t reason, int to); int hci_inquiry(int dev_id, int len, int num_rsp, uint8_t *lap, inquiry_info **ii, long flags); int hci_devinfo(int dev_id, struct hci_dev_info *di); int hci_devba(int dev_id, bdaddr_t *ba); -int hci_devid(bdaddr_t *ba); +int hci_devid(char *str); int hci_local_name(int dd, int len, char *name, int to); int hci_remote_name(int dd, bdaddr_t *ba, int len, char *name, int to); diff --git a/src/hci.c b/src/hci.c index f72ef760..c0be8df2 100644 --- a/src/hci.c +++ b/src/hci.c @@ -415,9 +415,20 @@ int hci_get_route(bdaddr_t *bdaddr) return hci_for_each_dev(HCI_UP, NULL, 0); } -int hci_devid(bdaddr_t *bdaddr) +int hci_devid(char *str) { - return hci_for_each_dev(HCI_UP, __same_bdaddr, (long) bdaddr); + bdaddr_t ba; + int id = -1; + + if (!strncmp(str, "hci", 3) && strlen(str) >= 4) { + id = atoi(str + 3); + if (hci_devba(id, &ba) < 0) + return -1; + } else { + str2ba(str, &ba); + id = hci_for_each_dev(HCI_UP, __same_bdaddr, (long) &ba); + } + return id; } int hci_devinfo(int dev_id, struct hci_dev_info *di) -- cgit