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

BLE fragmentation issue

Hi 

I ran in some problems with my BLE fragmentation.
I want to send data (files) up to 6kBytes over BLE (Bluetooth 5 on nrf52840 to another nrf52840).
My project is based on the BLE APP UART EXAMPLE which I simply modified.

To send that amount of data, I wrote a BLE fragmentation function which sends out BLE fragments up to "BLE_NUS_MAX_DATA_LEN" (which are 244 Bytes).
Sending data up to roughly 960 Bytes works fine (4 BLE packets).
Exceeding the fourrh BLE packet, for example 990 Bytes (5 BLE packets) the program get stuck in something (like infinite loop) which I wasn't able to figure out yet. In debug mode after pausing the infinite loop, I end up in the "NRF_BREAKPOINT_COND", so restart is required. The Debug log just says: "Fatal error." (With Error-ID: 1)


I cannot figure out the reason why the programm stops working at that point.

I attached my fragmentation function below.

Thanks for your suggestions in advance.

Parents
  • Hi Alexander ,

    When do you call the ble_send_fragment_by_fragment() function ? 

    If you call the function from an interrupt handler it may not be the best idea. 

    Staying in the loop to try sending the data may block the softdevice handle to fetch the events. And it again resulted in that the softdevice can't send anything more. It can result in a deadlock. 

    Instead of staying in the loop trying to send data, you can instead wait for the BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE before you send more data. Try to call as much as possible of the write command inside that event, and stop and wait for next event if you hit buffer full. 

    I would suggest to have a look at ble_app_att_mtu_throughput example. 

  • Hi.

    Good thought.
    Actually, I am calling the function in the SPI handler, as I want to have a SPI-BLE interface. 

    I will try to rearange the program flow and put the ble_send_fragment_by_fragment in the main loop. 

    I will come back to you as soon as I got some new results.

    Thanks.

Reply Children
No Data
Related