读取特征时GATT 137异常

时间:2018-01-26 11:48:19

标签: android bluetooth bluetooth-lowenergy rxandroidble

我使用RxAndroidBle库连接bluetotooth设备。当我读到蓝牙设备的特性时,我得到了GATT 137异常。 为什么我无法读懂特色? 代码段:

 if (device.connectionState == RxBleConnection.RxBleConnectionState.CONNECTED) {
         rxConnection.readCharacteristic(ConstantsBle.deviceUUIDCharacteristic).subscribe({
             Log.e(TAG, "read characteristic task is success")
         }, {
             it.printStackTrace()
         })
     }

异常详情:

  

W / System.err的:   com.polidea.rxandroidble.exceptions.BleGattCharacteristicException:   来自MAC地址0C的GATT异常:F3:EE:2A:ED:49,状态137,类型   BleGattOperation {描述=' CHARACTERISTIC_READ'}。 (查找状态   这里是0x89   https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-5.1.0_r1/stack/include/gatt_api.h)   W / System.err:at   com.polidea.rxandroidble.internal.connection.RxBleGattCallback.propagateErrorIfOccurred(RxBleGattCallback.java:227)   W / System.err:at   com.polidea.rxandroidble.internal.connection.RxBleGattCallback.access $ 800(RxBleGattCallback.java:32)   W / System.err:at   com.polidea.rxandroidble.internal.connection.RxBleGattCallback $ 2.onCharacteristicRead(RxBleGattCallback.java:108)        在android.bluetooth.BluetoothGatt $ 1.onCharacteristicRead(BluetoothGatt.java:286)   W / System.err:at   android.bluetooth.IBluetoothGattCallback $ Stub.onTransact(IBluetoothGattCallback.java:117)   W / System.err:在android.os.Binder.execTransact(Binder.java:565)

1 个答案:

答案 0 :(得分:1)

您无法读取该特性,因为您的外围设备的身份验证失败了。

状态代码:1370x89 hex)在Android sources中有所描述。您甚至在粘贴的日志中都有链接。

这种情况可能有以下几种原因:

  1. 中央无法与外围设备建立联系
  2. 已经存在的债券已被一方(there are known bugs in Android
  3. 删除
  4. 刚刚为当前连接建立了配对 - 在这种情况下,您可以重试读取并且它应该成功
  5. 请注意,配对和绑定在BLE中是两个不同的东西,尽管它们经常互换使用。

    配对是一个针对特定连接的短期流程,而绑定则与后续的加密密钥交换配对(然后可以将这些配对重新用于下一个配对)。

相关问题