Android Question BLE2 WriteData fails when DataAvailable events are arriving from a previous ReadData

I have a B4A app that periodically reads services/characteristics from an Arduino backend using ReadData and a DataAvailable event routine. (not using notify)
Occasionally in response to UI activity the app goes to WriteData some writable characteristics. The write almost always fails unless it's timed to be well out of the way of the DataAvailable events (or I turn the reads off).

So I can get round it (not tried yet) by queueing up the write(s) until the read(s) are complete. That's OK, but some questions arise:
1. Is this expected behaviour or a bug?
2. Is there any way of finding out when the DataAvailable events from a given ReadData have finished? (I know I can always read specific services and keep track that way)
 
Thanks. The joys of networking...
Have averted the crashes in writes by limiting the amount read in the reads (only specific services rather than all connected). However, now if I write too often around ReadData and its callback, the ReadData succeeds but the callbacks stop coming. Seems I need to bite the bullet and have some sort of queueing scheme. Will also check on the Arduino end if anyone has seen this sort of thing before.
 
Upvote 0
Top