Hello, I'm using an nRF5340 board with nRF Connect SDK as a BLE peripheral device, and I'm trying to get RSSI value when another device connects to it.
So I'm trying to read it as in the Zephyr hci_pwr_ctrl example. Specifically, I'm calling this function in the connection handler:
bt_hci_cmd_send_sync(BT_HCI_OP_READ_RSSI, requestBuffer, &responseBuffer);
Note that I'm using SoftDevice BLE stack on the CPU_NET, and my code runs on the CPU_APP.
And I have created a hci_rpmsg.conf in the child_image folder, which has the following lines:
CONFIG_BT_LL_SOFTDEVICE_DEFAULT=y CONFIG_BT_LL_SOFTDEVICE_VS_INCLUDE=y CONFIG_BT_LL_SOFTDEVICE=y CONFIG_BT_EXT_ADV=y CONFIG_BT_CTLR=y CONFIG_BT_CTLR_ADV_EXT=y CONFIG_BT_EXT_ADV_MAX_ADV_SET=2 CONFIG_BT_CTLR_PHY_CODED=y CONFIG_BT_CTLR_ADVANCED_FEATURES=y CONFIG_BT_CTLR_CONN_RSSI=y CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y
And I also have flashed merged_CPUNET.hex to the board, so that CPU_NET runs with these settings.
Now, the function to read RSSI runs without any errors, it returns 0 as error code, and it always gives the value of RSSI equal to 127, irrelevant of the distance and signal strength shown in NRF Connect.
So, this code:
auto* commandResponse = reinterpret_cast<bt_hci_rp_read_rssi*>(responseBuffer->data); printk("Rssi %d, status %u, handle %u\n", commandResponse->rssi, commandResponse->status, commandResponse->handle);
Produces the following log upon connection:
00> Req rssi for handle 14 00> 00> Rssi 127, status 0, handle 14
What can be done to read RSSI properly?