mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-12-02 08:34:26 +08:00
Use library functions for RSSI and link quality
This commit is contained in:
parent
0197e2d62c
commit
818f37527b
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user