Android BluetoothGatt - status 133 - register callback
Alright I have figured it out. The issue was mainly an oversight of when I was reading through the BluetoothGatt
documentation. I was calling .disconnect()
, but not .close()
. Since the Galaxy s4 can only handle 6 connections at a time, my service was only running 6 times. Adding the .close()
to my code allowed it to properly shut down the connection and freed up those used connections.
Source that made me re-read the docs more carefully!
So remember to use .close() on your BluetoothGatt object if you have a recurring connection to the same device(s)!!
After months of research and pulling my hair out, I have found a solution that is not normally talked about.
Your normal connect request looks something like this:
cGatt.connectGatt(this, false, gattCallback);
There is another version of the connectGatt command, with a 4th parameter. This parameter specifies what type of bluetooth device you are connecting to. I added a "2" to specify that I am connecting via Bluetooth LE. (it's called "transport", forgive me if my explanation is incorrect, but it solved all my problems)
Try this:
cGatt.connectGatt(this, false, gattCallback, 2);
And BAM, now my #133 nightmare is over (I pray)!
Android OS < 6.0:
mBluetoothDevice.connectGatt(context, false, callback);
Android OS >= 6.0:
mBluetoothDevice.connectGatt(context, false, callback, BluetoothDevice.TRANSPORT_LE);
Ultimately, hardware equipment is needed to completely solve this problem.