简体   繁体   English

Android BLE Gatt特性WRITE_TYPE_NO_RESPONSE无效

[英]Android BLE Gatt Characteristic WRITE_TYPE_NO_RESPONSE not working

I have developed an Android app that connects to a CC2540 BLE peripheral. 我开发了一个连接到CC2540 BLE外设的Android应用程序。

When I do a Characteristic write of type no response (WRITE_TYPE_NO_RESPONSE), I still get the callback onCharacteristicWrite at the app level. 当我进行类型无响应的特征写入(WRITE_TYPE_NO_RESPONSE)时,我仍然在应用程序级别获得onCharacteristicWrite的回调。 Is this behavior correct? 这种行为是否正确?

I understand there is probably a low level acknowledgement that occurs between the Android device and the peripheral. 我知道Android设备和外围设备之间可能存在低级别确认。

But the reason I am asking is because this is causing an issue where I can only send a write once I have received this callback, which is slowing things down in the app. 但我之所以要问的原因是因为这导致了一个问题,我只能在收到回调后发送一个写入,这会减慢应用程序中的速度。

Any light on this behavior would be appreciated it. 对此行为的任何启示都将受到赞赏。

Thanks, 谢谢,

I did run into the same problem when I was trying to do some performance testing and found that when I used the WRITE_TYPE_DEFAULT specifically I stopped getting a response. 当我尝试进行一些性能测试时,我遇到了同样的问题,发现当我特意使用WRITE_TYPE_DEFAULT时,我停止了响应。 There might be a bug with the android constants that is causing inverse behavior, but I am not quite not sure. android常量可能存在导致反向行为的错误,但我不太确定。

you can only make 1 transfer at a time on the low level so you need a callback to tell when the stack is ready to send another command. 你只能在低级别上一次进行1次传输,因此你需要一个回调来告诉堆栈何时准备发送另一个命令。 If you try to send several after each other without waiting for the air-interface to be ready you can seriously crash the BLE stack! 如果你试图在没有等待空中接口准备就绪的情况下发送几个,你可以严重崩溃BLE堆栈! This was happening a lot on earlier iOS CoreBluetooth. 这在早期的iOS CoreBluetooth上发生了很多。 If one app crashes the BLE Stack then the phone need a reset or Bluetooth must be turned off and on again to reset the stack. 如果一个应用程序崩溃BLE堆栈,则手机需要重置或蓝牙必须关闭再打开以重置堆栈。 The callback just tells you that the stack has send a request over the air-interface, not that it was acknowledged by the recipient. 回调只是告诉你堆栈已通过空中接口发送请求,而不是收件人已确认。 For that you would use the other api which will make the BLE Stack re-transmit several times (depending on how the connection parameters has been negotiated). 为此,您将使用另一个api,它将使BLE堆栈重新发送几次(取决于协商连接参数的方式)。

It's stated clearly in the BLE specification that only 1 transfer can be made at a time. 在BLE规范中明确指出,一次只能进行1次传输。

If you just bang the API with write requ 如果你只是用写请求敲击API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM