Dear Sir,
I have connected a phone to a peripheral device using NRFconnect App.
Now I want to know the rssi value of the phone on the peripheral side.
I want to get the peer address(of the phone) and corresponding rssi value.
I have done the following code for the same.
switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_CONNECTED: NRF_LOG_INFO("Connected hrs."); NRF_LOG_INFO_ARRAY(p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr,BLE_GAP_ADDR_LEN); NRF_LOG_INFO_ARRAY(peak_rssi.peer_addr.addr,BLE_GAP_ADDR_LEN); err_code = bsp_indication_set(BSP_INDICATE_CONNECTED); APP_ERROR_CHECK(err_code); m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle; err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle); APP_ERROR_CHECK(err_code); sd_ble_gap_rssi_start(m_conn_handle,1,0); break; case BLE_GAP_EVT_RSSI_CHANGED: NRF_LOG_INFO("In BLE_GAP_EVT_RSSI_CHANGED "); c_rssi = p_ble_evt->evt.gap_evt.params.rssi_changed.rssi; c_addr = p_ble_evt->evt.gap_evt.params.connected.peer_addr; NRF_LOG_INFO_ARRAY(p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr,BLE_GAP_ADDR_LEN); NRF_LOG_INFO("RSSI = %d ",c_rssi); NRF_LOG_INFO("In BLE_GAP_EVT_RSSI_CHANGED End"); break;
But here two cases are there
1)case BLE_GAP_EVT_CONNECTED:
2)case BLE_GAP_EVT_RSSI_CHANGED:
In both these cases I am printing the variable "p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr".(as I want to get the peer address of the phone connected to the peripheral)
In case BLE_GAP_EVT_CONNECTED: it shows the same address ( after multiple connect-disconnect operations)
But in case BLE_GAP_EVT_RSSI_CHANGED the same variable is changing continuously (even if the device is connected to a phone).
So which will give the correct peer address of the phone?
Since the first one shows almost the stable one, I think I can relay on that. Am I correct?
Then the problem is which variable will give me the correct rssi value of the phone connected to the peripheral?
Please guide me in this and please give answers to 3 questions mentioned above.
Thank you