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

UART over BLE issues - Unable to send streaming data packets from nrf52 (ble_app_uart) to nRFUART app

I am using a ultra-miniature (BMD-350) series module from Rigdo which has the nRF52832 BLE SoC. The pins from the  nrf52 SoC are all brought out on a female headers on a custom PCB.

Firmware/SDK configuration:

  • nRF5_SDK_15.3.0_59ac345 SDK
  • pca10040 and softdevice s132  
  • nrf52832_xxaa

Debugger

  • J-Link EDU Mini debug module and using Segger Ozone software for debugging.

nrf Android Apps:

  • nrFConnect, nrF Logger and nrfUART app

I have modified the ble_app_uart example and attached the zip file of modified code.

In the main.c file, I modified the function nus_data_handler  to send dummy packets(appx. 24 bytes per packet)  to the nrfUART app by calling the function ble_nus_data_send periodically 5 seconds over BLE NUS to nrfUART app inside a loop over 500 times. Below is the  code snippet: 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**@snippet [Handling the data received over BLE] */
static void nus_data_handler(ble_nus_evt_t * p_evt)
{
// uint8_t rx_byte;
NRF_LOG_INFO("[%d]nus_data_handler", order++);
if (p_evt->type == BLE_NUS_EVT_RX_DATA)
{
NRF_LOG_INFO("[%d]nus_data_handler: evt=BLE_NUS_EVT_RX_DATA", order++);
uint32_t err_code;
NRF_LOG_DEBUG("Received data from BLE NUS. Writing data on UART.");
NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
for (uint32_t i = 0; i < p_evt->params.rx_data.length; i++)
{
do
{
err_code = app_uart_put(p_evt->params.rx_data.p_data[i]);
if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY))
{
NRF_LOG_ERROR("Failed receiving NUS message. Error 0x%x. ", err_code);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

While I do receive first 12 packets on nRFUART app but thereafter I stop receiving anything even though I should continue to receive remaining 489 of 500 dummy packets. The Bluetooth connection also gets disconnected and I dont see the nrf52 advertising. Thereafter, I have to reset my nRF52 to make new Bluetooth connection and restart this process.

I have tried manipulating buffer sizes used by ble_nus_data_send as well as UARt bufffers, but nothing seems to work. Either I get run-time error or issue remains.

What is the proper way to send streaming data packets to the nrfUART from nrf52 continuously using the  BLE UART service ?

ble_app_uart.zip

Parents Reply Children
  • Ok. I solved the issue. Had to replace the loop with if block. Instead I used a global variable which I loop in if on condition that  (i < 500). Within if, I increment i. The enclosing function is automatically called as each time I send a string a event is raised next which generates an event which subsequently calls the enclosing function

  • Ok. I solved the issue. Had to replace the loop with if block. Instead I used a global variable which I loop in if on condition that  (i < 500). Within if, I increment i. The enclosing function is automatically called as each time I send a string a event is raised next which generates an event which subsequently calls the enclosing function