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);
     }
    
Related