Android 4.4 BLE指示数据超过20个字节 [英] Android 4.4 BLE indication data more than 20 byte
问题描述
我对android 4.4低功耗蓝牙有疑问.
I have a question about android 4.4 Bluetooth Low Energy.
我有一个带UART Rx引脚的BLE加密狗.我可以将字节数据从Rx引脚发送到BLE加密狗,而BLE加密狗将根据指示将数据发送到蓝牙主机设备.
I have a BLE dongle with UART Rx pin. I can send bytes data from Rx-pin to BLE dongle, and BLE dongle will send the data to bluetooth host device by indication.
所以我有一个Rx特征值,它的属性是指示. 我向Rx特性发送了大约80个字节的数据,但是通过一次回调函数onCharacteristicChanged我只能得到20个字节.
So I have a Rx characteristic value it's property is indication. I send about 80 bytes data to Rx characteristic, but i only get 20 bytes by once callback function onCharacteristicChanged.
但是我使用iPad mini来指示此特征值,它接收20个字节数据之一中的4个数据包,这似乎是正确的.
But I use iPad mini to indicate this characteristic value, it receives 4 packets one of 20 bytes data and it seems right.
如何在Android回调函数中接收类似iOS的80字节数据?
How can I do to receive 80 bytes data like iOS in Android callback function ?
推荐答案
尝试协商更大的GATT MTU.默认值为23个字节. (G)ATT协议在每个通知/指示"的报头中占用3个字节. 因此,默认情况下还剩20-3 = 20个字节.
Try negotiating a bigger GATT MTU. The default is 23 bytes. The (G)ATT protocol takes up 3 bytes for the header per Notification / Indication. So 20 - 3 = 20 bytes left by default.
在iOS 8上,iOS允许的最大MTU为158字节. 我不确定Android允许什么.
On iOS 8, the maximum MTU that iOS will allow is 158 bytes. I'm not sure about what Android allows.
这篇关于Android 4.4 BLE指示数据超过20个字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!