From 84cc44acd712f84ff544b7e1b96d1410c732dc8c Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 13 Jan 2005 22:57:36 +0000 Subject: Add function for reading the transmit power level --- include/hci_lib.h | 1 + src/hci.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/hci_lib.h b/include/hci_lib.h index 7e6acfaf..3c44bd8a 100644 --- a/include/hci_lib.h +++ b/include/hci_lib.h @@ -89,6 +89,7 @@ int hci_read_inquiry_mode(int dd, uint8_t *mode, int to); int hci_write_inquiry_mode(int dd, uint8_t mode, int to); int hci_read_afh_mode(int dd, uint8_t *mode, int to); int hci_write_afh_mode(int dd, uint8_t mode, int to); +int hci_read_transmit_power_level(int dd, uint16_t handle, uint8_t type, uint8_t *level, int to); int hci_read_link_supervision_timeout(int dd, uint16_t handle, uint16_t *timeout, int to); int hci_write_link_supervision_timeout(int dd, uint16_t handle, uint16_t timeout, int to); int hci_set_afh_classification(int dd, uint8_t *map, int to); diff --git a/src/hci.c b/src/hci.c index ca53105e..8e0b7938 100644 --- a/src/hci.c +++ b/src/hci.c @@ -1432,6 +1432,36 @@ int hci_write_afh_mode(int dd, uint8_t mode, int to) return 0; } +int hci_read_transmit_power_level(int dd, uint16_t handle, uint8_t type, uint8_t *level, int to) +{ + read_transmit_power_level_cp cp; + read_transmit_power_level_rp rp; + struct hci_request rq; + + memset(&cp, 0, sizeof(cp)); + cp.handle = handle; + cp.type = type; + + memset(&rq, 0, sizeof(rq)); + rq.ogf = OGF_HOST_CTL; + rq.ocf = OCF_READ_TRANSMIT_POWER_LEVEL; + rq.cparam = &cp; + rq.clen = READ_TRANSMIT_POWER_LEVEL_CP_SIZE; + rq.rparam = &rp; + rq.rlen = READ_TRANSMIT_POWER_LEVEL_RP_SIZE; + + if (hci_send_req(dd, &rq, to) < 0) + return -1; + + if (rp.status) { + errno = EIO; + return -1; + } + + *level = rp.level; + return 0; +} + int hci_read_link_supervision_timeout(int dd, uint16_t handle, uint16_t *timeout, int to) { read_link_supervision_timeout_rp rp; -- cgit