This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Reading the RSSI from connected device and from non-connected device by specified MAC

Hello,

I am using a central with SDK 14 & nRF52832; my goal is to read the RSSI & MAC from a connected peripheral device. During the BLE_GAP_EVT_RSSI_CHANGED event what I getting is "random beacons nearby" as described here .


Questions are:

(1) Having the described setup, what would be the correct steps to only get the RSSI of the connected peripheral?

(2) With the given setup, what would be the correct steps to get the RSSI of a device that isn't connected? Should I simply perform filtering by desired MAC with the setup I already have?

Thanks in advance

Parents
  • Hi,

    1. To get the RSSI of a connected device you can use the functions sd_ble_gap_rssi_start() and sd_ble_gap_rssi_get() to get the RSSI value between the peripheral and central. 

    2. Yes, in ble_evt_handler upon receiving an advertisement report, you can apply a filter for the desired MAC address then read out the RSSI from the report.

  • Hello Mttrinh,

    Thanks for the fast response!

    I then have additional questions to make situation clear:

    (1)

    1.1.Intuitively, sd_ble_gap_rssi_start(p_gap_evt->conn_handle, 0, 1); should start RSSI scanning only for the connected device with the specified connection handler (but not get events for RSSI change of non-connected peripheral or other connected peripheral). Is this understanding correct?

    1.2. If so, BLE_GAP_EVT_RSSI_CHANGED should be triggered only by a change in the RSSI of the connected peripheral  whose handler is currently serviced. How is then possible to get the RSSI of non-connected peripherals during the BLE_GAP_EVT_RSSI_CHANGED event?

    1.3 Further, what is, in principle, the difference between reading p_ble_evt->evt.gap_evt.params.rssi_changed.rssi and calling sd_ble_gap_rssi_get(p_gap_evt->conn_handle, &rssi) ?

    (2) In case of multiple connected peripherals we shall know which peripheral's RSSI was read by the respective connection handle. It would be very helpful if you can point a code example to implement it, i.e. after calling sd_ble_gap_rssi_get() and having the connection handle, how to get the respective MAC of the connected peripheral device whose RSSI was read?

    (3) Please, provide a code example how to implement RSSI scanning of non-connected peripherals at a regular intervals, e.g. every 100 ms. I guess it should apply a timer to call the scanning routine, but I am not clear shall it use  p_ble_evt->evt.gap_evt.params.rssi_changed.rssi & p_ble_evt->evt.gap_evt.params.connected.peer_addr or rather sd_ble_gap_rssi_get(p_gap_evt->conn_handle, &rssi)  (and how to read the MAC in this case).

    (4) Is it possible for a peripheral device to read rssi of surrounding devices? If yes, could you please, provide a code example. If not - what could be the workaround - e.g. switching a device between central and peripheral roles?

    Thanks much in advance!

Reply
  • Hello Mttrinh,

    Thanks for the fast response!

    I then have additional questions to make situation clear:

    (1)

    1.1.Intuitively, sd_ble_gap_rssi_start(p_gap_evt->conn_handle, 0, 1); should start RSSI scanning only for the connected device with the specified connection handler (but not get events for RSSI change of non-connected peripheral or other connected peripheral). Is this understanding correct?

    1.2. If so, BLE_GAP_EVT_RSSI_CHANGED should be triggered only by a change in the RSSI of the connected peripheral  whose handler is currently serviced. How is then possible to get the RSSI of non-connected peripherals during the BLE_GAP_EVT_RSSI_CHANGED event?

    1.3 Further, what is, in principle, the difference between reading p_ble_evt->evt.gap_evt.params.rssi_changed.rssi and calling sd_ble_gap_rssi_get(p_gap_evt->conn_handle, &rssi) ?

    (2) In case of multiple connected peripherals we shall know which peripheral's RSSI was read by the respective connection handle. It would be very helpful if you can point a code example to implement it, i.e. after calling sd_ble_gap_rssi_get() and having the connection handle, how to get the respective MAC of the connected peripheral device whose RSSI was read?

    (3) Please, provide a code example how to implement RSSI scanning of non-connected peripherals at a regular intervals, e.g. every 100 ms. I guess it should apply a timer to call the scanning routine, but I am not clear shall it use  p_ble_evt->evt.gap_evt.params.rssi_changed.rssi & p_ble_evt->evt.gap_evt.params.connected.peer_addr or rather sd_ble_gap_rssi_get(p_gap_evt->conn_handle, &rssi)  (and how to read the MAC in this case).

    (4) Is it possible for a peripheral device to read rssi of surrounding devices? If yes, could you please, provide a code example. If not - what could be the workaround - e.g. switching a device between central and peripheral roles?

    Thanks much in advance!

Children
No Data
Related