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

Sending data via BLE resulting in fatal error after some time ble_app_uart example

Hi,

We are attempting to send data via BLE every 100 ms using an app_timer. The app_timer sets a flag and in the while loop in main.c we call 

ret_code_t err_code;
do
{
uint16_t length = (uint16_t)len;
err_code = ble_nus_data_send(&m_nus, msg, &length, m_conn_handle);
//SEGGER_RTT_WriteString(0, "Sending data\n");
if ( (err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY) &&
(err_code != NRF_ERROR_NOT_FOUND) )
{
APP_ERROR_CHECK(err_code);
}
} while (err_code == NRF_ERROR_BUSY);

and set the flag back to 0 for the next send.

When we use nrf toolbox, we received data for some time and then get a GATT Timeout error and it disconnects. On RTT we get the following errors after setting nrf_log to debug mode

0> Debug logging for UART over RTT started.
0> <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.
0> <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.
0> <info> app: Connected
0> <debug> nrf_ble_gatt: ATT MTU updated to 247 bytes on connection 0x0 (response).
0> <info> app: Data len is set to 0xF4(244)
0> <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
0> <debug> nrf_ble_gatt: Data length updated to 251 on connection 0x0.
0> <debug> nrf_ble_gatt: max_rx_octets: 27
0> <debug> nrf_ble_gatt: max_tx_octets: 251
0> <debug> nrf_ble_gatt: max_rx_time: 328
0> <debug> nrf_ble_gatt: max_tx_time: 2120
0> <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
0> <debug> app: PHY update request.
0> <error> app: Fatal error

Parents
  • Hi Shreekant, 

    Fatal error indicates that its the SoftDevice that is asserting for some reason. 

    1. Start a debug session
    2. Set a breakpoint in app_error_fault_handler in app_error_weak.c
    3. Run the code and if you end up in the error handler, examine the call stack and identify the last sd_ - function called prior to the assert. ( It looks like it might be sd_ble_gap_phy_update() from the debug log).

    Best regards

    Bjørn 

  • We figured it out. Instead of using a do while loop, we used while(ble_nus_data_send() != NRF_SUCCESS) function. Now, we are spamming that line in a while loop, but on the nrf toolbox and our receiver software we are getting a few sets of 20 bytes with very little latency and then it hangs and then continues seemingly randomly. How do we have the nrf52 send our 20 byte data consistently with low latency. Here is our latency output from our testing software:

    Connected to device!
    data received: 20 bytes
    LATENCY: 8079
    data received: 20 bytes
    LATENCY: 241
    data received: 20 bytes
    LATENCY: 658
    data received: 20 bytes
    LATENCY: 0
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 5468
    data received: 20 bytes
    LATENCY: 50
    data received: 20 bytes
    LATENCY: 481
    data received: 20 bytes
    LATENCY: 490
    data received: 20 bytes
    LATENCY: 2
    data received: 20 bytes
    LATENCY: 528
    data received: 20 bytes
    LATENCY: 480
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 0
    data received: 20 bytes
    LATENCY: 238
    data received: 20 bytes
    LATENCY: 0
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 4
    data received: 20 bytes
    LATENCY: 475
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 0
    data received: 20 bytes
    LATENCY: 238
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 0
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 0
    data received: 20 bytes
    LATENCY: 176
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 61
    data received: 20 bytes
    LATENCY: 241
    data received: 20 bytes
    LATENCY: 181
    data received: 20 bytes
    LATENCY: 477
    data received: 20 bytes
    LATENCY: 840
    data received: 20 bytes
    LATENCY: 0
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 0
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 5936
    data received: 20 bytes
    LATENCY: 241
    data received: 20 bytes
    LATENCY: 59
    data received: 20 bytes
    LATENCY: 241
    data received: 20 bytes
    LATENCY: 0
    data received: 20 bytes
    LATENCY: 179
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 0
    data received: 20 bytes
    LATENCY: 1263
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 0
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 235
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 1
    data received: 20 bytes
    LATENCY: 0
    data received: 20 bytes
    LATENCY: 0
    data received: 20 bytes
    LATENCY: 238
    data received: 20 bytes
    LATENCY: 3
    Connection status: Disconnected from device.
    Also, when spamming the function in sdk 12.3, the latency was pretty low and consistent, which is not the case for the sdk 15. I also tried on sdk 14, which was also faster than sdk 15. 
  • How are you measuring the latency?Is it the time exeeding the time since the last packet was recieved + the connection interval? Which connection interval are you using? When you say that it hangs, you are referring to the nRF Toolbox app? Have you tried using nRF Connect ?

     

  • The same question is raised in https://devzone.nordicsemi.com/support-private/support/209985 so I suggest that we close this case and continue the discussion of the second issue there. 

Reply Children
No Data
Related