Android BLE BluetoothGatt.writeDescriptor()有时返回false [英] Android BLE BluetoothGatt.writeDescriptor() return sometimes false

查看:510
本文介绍了Android BLE BluetoothGatt.writeDescriptor()有时返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写BLE Android应用.我发现有时候我打电话时 BluetoothGatt.writeDescriptor()它返回false.

I'm trying to write BLE Android app. I found that sometimes when I call BluetoothGatt.writeDescriptor() it returns false.

我在文档中没有发现任何限制此功能的记录.但是栈上的ppl表示我需要等待

I have not found in documentation any note of limitation to this function. But ppl on stack overflow says that I need to wait for BluetoothGattCallback.onDescriptorWrite() before I try to write another descriptor.

这里有一封回复说, BLE正在使用writeDescriptor()忙,并且无法执行其他写操作.

Here is one reply saying that BLE is busy with writeDescriptor() and can not do other write.

这是另一个线程,表示您不能调用两次writeCharacteristic().

Here is another thread saying that you can not call twice writeCharacteristic().

我的问题是

  • 真的是真的吗?
  • 是否真的缺少用于序列化BLE请求的内部android API缓冲区,并且每个开发人员都必须自己完成?
  • 不同功能是否正确?例如,当我呼叫writeDescriptor()时,我知道在收到onDescriptorWrite()之前无法再次呼叫writeDescriptor().但是,要呼叫writeCharacteristic()时是否必须等待onDescriptorWrite()?
  • 如果还存在函数间依赖关系,那么还有哪些函数具有此限制(即:readCharacteristic()readDescriptor()requestMtu() ...)?
  • 此外,BluetoothGattServer和BluetoothGatt之间存在相互依赖性.因此,例如,当我呼叫BluetoothGattServer.notifyCharacteristicChanged()时,我应该等待 BluetoothGattServerCallback.onNotificationSent ,然后才能呼叫BluetoothGatt.writeDescriptor()BluetoothGatt.writeCharacteristic()? (顺便说一句,对Google文档onNotificationSent()的称赞是幸运的,有据可查.Doc说:
  • is it really true?
  • is there really missing some internal android API buffer for serializing BLE requests and every developer has to do it on it's own?
  • Is it true for different functions? For example when I call writeDescriptor() I understand I can not call second time writeDescriptor() before I receive onDescriptorWrite(). But do I have to wait for onDescriptorWrite() when I want to call writeCharacteristic()?
  • Also if there is inter-function dependency then what else function have this limitation (namely: readCharacteristic(), readDescriptor(), requestMtu()...)?
  • And additionally is there interdependency between BluetoothGattServer and BluetoothGatt. So for example when I call BluetoothGattServer.notifyCharacteristicChanged() shall I wait forBluetoothGattServerCallback.onNotificationSent before I can call BluetoothGatt.writeDescriptor() or BluetoothGatt.writeCharacteristic()? (BTW praise for google documentation onNotificationSent() is by luck documented properly. Doc says:

要发送多个通知时,应用程序必须等待 以便在发送其他回调之前收到此回调 通知.

When multiple notifications are to be sent, an application must wait for this callback to be received before sending additional notifications.

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆