4

我一直在研究心率测量特性文档,以了解特性的每个字节的含义。我的理解是特征的最低有效字节对应于标志字段。所以这行代码(在 Android 应用程序中)应该返回标志:

characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0);

此外,从 Android BluetoothGattCharacteristic 文档中,看起来 getProperties 方法也应该返回标志字段。

但是,当我将这两个值都打印到控制台时,它们是不同的。

代码

Log.d(TAG, "Flags  : " + Integer.toBinaryString(characteristic.getProperties()));
Log.d(TAG, "Byte  0: " + Integer.toBinaryString(characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0)));

控制台输出

byte data﹕ Flags  : 10000
byte data﹕ Byte  0: 10110

我注意到只是传感器接触状态位不同。仅仅是这些位不被视为属性吗?还是我的假设不正确?

参考

HR 测量特性: https ://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.heart_rate_measurement.xml

getProperties 方法:https://developer.android.com/reference/android/bluetooth/BluetoothGattCharacteristic.html#getProperties()

4

0 回答 0