I am trying to use sd_ble_gatts_hvx function to send custom data through BLE. I found out that for the data I am sending the function takes a lot of time to send data which results in a FIFO error on the UART module.
For this reason, I wanted to know if sd_ble_gatts_hvx is a Blocking or Non Blocking function.
I am using SDK 15.3.0 SoftDevice 132 and nRF52832.
It's non-blocking. It returns the status in a event after the connection interval has finished. For more detailed info, please see this message sequence chart:
Thank you for this information!
In my use case have continuous values coming onto the UART lines at 57600 baud rate.
I'm reading these values using app_uart_get() and storing them in an array in the uart_event_handle function. I'm performing parsing on the incoming packets on the UART lines and storing the result of parsing in a data buffer of 20 bytes. I send the values on this buffer through BLE using the sd_ble_gatts_hvx() function.
When I run the code on the board, I get a FIFO ERROR with an error code of 1 or an error code of 4.
When I comment out the sd_ble_gatts_hvx() part of the code in the uart_event_handle function the code runs smoothly and there is no FIFO ERROR.
Could you please let me know if there is a way to avoid this FIFO error while using the sd_ble_gatts_hvx() function?
I cannot afford to drop data.
It might be that you are doing "just too much" in your interrupt function. Try to shorten your interrupt handler (ie: the uart_evt_handler()) and instead set boolean flags which you handle in your main function for instance.
Thanks a lot! It works.