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

How can I know ble_nus_data_send() had send data complete?

Hi,

I am try to send many data via ble_nus_data_send() function, but I found "Host can not receive any data if ble_nus_data_send() is execute busy".

So, I have two questions:

1. How can I know "ble_nus_data_send() had complete send data to host?.

2. If I want to send many data to host in short time, how can I do?

Thank you,

Chianglin

  • Hi,

    ble_nus_data_send() will return NRF_ERROR_RESOURCES if you send data to fast. This error means that the internal notification queue is full, and you need to wait for a notification to be sent before trying again.  

    1. As illustrated by the message sequence chart here, you will get the BLE_GATTS_EVT_HVN_TX_COMPLETE event when the client has received one or more notification packets. 

    2. To maximize throughput, it's important to handle the NRF_ERROR_RESOURCES error from ble_nus_data_send(). That is, if you get the NRF_ERROR_RESOURCES  error, wait for the BLE_GATTS_EVT_HVN_TX_COMPLETE event then try again. 

Related