简体   繁体   English

Android:如何获取与 BLE 心率 GATT 服务的测量特性相关的时间戳?

[英]Android: how to get the timestamp related to a measured characteristic of a BLE heart rate GATT service?

I'm doing as the guide says and all work perfectly fine.我正在按照指南所说的进行操作,并且一切正常。 I can discover the heart rate service from the GATT server and then get all the updates from the heart rate characteristic samples.我可以从 GATT 服务器发现心率服务,然后从心率特征样本中获取所有更新。

However, is there a characteristic to get the timestamp related to each heart rate sample?但是,是否有一个特征可以获取与每个心率样本相关的时间戳? Getting the System.currentMillis() whenever I get a sample seems too inaccurate to me.每当我得到样本时获取 System.currentMillis() 对我来说似乎太不准确了。 I'd want something like this我想要这样的东西

 if (UUID_HEART_RATE_TIMESTAMP.equals(characteristic.getUuid()))

EDIT: I'm referring to the example at the line编辑:我指的是行中的示例

if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) {

where the app can parse the data received by the heart rate sensors.应用程序可以在其中解析心率传感器接收到的数据。 Is there a way to parse a timestamp value together with the heart rate?有没有办法将时间戳值与心率一起解析? The result I need is something like a couple of values, not the single hear rate.我需要的结果是一些值,而不是单一的听力率。

(timestamp, heart rate) (时间戳,心率)

Receiving the exact timestamp related to a BLE heart rate measurement is impossible since this is not part of the BLE Heart Rate Service GATT specification :接收与 BLE 心率测量相关的准确时间戳是不可能的,因为这不是BLE 心率服务 GATT 规范的一部分:

3.4 Requirements for Time-Sensitive Data 3.4 对时间敏感数据的要求

The Heart Rate Measurement characteristic contains time sensitive data and is considered a time-sensitive characteristic, thus the following requirements apply:心率测量特性包含时间敏感数据并被视为时间敏感特性,因此适用以下要求:

Since this service does not provide for a time stamp to identify the measurement time (and age) of the data , the value of the Heart Rate Measurement characteristic shall be discarded if either the connection does not get established or if the notification is not successfully sent to the Client (eg, link loss).由于此服务不提供时间戳来识别数据的测量时间(和年龄),因此如果连接未建立或通知未成功发送,则应丢弃心率测量特性的值给客户端(例如,链接丢失)。

As indicated by the documentation, you can assume that transmitted measurements are 'fresh' and therefore using the receiving device's timestamp upon arrival is a good approximation.如文档所示,您可以假设传输的测量值是“新鲜的”,因此在到达时使用接收设备的时间戳是一个很好的近似值。

Unfortunately, RR-intervals might need more precision and are contained within the same not-timestamped measurements.不幸的是,RR 间隔可能需要更高的精度,并且包含在相同的无时间戳测量中。 Assessing the timestamp of individual RR-intervals might require some more trickery since multiple intervals are bundled together per measurement.评估单个 RR 间隔的时间戳可能需要更多技巧,因为每个测量将多个间隔捆绑在一起。

If more RR-Interval values are measured since the last notification than fit into one Heart Rate Measurement characteristic, then the remaining RR-Interval values should be included in the next available Heart Rate Measurement characteristic.如果自上次通知以来测量到的 RR 间隔值多于适合一个心率测量特征的 RR 间隔值,则剩余的 RR 间隔值应包含在下一个可用的心率测量特征中。

If there is no available space in the internal buffer of the Heart Rate Sensor, it may discard the oldest RR-Interval values.如果心率传感器的内部缓冲区没有可用空间,它可能会丢弃最早的 RR-Interval 值。

You might thus have to use the transmission interval to assess whether or not measurements have been dropped, which impacts your ability to timestamp RR-intervals.因此,您可能必须使用传输间隔来评估测量是否已被丢弃,这会影响您为 RR 间隔设置时间戳的能力。

In typical applications, the Heart Rate Measurement characteristic is notified approximately 1 time per second and includes the Heart Rate Measurement Value field and, if supported, the RR-Interval field.在典型应用中,心率测量特性大约每秒通知 1 次,包括心率测量值字段和 RR-Interval 字段(如果支持)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM