我正在使用Android 5.1(蓝牙4.0)和具有蓝牙4.2的MCU板的Android设备。阅读Gatt特性后会发生什么?
在我的MCU端,我正在更新环路中的GAT特性,以确保我知道我写入的数据是否一致。在我写入gatt数据库之前,我正在使用crc检查。
在我的android端我只是有一个线程,读取特征从那个gatt数据库中读取,然后我有相同的crc,但它似乎有50%的值是腐败的(这是没有意义的我这边)。 我知道我写在我的gatt数据库中的数据是正确的,所以我想问题是在线程中多次读取特征。
我已经尝试通过我的android端的通知读取特征,但bluetoothleservice永远不会跳入OnCharacteristicChanged回调。
我的特征更新貌似这个
tmpGatt.readCharacteristic(characteristic);
和特性由UUID之前
for(int i = 0; i<Services.size(); i++){
Characteristics = Services.get(i).getCharacteristics();
for(int c=0;c < Characteristics.size();c++){
UUID myUUID = Characteristics.get(c).getUuid();
if(myUUID.toString().equals("354a1b8e-7597-11e6-8b77-86f30ca893d3")){
characteristic = Characteristics.get(c);
//refExternalData.getRefBluetoothGatt().readCharacteristic(characteristic);
descriptor = characteristic.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
Log.i("BLE", "Characteristic " + myUUID.toString() + " found");
}
}
}
过滤,因此,我需要做什么特别的重读gattcharacteristic?
我已经切换回BLE示例应用程序,现在只是为了确保onCharacteristicRead正在触发如果我推特性名称但数据仍然损坏。所以你认为问题出现在应用程序端还是在单向端? –
如果数据损坏,那肯定是MCU /发送端的问题。在空中,根据BLE标准,有效载荷已经被CRC保护。 – Emil
我会重新检查我的代码,如果我发现问题生病发布在这里。谢谢 –