SDK: v15
SoftDevice: S132
Chip: nRF52832 on BL652 Module
I have a command->response type system. The Central (Android phone) sends a command, and the Peripheral (nRF52 device) responds.
The command sent by central is interpreted by nus_data_handler() handler, and calls another function that needs to send back packets with ble_nus_data_send().
The issue is that I can only send five packets from my function, even with VERY long delays (1 sec) between each send. After five I get error NRF_ERROR_RESOURCES for each later attempt. The one second delay is obviously much longer than the packet interval.
I searched the forum extensively and implemented a flag to track when BLE_GATTS_EVT_HVN_TX_COMPLETE is raised, but I noticed that this event does not happen after every packet is sent. Also, for the packets after the initial five, BLE_GATTS_EVT_HVN_TX_COMPLETE event will not be raised until the function is finished.
I think this has something to do with interrupt priorities but I don't know how to look into that. Can ble_evt_handler() priority be greater than nus_data_handler()?
<info> app: UART_SERVICE_SUBCOMMAND_SEND_ALLEVENTS <info> app: event_id: 1 <info> app: Sending data for event: 1 <info> app: Sent data for ble. Success. <info> app: event_id: 2 <info> app: Sending data for event: 2 <info> app: Sent data for ble. Success. <info> app: event_id: 3 <info> app: Sending data for event: 3 <info> app: Sent data for ble. Success. <info> app: event_id: 4 <info> app: Sending data for event: 4 <info> app: Sent data for ble. Success. <info> app: event_id: 5 <info> app: Sending data for event: 5 <info> app: Sent data for ble. Success. <info> app: event_id: 6 <info> app: Sending data for event: 6 <info> app: Sent data for ble. Err code: 19 <info> app: event_id: 7 <info> app: Sending data for event: 7 <info> app: Sent data for ble. Err code: 19 // This is the last event it tried to send (no retry in this code) // After the last transfer attempt (#7), only then did the TX_COMPLETE event get raised <info> app: BLE_GATTS_EVT_HVN_TX_COMPLETE event <info> app: Connected <info> app: BLE_GATTS_EVT_HVN_TX_COMPLETE event <info> app: Connected <info> app: BLE_GATTS_EVT_HVN_TX_COMPLETE event