因为项目有个需要连接ble设备的,有些手机能够连接上,有些手机就会一直报status=133的错误。
原因有两个:
1、断开连接用的BluetootGatt.disconnect(),这样只是断开连接,并没有关闭,因为BluetoothGatt连接个数有限制,所以必须关闭连接:
**
* Close this Bluetooth GATT client.
*
* Application should call this method as early as possible after it is done with
* this GATT client.
*/
所以,每次使用完连接后必须调用BluetoothGatt.close();
2、 如果以上已经做好,却发现还是出现status=133,此时错误很可能是传输层的模式的问题。在android5.0(不包括)以下,不支持设置模式,连接ble的函数为:
public BluetoothGatt connectGatt(Context context, boolean autoConnect,BluetoothGattCallback callback)
而5.0和5.1两个版本内部源码多