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?

  • If you put more packets into the TX_buffer than you send out, it fill naturally fill up. The peripheral is able to send a certain amount of packets each connection interval (6 for S110). With a connection interval of 60ms, it can send (6 * (1/0.060) = 100) packets each second. Even though this is a theoretical maximum, it should be more than enough to send every 100 ms. (See this post for more info on BLE throughput). What is the connection intervals on your peripheral application?

Reply
  • If you put more packets into the TX_buffer than you send out, it fill naturally fill up. The peripheral is able to send a certain amount of packets each connection interval (6 for S110). With a connection interval of 60ms, it can send (6 * (1/0.060) = 100) packets each second. Even though this is a theoretical maximum, it should be more than enough to send every 100 ms. (See this post for more info on BLE throughput). What is the connection intervals on your peripheral application?

Children
No Data
Related