summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/hci.h6
-rw-r--r--include/hci_lib.h2
-rw-r--r--src/hci.c50
3 files changed, 55 insertions, 3 deletions
diff --git a/include/hci.h b/include/hci.h
index 683c988f..54bb8849 100644
--- a/include/hci.h
+++ b/include/hci.h
@@ -791,13 +791,13 @@ typedef struct {
} __attribute__ ((packed)) reset_failed_contact_counter_rp;
#define RESET_FAILED_CONTACT_COUNTER_RP_SIZE 4
-#define OCF_GET_LINK_QUALITY 0x0003
+#define OCF_READ_LINK_QUALITY 0x0003
typedef struct {
uint8_t status;
uint16_t handle;
uint8_t link_quality;
-} __attribute__ ((packed)) get_link_quality_rp;
-#define GET_LINK_QUALITY_RP_SIZE 4
+} __attribute__ ((packed)) read_link_quality_rp;
+#define READ_LINK_QUALITY_RP_SIZE 4
#define OCF_READ_RSSI 0x0005
typedef struct {
diff --git a/include/hci_lib.h b/include/hci_lib.h
index 5c83b5e8..969db1f2 100644
--- a/include/hci_lib.h
+++ b/include/hci_lib.h
@@ -92,6 +92,8 @@ 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_set_afh_classification(int dd, uint8_t *map, int to);
+int hci_read_link_quality(int dd, uint16_t handle, uint8_t *link_quality, int to);
+int hci_read_rssi(int dd, uint16_t handle, int8_t *rssi, int to);
int hci_read_afh_map(int dd, uint16_t handle, uint8_t *mode, uint8_t *map, int to);
int hci_for_each_dev(int flag, int(*func)(int s, int dev_id, long arg), long arg);
diff --git a/src/hci.c b/src/hci.c
index 5d11309f..63a79d06 100644
--- a/src/hci.c
+++ b/src/hci.c
@@ -1460,6 +1460,56 @@ int hci_set_afh_classification(int dd, uint8_t *map, int to)
return 0;
}
+int hci_read_link_quality(int dd, uint16_t handle, uint8_t *link_quality, int to)
+{
+ read_link_quality_rp rp;
+ struct hci_request rq;
+
+ memset(&rq, 0, sizeof(rq));
+ rq.ogf = OGF_STATUS_PARAM;
+ rq.ocf = OCF_READ_LINK_QUALITY;
+ rq.cparam = &handle;
+ rq.clen = 2;
+ rq.rparam = &rp;
+ rq.rlen = READ_LINK_QUALITY_RP_SIZE;
+
+ if (hci_send_req(dd, &rq, to) < 0)
+ return -1;
+
+ if (rp.status) {
+ errno = EIO;
+ return -1;
+ }
+
+ *link_quality = rp.link_quality;
+ return 0;
+}
+
+int hci_read_rssi(int dd, uint16_t handle, int8_t *rssi, int to)
+{
+ read_rssi_rp rp;
+ struct hci_request rq;
+
+ memset(&rq, 0, sizeof(rq));
+ rq.ogf = OGF_STATUS_PARAM;
+ rq.ocf = OCF_READ_RSSI;
+ rq.cparam = &handle;
+ rq.clen = 2;
+ rq.rparam = &rp;
+ rq.rlen = READ_RSSI_RP_SIZE;
+
+ if (hci_send_req(dd, &rq, to) < 0)
+ return -1;
+
+ if (rp.status) {
+ errno = EIO;
+ return -1;
+ }
+
+ *rssi = rp.rssi;
+ return 0;
+}
+
int hci_read_afh_map(int dd, uint16_t handle, uint8_t *mode, uint8_t *map, int to)
{
read_afh_map_rp rp;