如何从葡萄糖测量特性(蓝牙)解码响应 [英] How to decode response from Glucose Measurement Characteristic (Bluetooth)

查看:49
本文介绍了如何从葡萄糖测量特性(蓝牙)解码响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个本机应用程序,我试图从Accu-Chek Guide设备获取葡萄糖测量值.

我对BLE的知识有限,这个stackoverflow问题对我了解蓝牙和获取葡萄糖测量值有很大帮助.从通知特征(离子-蓝牙)中读取

所以,我在我的代码中做什么:

1,连接到BLE外围设备
2,监视特征葡萄糖功能&记录访问控制点
3,将 0x0101(报告已存储的记录|所有记录)发送到记录访问控制点
4,解码响应

到目前为止,我有1-3个工作,但我不知道如何解码葡萄糖功能的响应:

血糖测量的通知响应

[27、4、0、195、164、7、7、14、11、6、5、90、2、119、194、176、195、184、0、0]


记录访问控制点的通知

[6,0,1,1]

解决方案

我假设这是Bluetooth SIG所采用的连续葡萄糖监测服务(CGMS)的配置文件,其规范可从以下网站获得:

https://www.bluetooth.com/specifications/gatt/

通过XML了解葡萄糖测量特性,可以更详细地了解数据的结构.

uint16 ,因此将占用两个字节.这里值得一提的是,蓝牙通常使用小尾数.

接下来是 Base Time 字段,该字段引用Reading from a Notify Characteristic (Ionic - Bluetooth)

so, what im doing in my code:

1, connect to BLE Peripheral
2, monitor characteristic Glucose Feature & Record Access Control Point
3, send 0x0101 (Report stored records | All records) to Record Access Control Point
4, decode response

So far i have 1-3 working but i dont know how to decode the response from Glucose Feature:

Notification response of Glucose Measurement

[27, 4, 0, 195, 164, 7, 7, 14, 11, 6, 5, 90, 2, 119, 194, 176, 195, 184, 0, 0]


Notification of Record Access Control Point

[6, 0, 1, 1]

解决方案

I am assuming this is the Bluetooth SIG adopted profile of Continuous Glucose Monitoring Service (CGMS) the specification of which is available from:

https://www.bluetooth.com/specifications/gatt/

Looking at the XML for the Glucose Measurement characteristic, gives more detail on how the data is structured.

https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.glucose_measurement.xml

There will be a little bit of work to do to unpack the data.

For example, the first byte stores the information for the first field named flags. However you need to look at the first 5 bits for those various flags.

The next field is "Sequence Number" which is a uint16 so will take two bytes. Worth noting here that Bluetooth typically uses little endian.

Next is the Base Time field which refers to https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.date_time.xml which will take the next 7 bytes.

Because some of the 9 fields in the characteristic take more than one byte, this is why you are seeing 20 bytes for the 9 fields.

这篇关于如何从葡萄糖测量特性(蓝牙)解码响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆