android - BLE 通知冻结所有其他活动读取特性
问题描述
从启用通知后
BluetoothGatt gatt= leBluetoothService.getmBluetoothGatt();
gatt.setCharacteristicNotification(chracteristicId, enable);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
BluetoothGattDescriptor descriptor = chracteristicId.getDescriptor(
UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
gatt.writeDescriptor(descriptor);
我无法从任何其他特征读取数据。它冻结了所有特征。为什么会这样?启用通知后,它也不会从该特征读取数据。
编辑:
在调用设置通知后,所有读取和通知开始堆积而不是执行。我对每个操作都使用了同步静态方法。
public static void AddOperation(Operation opr) {
operations.add(opr) ;
Log.d("operations",String.valueOf(operations.size()));
if (currentOperation ==null){
currentOperation = opr;
request(opr);
}
}
private static synchronized void request(Operation operation) {
Log.d("kala", ""+operation);
operation.execute();
}
public static synchronized void operationCompleted() {
currentOperation = null;
if (operations.peek() != null) {
currentOperation = operations.poll();
Log.d("kalaa", ""+currentOperation);
currentOperation.execute();
}
}
所有读取操作都执行良好,但如果特性已通知属性,则操作开始堆积。有什么方法可以查看何时设置通知?
解决方案
推荐阅读
- android - 添加新联系人时颤动contacts_service问题
- markdown - 更改使用 md 和 pandoc 生成的 pptx 中代码块的布局
- python - 如何从python运行cmd命令?
- reactjs - 使用三个力图和打字稿错误
- javascript - 在 Electron 应用中使用 Firebase 进行 Google 身份验证
- reactjs - 开始后不久,屏幕共享视频质量从原始质量下降到低质量
- php - 无法获取graph api返回的response的key的值
- javascript - 为 JSON 字幕中的每个单词创建一个可点击的跨度
- jquery - 动态创建 L.geoJson 的样式
- flutter - 如何将函数传递给较低的小部件