Wish Way to tell completion status for a BLE2 Writedata.

Turbo3

Active Member
Licensed User
Longtime User
I need to send 22 bytes of data which is more data then will fit in one Writedata transfer which is limited to 20 bytes. To do this I send one transfer of 20 bytes followed by a second writedata of 2 bytes but the second writedata can not take place until the first write has completed. If the second writedata is executed before the first completes the app crashes with a write error. To avoid overrunning the first writedata I currently use a timer to wait 350 msecs before sending the second writedata. This does not seem like a good way to handle this.

Is there a way to detect when the Bluetooth controller has received the write response message signaling that the first writedata has completed? Keep in mind a notification is only sent back after the full 22 bytes have been received by the target device. So I can not use the DataAvailable event which I normally use to trigger when next the writedata can be sent.

I have been using WireShark to examine the btsnoop_hci.log files of the Bluetooth traffic to verify this behavior. On the trace I can see the Write Request going out followed by the the inbound "Number of Completed Packets" and "Write Response" sent from the controller to the host. I just need some way to see this in my app.
 

Turbo3

Active Member
Licensed User
Longtime User
Thanks Erel. What are the Status values that come with WriteComplete?

By fix the error does that mean you will hold off sending the second WriteData until the first one completes? So I can just send two back to back WriteData commands?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Top