diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-05-23 18:32:16 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-05-23 18:32:16 +0000 |
commit | 277e0363f2839a05b80c1bc4263cfeaf9909be8c (patch) | |
tree | 1a8830c7b7b030e9d4f5031ac08801f8f0474142 /hcid/device.c | |
parent | 7cc971c79cd88798c5c40f9cdf85532a7aeab8a9 (diff) |
Added device class tracking
Diffstat (limited to 'hcid/device.c')
-rw-r--r-- | hcid/device.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/hcid/device.c b/hcid/device.c index 4d2239ec..920a4dad 100644 --- a/hcid/device.c +++ b/hcid/device.c @@ -81,6 +81,7 @@ struct hci_dev { uint16_t manufacturer; uint8_t name[248]; + uint8_t class[3]; struct hci_peer *peers; struct hci_conn *conns; @@ -203,7 +204,7 @@ int start_device(uint16_t dev_id) struct hci_dev *dev; struct hci_version ver; uint8_t features[8], inqmode; - int dd; + int dd, err; ASSERT_DEV_ID; @@ -233,15 +234,23 @@ int start_device(uint16_t dev_id) dev->manufacturer = ver.manufacturer; if (hci_read_local_features(dd, features, 1000) < 0) { - int err = errno; + err = errno; error("Can't read features for hci%d: %s (%d)", - dev_id, strerror(errno), errno); + dev_id, strerror(err), err); hci_close_dev(dd); return -err; } memcpy(dev->features, features, 8); + if (hci_read_class_of_dev(dd, dev->class, 1000) < 0) { + err = errno; + error("Can't read class of device on hci%d: %s(%d)", + dev_id, strerror(err), err); + hci_close_dev(dd); + return -err; + } + inqmode = get_inquiry_mode(dev); if (inqmode < 1) goto done; @@ -285,6 +294,18 @@ int get_device_address(uint16_t dev_id, char *address, size_t size) return ba2str(&dev->bdaddr, address); } +int get_device_class(uint16_t dev_id, uint8_t *cls) +{ + struct hci_dev *dev; + + ASSERT_DEV_ID; + + dev = &devices[dev_id]; + memcpy(cls, dev->class, 3); + + return 0; +} + int get_device_version(uint16_t dev_id, char *version, size_t size) { struct hci_dev *dev; |