[英]How to write characteristic fast and stable for BLE in Android?
I am developing for BLE in Android. 我正在开发Android中的BLE。 The Android can send data to BLE device by
Gatt.writeCharacteristic
. Android可以通过
Gatt.writeCharacteristic
将数据发送到BLE设备。
But When I write consecutive Characteristic to BLE device (5 times in 1 Second) , I will get GATT_DISCONNECTED
and it return null
when I try to getService
and GetCharacteristic
. 但是当我连续写入BLE设备的特性 (1秒内5次)时,我会得到
GATT_DISCONNECTED
,当我尝试getService
和GetCharacteristic
时它返回null
。
I have seen some BLE LED product in market. 我在市场上看到了一些BLE LED产品 。 It use a color picker in Android like the following picture:
它在Android中使用颜色选择器,如下图所示:
When user change the color fast on the color picker , the BLE LED also change the color immediately. 当用户在颜色选择器上快速更改颜色时, BLE LED也会立即改变颜色。
How to write characteristic fast and stable for BLE in Android like the BLE LED product in market ? 如何像市场上的BLE LED产品一样在Android中为BLE写出快速稳定的特性?
When you call gatt.writeCharacteristic
you need to do 2 things: 当你打电话给
gatt.writeCharacteristic
你需要做两件事:
I have found that the best way to read (or write) BLE characteristics fast is to make the request, wait for the callback and make the next request from the callback. 我发现快速读取(或写入)BLE特性的最佳方法是发出请求,等待回调并从回调中发出下一个请求。 If there is a faster or more reliable way, I am unaware of it.
如果有更快或更可靠的方式,我不知道它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.