2 of 2 people found this helpful
Please find answers below- From your description , I understand that you are developing a Mobile Client App.
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.
Ans: There are no better ways other than the one you mentioned. You need to create a Characteristics with length "MTU-3" and send the data.
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.
Ans: WriteResponse is the better way because if you send a ACK from a different characteristics , it will add more latency.
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.
Ans: Yes, it comes from the BLE SIG spec and standard over all the mobile phones.
Thank you for the answer!
You are correct, we are trying to create a Mobile Client App. I have two final questions regarding yours:
1: What we want with this file is to write it to an SD card. When we receive one chunk of the file (512 byte), we will write it to an SD card. So, I need to wait for this SPI write operation to finish and then send the WriteResponse to the the client (Mobile app). But this write operation may take longer than 100ms because there is a bridge between the Cypress and the sd card. I don't want to complicate things, this is not important actually. What I'm trying to ask is, would it be a problem if we send the WriteResponse to the client after 100ms? Can a client give a timeout error or something when the server wait a bit longer to send the WriteResponse?
2: Do you know how does the Bluetooth Headsets transfer live sound data? Do they use 512 byte characteristics too? I was wondering if they somehow increase the MTU size and write bigger characteristics to lower the latency. Or do they use multiple characteristics with 512 byte size each?
1 of 1 people found this helpful
-> 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.