Why do we get ERROR_GATT_WRITE_REQUEST_BUSY error while writing to characteristic?

62 Views Asked by At

I am building chat app on ble. I do not need queue as i will be writing sequentially. But sometimes i get this error. I tried to debug it, what i found is if i remove my Notify Characteristic then it works fine, but if i add it then it shows that error. How are they related? I tried to find but there is no document which talks about this error.

1

There are 1 best solutions below

0
Youssif Saeed On

This error usually happens when you are trying to perform too many GATT operations at the same time. I haven't seen it happen because there is a write attempt when notifications are ongoing, as most GATT servers are able to handle that. I have mostly seen it when a GATT write operation is being performed in quick succession without waiting for the "Done" or "ACK" events. Maybe this is happening in your case because you are sending too many write events? You can test this by doing a proper flow of waiting for the GATT complete events before performing a new GATT operations, or as a quick hack/workaround you can try introducing a small delay before successive GATT writes to see if this fixes your problem. In any case, as Michael Kotzjan suggested, sharing your code will make it much easier to debug what actually is happening.