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

How to check when the stack is ready to send notification?

Hi all,

I'm using two nRF51 DK to measure ADC input on peripheral side and translate it to central, based on Multilink example. One software timer is used to perform one ADC conversion every 1 sec, and send a notification to the central throug sd_ble_gatts_hvx(). Currently timer started and stopped by button press, I need to change it:

  • start timer, when connection is done AND notification is properly enabled;
  • stop timer, when notification disabled or connection is done.

What BLE events or functions should be used to get this done?

Currently I check:

  1. (m_conn_handle != BLE_CONN_HANDLE_INVALID) in timer handler - it doen's works when connection is done, handle still has the value

  2. err_code = sd_ble_gatts_hvx(m_conn_handle, &hvx_params);
     if (err_code != NRF_ERROR_INVALID_STATE && err_code !=     BLE_ERROR_GATTS_SYS_ATTR_MISSING)         
     {
         APP_ERROR_CHECK(err_code);
     }
    
Parents
  • Hi, Anders!

    Thank you, it works fine for cccd writes, but there is an error produced on the disconnection, althought BLE_GAP_EVT_DISCONNECTED is monitored. I get the 0x3004 error on the code:

    err_code = sd_ble_gatts_hvx(m_conn_handle, &hvx_params);
    if (err_code != NRF_ERROR_INVALID_STATE && err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING) {
    APP_ERROR_CHECK(err_code);
    }
    

    The problem typically appears on small timer period (I tested for 100 ms), when I reset central app. What is wrong here?

  • Anders, I changed the MAX_CONN_INTERVAL to 60 ms, but it doesn't helps. Yes, we need slave latency to be able to set different send period and save energy on the peripheral side. For example, period could be set from 100 ms up to 2 sec. How to use slave latency setting?

Reply Children
No Data
Related