我正在尝试使用MAC地址连接到一个BLE设备。
BluetoothDevice device = bluetoothAdapter.getRemoteDevice(rememberedDeviceAddress)
bluetoothDevice.connectGatt(context, false, bluetoothGattCallback);
即使我的BLE设备已经关闭,我在BluetoothGattCallback.onConnectionStateChange
中收到一个回调,其中status = 133
和newState = 2
。newState = 2是指连接状态为BluetoothProfile.STATE_CONNECTED
,而status = 133是GATT_ERROR(而不是status = 0 SUCCESS)。
我没有收到“无法注册回调”的错误。
设备:One plus one(Android 4.4)
对于可能导致此问题的原因的任何指针都将有所帮助。
注意:并非所有设备都会出现此问题。 在Android 5.0上使用Nexus 5时似乎一切正常。
请查看以下堆栈跟踪:
03-06 13:00:11.994: D/BluetoothGatt(26771): registerApp()
03-06 13:00:11.994: D/BluetoothGatt(26771): registerApp() - UUID='uuid comes here'
03-06 13:00:12.004: D/BluetoothGatt(26771): onClientRegistered() - status=0 clientIf=5
03-06 13:00:42.004: D/BluetoothGatt(26771): onClientConnectionState() - status=133 clientIf=5 device='device id comes here'