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

Finding RSSI value after connection continously

Hey

I am working on ble_app_blinky central and peripheral, I want to calculate the RSSI of peripheral after connection with central. I am able to calculate the RSSI value while it is scanning,

When I am trying to print the rssi in rtt from ble_event_handler in  main.c I am getting value as zero as shown below.

I have used these functions at same place 

sd_ble_gap_rssi_start(p_ble_evt->evt.gap_evt.conn_handle, 0 , 0);

sd_ble_gap_rssi_get(p_ble_evt->evt.gap_evt.conn_handle,&p_ble_evt->evt.gap_evt.params.rssi_changed.rssi,&p_ble_evt->evt.gap_evt.params.rssi_changed.ch_index);

even though i am getting zero for rssi value. Please help to sort this issue

regards

Sumanth

Parents
  • Hi Sumanth

    You have to call sd_ble_gap_rssi_start() initially so that the SoftDevice will start to report the RSSI. Depending on the parameters, you will get an event (BLE_GAP_EVT_RSSI_CHANGED) every time the RSSI change. Then you should be able to use the sd_ble_gap_rssi_get() event when the RSSI_CHANGED event occurs. Something similar to this should do.

    // On the connection event
    
    uint32_t err_code;  
    m_conn_handle  = p_ble_evt->evt.gap_evt.conn_handle;  
    err_code = sd_ble_gap_rssi_start(m_conn_handle, 10, 0);   
    APP_ERROR_CHECK(err_code); 
    
    
    //On the RSSI_CHANGED event
    
    uint32_t err_code;  
    int8_t rssi;  
    err_code = sd_ble_gap_rssi_get(m_conn_handle, &rssi);  
    APP_ERROR_CHECK(err_code);
    

    Then you should be able to log the RSSI values.

    Best regards,

    Simon

  • Thanks Simonr i am able to get RSSI for every updated value, Now I have to read up to 5 RSSI values on interval basis, i,e for every 300 ms i have to read RSSI upto 5 values and get an average, This should be repeated continuously, Do it consume more power, if yes how can i reduce it?

    Regards

    sumanth      

Reply Children
No Data
Related