I found some examples on dev zone how to read RSSI during connected state:
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); }
Function report RSSI but as a positive value around 230. How to recalculate it to dB. I see that value is getting changed (getting smaller) when I'm moving my mobile from the board.
Przemek