Hi all,
We are using the BMD-340 from uBlox, which runs the nRF52840 SoC.
On this BLE Peripheral, we are running the ble peripheral demo project ble_app_uart (pca10056), which has only been lightly modified for our uses. We are using the nRF device to receive file transfer packets over BLE, and to send them to our processor over UART (115200 baud). We are using SDK version 16.0.0, and SoftDevice S140 v7.0.1. Despite our best efforts, we are seeing very slow throughput data rates.
We are trying to perform a file transfer (a binary update via a bootloader) over Bluetooth, implementing the xModem protocol (a quick google search will explain it - not sure if I'm allowed to post links). In essence, this a simple file transfer protocol, in which the host sends 128 byte packets, and the client sends back a 1 byte response (ACK, NAK, etc) for every received packet. The host will not send the next packet until it received an ACK. Note: after accounting for encoding overhead, our payload packets (coming from the host, i.e. the tablet) are 155 bytes, and the responses from the client (the bootloader/BLE peripheral) are 27 bytes.
For reference, when completing this process over a straight serial UART cable (115200 baud), we see a data rate of ~7.50-8.50KB/s.
On an iPad Air 2 running iOS 13.5.1, we saw an effective data rate of 2.08kB/s
On a Samsung Galaxy Tab A running Android 9, we saw an effective data rate of 0.71KB/s.
This is completely baffling to our team - but admittedly, our team is fairly inexperienced with programming with the BLE spec. Please see below for the changes we've made to the demo ble_app_uart project.
We have made the following changes to the main.c:
#define UART_TX_BUF_SIZE 1024 /**< UART TX buffer size. */
#define UART_RX_BUF_SIZE 1024 /**< UART RX buffer size. */
^ increased to 1024 from 256
-> We also added a simple function that wraps all of our received messages over BLE with COBS encoding (a very simple framing scheme) before transmitting those messages over the UART line.
-> We also have a very simple function that checks if the incoming message is of a specific message type
We don't have any reason to believe that these changes are what's causing the extremely low throughput.
And we have made the following changes to the sdk_config.h:
#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247
#define NRF_SDH_BLE_GAP_DATA_LENGTH 251
^ both of these values were 160 originally
Other than the above, nothing else is currently different from the demo project.
We've also tried changing many other settings (Min/Max Connection Interval, MTU size, GAP Event Length, etc) but none of them yielded very positive results, nor were they very consistent across devices. And yes we know we can try increasing the size of our payload messages, however this will be integrated into a consumer product, and must therefor work with a variety of mobile phones and tablets (some of which won't support MTU's greater than 185 - the iPad Air 2 for example).
Any and all help would be greatly appreciated!! We're even curious why the iPad Air 2 is almost 3x faster than the Galaxy TabA 10.1, since the iPad is about 5 years older.
Thank you in advance! Feel free to ask for additional information, I will be happy to oblige where possible.
Cheers,
Ty