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

Connecting the BLE device to a phone/App with highest signal strength

Dear Sir,

I am working on the following scenario.

I have BLE device ( SDK 15 and softdevice s132). It is advertising for specific duration.

There are different phones at different distances from the BLE device.

There will be multiple requests coming to the BLE device to establish connection. I want the BLE device to connect the phone with highest signal strength?

Is it possible to do handle such a scenario with SDK15 and softdevice s132?

Please guide me on this.

Thanking you.

Parents Reply Children
  • Hi, Thank you for your susggestion.

    I will check it.

  • Hi,

    You mentioned the following .

    2. The _ble_evt->evt.gap_evt.params.adv_report.rssi variable gets populated with the RSSI once the phone has sent a scan request package. 

    So is this means the following.

    The variable "_ble_evt->evt.gap_evt.params.adv_report.rssi " (which is in the peripheral side)  will get populated with the rssi of the phone which responded to advertiser(which is the peripheral device itself).?

    PLease correct me if i am wrong.

  • Hi 

    I'm sorry but the correct variable is p_ble_evt->evt.gap_evt.params.scan_req_report.rssi not p_ble_evt->evt.gap_evt.params.adv_report.rssi

    You're understanding is correct otherwise. You enable a BLE_GAP_EVT_SCAN_REQ_REPORT by setting p_advertising->adv_params.scan_req_notification = 1 in ble_advertising.c

    I've included a modified version of the template example where a BLE_GAP_EVT_SCAN_REQ_REPORT is made when a scan request package is requested to the peripheral. The Peripheral prints out the  RSSI to the central that requested the scan request package to a terminal

    Cheers

    Jared

    Scan_example.zip

  • Hi,

    In the code  you have written the code as follows.

    rssi = p_ble_evt->evt.gap_evt.params.adv_report.rssi;
    // rssi = p_ble_evt->evt.gap_evt.params.scan_req_report.rssi;

    So as you mentioned above, I need to comment out first line and uncomment the second one. right?

    Thank you.

    It is showing the values  now,

    (after enabling the variable   " p_ble_evt->evt.gap_evt.params.scan_req_report.rssi"  ). as folllows

    <info> app: SCAN REPORT SENT
    <info> app: RSSI:-42
    <info> app: SCAN REPORT

    <info> app: SCAN REPORT SENT
    <info> app: RSSI:-41
    <info> app: SCAN REPORT

    <info> app: SCAN REPORT SENT
    <info> app: RSSI:-72
    <info> app: SCAN REPORT

    <info> app: SCAN REPORT SENT
    <info> app: RSSI:-83

    But the value is continuously varying...Is that an expected behaviour?

    And how can I print the peer address (using NRF_LOG_INFO()) also along with rssi?

    Please share your ideas.

    Thanking you

  • The  p_ble_evt->evt.gap_evt.params.scan_req_report.rssi sets rssi to the received signal strength to the device that sent a scan request package. It should therefore vary when multiple devices are sending scan request packages.

    You can print the peer address by printing the p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr array that is of length BLE_GAP_ADDR_LEN. 

    The format for printing characters with NRF_LOG_INFO is NRF_LOG_INFO("PEER[1]: %02x",p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[1]);

    Good luck

    Jared

Related