Hi, I want to get the RSSI for each peripheral that is connected to an nRF52 when it is operating as a multi-link central to multiple peripherals. Helpful hints? Sample code?
Thanks!
Hi, I want to get the RSSI for each peripheral that is connected to an nRF52 when it is operating as a multi-link central to multiple peripherals. Helpful hints? Sample code?
Thanks!
Hi,
In order to measure the RSSI on a connected peripheral, you can use the SoftDevice functions sd_ble_gap_rssi_get()
, sd_ble_gap_rssi_start()
and sd_ble_gap_rssi_stop()
. Provide the conn_handle for the peripheral you want to get the RSSI from. You can read more about these functions here.
Example: When a peripheral connects, let’s start the RSSI sampling. In the function on_ble_evt(),when we get the event BLE_GAP_EVT_CONNECTED, let’s call the start function:
case BLE_GAP_EVT_CONNECTED:
{
NRF_LOG_INFO("Connection 0x%x established, starting DB discovery.\r\n",
p_gap_evt->conn_handle);
APP_ERROR_CHECK_BOOL(p_gap_evt->conn_handle < TOTAL_LINK_COUNT);
err_code = ble_lbs_c_handles_assign(&m_ble_lbs_c[p_gap_evt->conn_handle],
p_gap_evt->conn_handle,
NULL);
APP_ERROR_CHECK(err_code);
sd_ble_gap_rssi_start(p_gap_evt->conn_handle,3,0); // ADD THIS
then add a new case in the function on_ble_evt() for the rssi event:
case BLE_GAP_EVT_RSSI_CHANGED:
NRF_LOG_INFO("Rssi is %d with conn_handle: %d\n",p_gap_evt->params.rssi_changed.rssi,p_gap_evt->conn_handle);
break;
Example: When a peripheral connects, let’s start the RSSI sampling. In the function on_ble_evt(),when we get the event BLE_GAP_EVT_CONNECTED, let’s call the start function:
case BLE_GAP_EVT_CONNECTED:
{
NRF_LOG_INFO("Connection 0x%x established, starting DB discovery.\r\n",
p_gap_evt->conn_handle);
APP_ERROR_CHECK_BOOL(p_gap_evt->conn_handle < TOTAL_LINK_COUNT);
err_code = ble_lbs_c_handles_assign(&m_ble_lbs_c[p_gap_evt->conn_handle],
p_gap_evt->conn_handle,
NULL);
APP_ERROR_CHECK(err_code);
sd_ble_gap_rssi_start(p_gap_evt->conn_handle,3,0); // ADD THIS
then add a new case in the function on_ble_evt() for the rssi event:
case BLE_GAP_EVT_RSSI_CHANGED:
NRF_LOG_INFO("Rssi is %d with conn_handle: %d\n",p_gap_evt->params.rssi_changed.rssi,p_gap_evt->conn_handle);
break;