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

About RSSI of BLE

Hi, I am trying to get the rssi value of a connection, and what I am trying to do is to start the rssi in the beginning at the connection and end it at the end of connection. So in my on_ble_evt of my app I have:

    case BLE_GAP_EVT_CONNECTED:
        nrf_gpio_pin_set(CONNECTED_LED_PIN_NO);
        nrf_gpio_pin_clear(ADVERTISING_LED_PIN_NO);
        m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;

        err_code = sd_ble_gap_rssi_start(m_conn_handle);
        APP_ERROR_CHECK(err_code);
        
        break;
        
    case BLE_GAP_EVT_DISCONNECTED:
    
        err_code = sd_ble_gap_rssi_stop(m_conn_handle);
        APP_ERROR_CHECK(err_code);

        nrf_gpio_pin_clear(CONNECTED_LED_PIN_NO);
        m_conn_handle = BLE_CONN_HANDLE_INVALID;

The problem is that the sd_ble_gap_rssi_stop function is not working properly. I am guessing the connection ended before this so causing the rssi_stop cannot work. Do you have any idea how can I walk around it?

  • Hi,

    We have recently come across this bug, where the RSSI stop function does give back an error code. The connection handle is actually invalid once the "BLE_GAP_EVT_DISCONNECTED" is called, so this is why you are seeing an assert at this point. The bug from Nordic's side is that the RSSI is not stopped properly after a disconnect occurs.

    You can work around this by: call function "(void)sd_ble_gap_rssi_stop(m_conn_handle);" before starting RSSI in BLE_GAP_EVT_CONNECTED.

    Another way is to use a variable to stop the RSSI, as the attached .c file shows.

    You should then not call sd_ble_gap_rssi_stop in the "BLE_GAP_EVT_DISCONNECTED" event.

    Best regards Håkon

    sd_rssi_wrkaround.c

  • This issue was fixed in version 6.0.0 of the S110 SoftDevice.

    Here's a quote from the release notes: Fixed an issue where calling sd_ble_gap_rssi_stop() after connection had ended would cause an assert. In addition, RSSI will now be stopped automatically when the connection ends (NRFFOETT-499, DRGN-3131).

Related