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

sd_ble_gatts_hvx() cannot sent many packets in the loop

Hi 

I had a problem which I want to send many packets in a loop using sd_ble_gatts_hvx(), but when the number is 5, the error code(NRF_ERROR_RESOURCES) is happened. Then I used the BLE_GATTS_EVT_HVN_TX_COMPLETE to send other packets. But there are three questions. Firstly, when I send 4 packets ,could  the BLE_GATTS_EVT_HVN_TX_COMPLETE  be carried on 4 timers? Secondly, 4 packets may be the limit of BLE buffer, Can I revise it? Finally, I send 160 packets, because the rate of BLE is 1Mbps, the packets could be spent  about 20ms. But that's not case. Why? Thanks for your answer.

for(j = 0;j < 160 ;j++)
{

..................

err_code = ble_lbs_on_button_change(m_conn_handle, &m_lbs, 0);
if(err_code == NRF_ERROR_RESOURCES)
  break;
if(err_code != NRF_SUCCESS &&
err_code != BLE_ERROR_INVALID_CONN_HANDLE &&
err_code != NRF_ERROR_INVALID_STATE &&
err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
{
    APP_ERROR_CHECK(err_code);
}

................

}

  • Hi,

    1 Mbps is only onair data rate of BLE. The actual data you can send is depends on many criteria. It's relate to connection interval, actual data length, event length etc. 

    If you have a look here you can find that data is transferred on each connection interval. You would need to configure your event length in your softdevice to maximize the time you can transmit on each connection interval. But there also no guarantee that you would be able to transfer unlimited number of packet per connection interval, it depends on the peed device. 

    I would suggest you to have a look at the discussion here.

Related