diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2005-01-13 20:21:51 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2005-01-13 20:21:51 +0000 |
commit | 818f37527b66b1bd8c177759a8c7710882030093 (patch) | |
tree | b52f1c7e89e431b69c220201cd794b56b5eac0cc | |
parent | 0197e2d62cac9323387d52b5711d3c564303d949 (diff) |
Use library functions for RSSI and link quality
-rw-r--r-- | tools/hcitool.c | 48 |
1 files changed, 7 insertions, 41 deletions
diff --git a/tools/hcitool.c b/tools/hcitool.c index 99262f41..ffa98536 100644 --- a/tools/hcitool.c +++ b/tools/hcitool.c @@ -815,10 +815,8 @@ static char *rssi_help = static void cmd_rssi(int dev_id, int argc, char **argv) { struct hci_conn_info_req *cr; - struct hci_request rq; - read_rssi_rp rp; bdaddr_t bdaddr; - uint16_t handle; + int8_t rssi; int opt, dd; for_each_opt(opt, rssi_options, NULL) { @@ -863,27 +861,12 @@ static void cmd_rssi(int dev_id, int argc, char **argv) exit(1); } - handle = htobs(cr->conn_info->handle); - - 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, 100) < 0) { + if (hci_read_rssi(dd, htobs(cr->conn_info->handle), &rssi, 1000) < 0) { perror("Read RSSI failed"); exit(1); } - if (rp.status) { - printf("Read RSSI returned (error) status 0x%2.2X\n", - rp.status); - exit(1); - } - printf("RSSI return value: %d\n", rp.rssi); + printf("RSSI return value: %d\n", rssi); close(dd); free(cr); @@ -903,10 +886,8 @@ static char *lq_help = static void cmd_lq(int dev_id, int argc, char **argv) { struct hci_conn_info_req *cr; - struct hci_request rq; - get_link_quality_rp rp; bdaddr_t bdaddr; - uint16_t handle; + uint8_t lq; int opt, dd; for_each_opt(opt, lq_options, NULL) { @@ -951,27 +932,12 @@ static void cmd_lq(int dev_id, int argc, char **argv) exit(1); } - handle = htobs(cr->conn_info->handle); - - memset(&rq, 0, sizeof(rq)); - rq.ogf = OGF_STATUS_PARAM; - rq.ocf = OCF_GET_LINK_QUALITY; - rq.cparam = &handle; - rq.clen = 2; - rq.rparam = &rp; - rq.rlen = GET_LINK_QUALITY_RP_SIZE; - - if (hci_send_req(dd, &rq, 100) < 0) { - perror("HCI get_link_quality request failed"); + if (hci_read_link_quality(dd, htobs(cr->conn_info->handle), &lq, 1000) < 0) { + perror("HCI read_link_quality request failed"); exit(1); } - if (rp.status) { - fprintf(stderr, "HCI get_link_quality cmd failed (0x%2.2X)\n", - rp.status); - exit(1); - } - printf("Link quality: %d\n", rp.link_quality); + printf("Link quality: %d\n", lq); close(dd); free(cr); |