Android GATT 133, continued
Some other reasons you may see the GATT 133 status
Remember - the "GATT_ERROR" (aka GATT status 133, aka 😖) is really a catch-all status for when something goes wrong.
You may be correctly queuing up requests and handling things serially, but see the error when making connection requests.
What could still be the issue?
- Check the GATT instance count
One thing to look for is the "clientIf" value that is logged when the BluetoothGatt
instance is created:
2022-07-18 13:47:20.006 21886-23962/com.safr.app D/BluetoothGatt: onClientRegistered() - status=0 clientIf=9
This value represents the number of peripheral handles - once it exceeds the maximum allowed connections (37), the Bluetooth adapter will report 133 statuses until the Bluetooth adapter is reset.
2. Are you attempting to re-connect after a disconnect?
The Bluetooth stack should wait for a short period (the "supervisor timeout") before full disconnecting. The Android supervisor timeout is high - and it may take at least 5 seconds for the stack to truly disconnect. See this story for more detail.
3. Closing a connection that was just requested
Another thing to be aware of is that the close()
function on BluetoothGatt
will not consistently disconnect a device that has just initiated a connection request.
This may not apply to a lot of use cases, but if you have a device that many people have to access (e.g. an access control device), then this situation is something to keep in mind.