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

How to print the RSSI values after successful connection?

Hello All,

I am working with the HRS example. Currently I have one central device and one peripheral device is there.

From central code I want to print the updated RSSI values continuously . For that I added the below code snippet:

case BLE_GAP_EVT_CONNECTED:
    {
        NRF_LOG_INFO("Connected.");
    printf("\r\nConnected\r\n");

        // Discover peer's services.
        err_code = ble_db_discovery_start(&m_db_disc, p_ble_evt->evt.gap_evt.conn_handle);
        APP_ERROR_CHECK(err_code);

        err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
        APP_ERROR_CHECK(err_code);

    sd_ble_gap_rssi_start(p_ble_evt->evt.gap_evt.conn_handle, 0 , 0);
    NRF_LOG_INFO("RSSI: %d", p_ble_evt->evt.gap_evt.params.adv_report.rssi);
    //NRF_LOG_INFO("RSSI: %d", p_ble_evt->evt.gap_evt.params.rssi_changed.rssi);

        if (ble_conn_state_n_centrals() < NRF_SDH_BLE_CENTRAL_LINK_COUNT)
        {
            scan_start();
        }
    } break;

with NRF_LOG_INFO("RSSI: %d", p_ble_evt->evt.gap_evt.params.rssi_changed.rssi); I am always getting the value 2.

with NRF_LOG_INFO("RSSI: %d", p_ble_evt->evt.gap_evt.params.adv_report.rssi); I am getting correct value but only once.

I want to print the updated value continuously with HRS values,how can I do that?

Regards, Hrushi

Related