首页 > 解决方案 > BLE onCharacteristicRead 接收状态 133

问题描述

我正在开发一个 BLE 中央应用程序(服务器)并在我的三星 Galaxy S8 上对其进行测试。在我的手机决定更新(从 7.1.0 到 8.0.0)之前,该应用程序正在运行。

我正在从已知特征/服务中进行标准读取。设备在功能中正确连接

public void onConnectionStateChange(final BluetoothGatt gatt, int status, int newState)

并且预期的服务出现在函数中

public void onServicesDiscovered(final BluetoothGatt gatt, int status)

. 在这两个回调中,status等于 0。所以一切似乎都在工作,直到我打电话

gatt.readCharacteristic(characteristic);

来自onServicesDiscovered回调,之后有很长的暂停,然后调用

public void onCharacteristicRead(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, int status)

当我用 . 检查特征值时,状态等于 133 和“null” Log.d("DEBUG", "" + characteristic.getStringValue(0));characteristic.getValue()也返回null。

最奇怪的是,这段代码在更新之前都运行成功了。(我现在已经将 BLE 代码复制到一个新项目中以隔离它,并相信我已经从原始项目中复制了适当的权限。)

在此特定回调中会导致错误 133 的原因是什么?我似乎在文档( https://developer.android.com/reference/android/bluetooth/BluetoothGatt )中找不到 133 ,所以即使只是帮助解释错误也是一个很好的步骤。

标签: androidbluetooth-lowenergyandroid-ble

解决方案


推荐阅读