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

BLE Long write

My Setup: Nordic is the Server, Android is the client.

I have read many, many forum posts about doing long reads/writes. Virtually everyone says you cannot do long writes. Instead you have to do a sequence of 20 byte writes.
devzone.nordicsemi.com/.../

I've also looked into Android API, and found that they do long read under the hood but do not support long write. I can only send 20 byte at a time. This is just what the forum posts have said.

HOWEVER, what I don't understand is how Noric Master Control Panel successfully executes long write. I can load up a 50 byte message and pass it over the Android App version of MCP. Is there something utilized in the MCP that I have missed, or cannot get access to in Android?

I cannot believe there is no way to write large streams of data from a phone to a BLE chip. It must be that I've missed something.

Thanks for your help!

Parents
  • Hi Darren,

    There is a feature in BLE that goes by names like "long write", "queued writes" and "prepared writes". This feature lets you write multiple 20-byte chunks of data simultaneously, even across multiple characteristics. It works by sending multiple "Prepare Write Requests" (which have their full data echoed back in the "Prepare Write Response") followed by a final "Execute Write Request" that includes a flag saying "Write now" or "Cancel". I guess this is what the MCP is doing.

    You should have the same functionality in Android by using beginReliableWrite() followed by a number of writeCharacteristic() calls and finalized with executeReliableWrite().

  • I'm still working on this. Is there some way you can post example code for this? I can write the android side code, but I don't know how to set up the nordic to allow for the prepared writes. There is so much confusion about this on the internet I am just totally lost. I really need to rewrite my application because the data rate without long write is just unacceptable. It takes seconds to send tiny string messages. Please refer me to example source code to set up my nordic to allow for writing multiple 20-byte chunks.

Reply
  • I'm still working on this. Is there some way you can post example code for this? I can write the android side code, but I don't know how to set up the nordic to allow for the prepared writes. There is so much confusion about this on the internet I am just totally lost. I really need to rewrite my application because the data rate without long write is just unacceptable. It takes seconds to send tiny string messages. Please refer me to example source code to set up my nordic to allow for writing multiple 20-byte chunks.

Children
No Data
Related