Hi,
I am developing the nRF52833 DK with NCS v2.00.
I am using a function in my source code that reads the current RSSI of the connection. The function, read_conn_rssi (attached below), is taken from the Bluetooth sample, Bluetooth: HCI Power Control. I am printing the RSSI (using printk) on the nRF terminal. I am also connecting the SoC to my Android phone and reading the remote RSSI using the macros provided on the app. The RSSI on the application is always different to the RSSI that is read from the read_conn_rssi function. The RSSI on the nRF Connect app is always about ~15-20 dBm weaker than that read by the read_conn_rssi function.
Any idea why this may be? Perhaps someone could please repeat this experiment and see if there is also a discrepancy in RSSI readings?
Thanks very much,
Adam
static void read_conn_rssi(uint16_t handle, int8_t *rssi)
{
struct net_buf *buf, *rsp = NULL;
struct bt_hci_cp_read_rssi *cp;
struct bt_hci_rp_read_rssi *rp;
int err;
buf = bt_hci_cmd_create(BT_HCI_OP_READ_RSSI, sizeof(*cp));
if (!buf) {
printk("Unable to allocate command buffer\n");
return;
}
cp = net_buf_add(buf, sizeof(*cp));
cp->handle = sys_cpu_to_le16(handle);
err = bt_hci_cmd_send_sync(BT_HCI_OP_READ_RSSI, buf, &rsp);
if (err) {
uint8_t reason = rsp ?
((struct bt_hci_rp_read_rssi *)rsp->data)->status : 0;
printk("Read RSSI err: %d reason 0x%02x\n", err, reason);
return;
}
rp = (void *)rsp->data;
*rssi = rp->rssi;
net_buf_unref(rsp);
}