diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2003-03-22 08:00:36 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2003-03-22 08:00:36 +0000 |
commit | 1c9576607a611e033e0bac0f56d91146c120a16d (patch) | |
tree | bf1f45ee6e5aed3e94fb4a6b154b98efda4614ca | |
parent | bfcbbde6d7baebca27c6e93f02f6279e5f36c866 (diff) |
Support for reading the clock offset
-rw-r--r-- | include/hci.h | 14 | ||||
-rw-r--r-- | include/hci_lib.h | 1 | ||||
-rw-r--r-- | src/hci.c | 30 |
3 files changed, 45 insertions, 0 deletions
diff --git a/include/hci.h b/include/hci.h index 212db12b..904bc5c8 100644 --- a/include/hci.h +++ b/include/hci.h @@ -546,6 +546,12 @@ typedef struct { } __attribute__ ((packed)) read_remote_version_cp; #define READ_REMOTE_VERSION_CP_SIZE 2 +#define OCF_READ_CLOCK_OFFSET 0x001F +typedef struct { + uint16_t handle; +} __attribute__ ((packed)) read_clock_offset_cp; +#define READ_CLOCK_OFFSET_CP_SIZE 2 + /* Link Policy */ #define OGF_LINK_POLICY 0x02 @@ -777,6 +783,14 @@ typedef struct { } __attribute__ ((packed)) evt_link_key_notify; #define EVT_LINK_KEY_NOTIFY_SIZE 23 +#define EVT_READ_CLOCK_OFFSET_COMPLETE 0x1C +typedef struct { + uint8_t status; + uint16_t handle; + uint16_t clock_offset; +} __attribute__ ((packed)) evt_read_clock_offset_complete; +#define EVT_READ_CLOCK_OFFSET_COMPLETE_SIZE 5 + #define EVT_CONN_PTYPE_CHANGED 0x1D typedef struct { uint8_t status; diff --git a/include/hci_lib.h b/include/hci_lib.h index d6d76214..79866a45 100644 --- a/include/hci_lib.h +++ b/include/hci_lib.h @@ -72,6 +72,7 @@ int hci_remote_name(int dd, const bdaddr_t *ba, int len, char *name, int to); int hci_read_remote_name(int dd, const bdaddr_t *ba, int len, char *name, int to); int hci_read_remote_features(int dd, uint16_t handle, uint8_t *features, int to); int hci_read_remote_version(int dd, uint16_t handle, struct hci_version *ver, int to); +int hci_read_clock_offset(int dd, uint16_t handle, uint16_t *clkoffset, int to); int hci_read_local_version(int dd, struct hci_version *ver, int to); int hci_read_class_of_dev(int dd, uint8_t *cls, int to); int hci_write_class_of_dev(int dd, uint32_t cls, int to); @@ -905,6 +905,36 @@ int hci_read_remote_version(int dd, uint16_t handle, struct hci_version *ver, in return 0; } +int hci_read_clock_offset(int dd, uint16_t handle, uint16_t *clkoffset, int to) +{ + evt_read_clock_offset_complete rp; + read_clock_offset_cp cp; + struct hci_request rq; + + memset(&cp, 0, sizeof(cp)); + cp.handle = handle; + + memset(&rq, 0, sizeof(rq)); + rq.ogf = OGF_LINK_CTL; + rq.ocf = OCF_READ_CLOCK_OFFSET; + rq.event = EVT_READ_CLOCK_OFFSET_COMPLETE; + rq.cparam = &cp; + rq.clen = READ_CLOCK_OFFSET_CP_SIZE; + rq.rparam = &rp; + rq.rlen = EVT_READ_CLOCK_OFFSET_COMPLETE_SIZE; + + if (hci_send_req(dd, &rq, to) < 0) + return -1; + + if (rp.status) { + errno = EIO; + return -1; + } + + *clkoffset = rp.clock_offset; + return 0; +} + int hci_read_local_version(int dd, struct hci_version *ver, int to) { read_local_version_rp rp; |