I am sending a data packet by notification that spans many MTU sizes. So I do a loop over the sd_ble_gatts_hvx(m_connection_handle, &hvx_params) method until I get a BLE_ERROR_NO_TX_PACKETS error. Now I have to wait for the BLE_EVT_TX_COMPLETE event before repeating the notification that failed and continuing on. I may run out of TX packets again, so the process repeats.
Now I am trying to understand when that BLE_EVT_TX_COMPLETE is called and how often it is called and when can I perform the next send which is an indication on another characteristic. I am running this on the nRF51 DK so I have a putty window catching print statements (which often overflows in this test). These BLE_EVT_TX_COMPLETE events keep coming until all the packets I have notified have been accounted for.
The question is when can I start doing the indication? I finish doing all the notifications before all the BLE_EVT_TX_COMPLETE events have been received; a good tenth of a second before all BLE_EVT_TX_COMPLETE events have been received. Can I start sending indications BEFORE all the BLE_EVT_TX_COMPLETE events have been received or will I just get an NRF_ERROR_BUSY error?
In other words, if I send a notification and receive no error, is that packet out the door? Additionally, if that happens to be the last notification I need to send for that data packet, can I immediately start sending an indication?
Please explain the relation between sending a notification, having the notification successfully on its way to the peer, and the BLE_EVT_TX_COMPLETE events.
Note that I am using only SoftDevice and I am pulling events from SoftDevice in the main for-loop when the sd_app_evt_wait() is triggered. When it is triggered I check if notifications/indications need to be sent and if they do, they are done.