From d316a5fbab4a41ce3f8321eef407db9c53b57e85 Mon Sep 17 00:00:00 2001 From: Max Krasnyansky Date: Tue, 18 Jun 2002 18:15:13 +0000 Subject: Added hci_devid function. --- include/hci_lib.h | 1 + src/hci.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/hci_lib.h b/include/hci_lib.h index 7fd95cfc..982c7608 100644 --- a/include/hci_lib.h +++ b/include/hci_lib.h @@ -62,6 +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_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 bc645686..f72ef760 100644 --- a/src/hci.c +++ b/src/hci.c @@ -399,6 +399,14 @@ static int __other_bdaddr(int s, int dev_id, long arg) return bacmp((bdaddr_t *)arg, &di.bdaddr); } +static int __same_bdaddr(int s, int dev_id, long arg) +{ + struct hci_dev_info di = {dev_id: dev_id}; + if (ioctl(s, HCIGETDEVINFO, (void*) &di)) + return 0; + return !bacmp((bdaddr_t *)arg, &di.bdaddr); +} + int hci_get_route(bdaddr_t *bdaddr) { if (bdaddr) @@ -407,6 +415,11 @@ int hci_get_route(bdaddr_t *bdaddr) return hci_for_each_dev(HCI_UP, NULL, 0); } +int hci_devid(bdaddr_t *bdaddr) +{ + return hci_for_each_dev(HCI_UP, __same_bdaddr, (long) bdaddr); +} + int hci_devinfo(int dev_id, struct hci_dev_info *di) { int s, err; -- cgit