I am currently trying to send indefinitely large files over BLE. To do this I have a central and peripheral application running between 2 nRF52840's (one peripheral, one central). The peripheral sends data via sd_ble_gatts_hvx.
When I am sending files that are small enough to fit inside one pre-allocated file buffer (size = 1000) I have no issue. The buffer is modulated into packets of NRF_SDH_BLE_GATT_MAX_MTU_SIZE (or less for the final packet) and the central application receives all the correct bytes.
When I am sending files that are too large for to fit inside one pre-allocated buffer, I send each buffer individually, i.e. I will modulate the file buffer into packets of NRF_SDH_BLE_GATT_MAX_MTU_SIZE (with the exception of the final packet which may be smaller). Once the central node has confirmed it has received all of the buffer's data and written it to an SD card, I will read new data into the peripheral's file buffer and begin the process again.
This method works fine until the very last packet of the very last file buffer. For some reason the central application receives a jumble of incorrect bytes. This packet is the correct length.
An exception to this failure is if the file can be modulated by NRF_SDH_BLE_GATT_MAX_MTU_SIZE with no remainder (i.e. never sends a packet smaller than NRF_SDH_BLE_GATT_MAX_MTU_SIZE).
If anyone has had a similar issue to this, please point me in the right direction.
Edit 2021-04-07: My application is based on the image transfer demo, which can be found here. I use ble_its_send_file to send my files from the peripheral. The central application then receives a data event and processes the incoming data.