【发布时间】:2022-11-01 22:29:02
【问题描述】:
通过了解蓝牙特性中的标志字段,我遇到了一些问题。
例如心率测量特性:
及其标志:
根据我的理解,值的第一部分必须包含标志。 例如 0x06 用于:
- 心率值格式设置为 uint8
- 检测到传感器接触 = true
- 传感器触点支持 = true
然后值的第二部分是字节(心率)。
在 Python 中,我像这样填充值:
value = []
value.append(dbus.Byte(0x06))
value.append(dbus.Byte(randint(90, 130)))
整个事情也很完美。当我使用应用程序 nRF connect 连接到服务器时,我得到的所有信息都与所有信息完美显示。
现在关于我的问题:
我试图实现重量测量特性。
我想要以 kg 为单位的体重、BMI 和身高。因此,据我所知,我必须用 0x08 填充标志字段以表示 00001000。
在 Python 中,它看起来像这样:
value = []
value.append(dbus.Byte(0x08))
value.append(dbus.Byte(randint(1, 13))) #weight
value.append(dbus.Byte(randint(1, 25))) #BMI
value.append(dbus.Byte(randint(1, 25))) #height
现在我在 nRF Connect 应用程序中收到消息无效数据语法。
我的问题是:
- 分辨率0.0001如何处理?值 = 高度/0.0001 还是高度*0.0001?
- 表示的值 M = 1, d=-1, ... 是什么意思?
- 为什么我在第二个 python 代码中的值无效?
非常感谢您的帮助!
我正在为我的服务器使用 bluez5.63/test/example-gatt-server.py!
【问题讨论】:
-
在bluetooth.com/specifications/assigned-numbers 的
GATT Specification Supplement文档中查看“2.3 值和表示值”部分,其中解释了表示值
标签: bluetooth bluetooth-lowenergy gatt bluetooth-gatt characteristics