File transfer over BLE

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
user_1528391
Level 4
Level 4
First like received First like given

Hi,

We are developing a mobile application based on custom BLE services. It will transfer a file (a hex file in this case but it's not important) to our custom BLE board which is based on CYBLE-012011. I wanted to ask you what is the best way to transfer a file over BLE. The file size will be 1 MB maximum.

What I plan is to create a custom characteristic with a maximum payload length. As I know, we can set the MTU size to 512 bytes manually with a handshake, that's okay. After handshaking the MTU size, we are planning to write the file in chunks to this characteristic. It will write 512 bytes every time and wait for the device (BLE server custom board) to send an acknowledgement. After getting the ACK, it will write the next chunk. My questions are below:

1: Are there any better ways to achieve this? Because there will be 2048 chunks to write a 1MB file. It will wait for an ACK every time from the device.

2: How should I send the ACK from the device to the phone? I think we can do this with the WriteResponse. We can also create another Characteristic for the ACK and notify the phone(BLE central) when the device is ready to receive the new chunk.

3: Where does the 512 byte MTU come from? I mean is this the maximum number of MTU that any BLE stack can allow according to the BLE SIG? Does this maximum number vary in different stacks? If yes, it can cause problems with different mobile phones. I want it to be generic and work in every phone model.

Thanks,

Abdullah.

0 Likes
1 Solution

Hi Abdullah,

  -> It is recommended that you send WriteResponse as soon as possible else client may give timeout error.

-> Bluetooth headsets uses standard bluetooth profiles ( A2DP profile or Headsets Profile ) and not BLE profiles. Bluetooth communication is different than BLE communication.

-> You may like to have a look at our Code Example " External Memory OTA Bootloader "  which uses the same concept of receiving an image over BLE and writing it to external memory.

-Gyan

View solution in original post

3 Replies