试图从极地H10 获得心率变异性

我正在使用Polar H10来获得心率变异性。

我正在运行Microsoft的蓝牙低功耗样本 。

我用这个样本从另一个极地设备(极地OH1)获得心率,它工作正常。

但现在我想从Polar H10获得HRV。 但是BLE样本代码并没有真正向我展示它应该像心率这样的HRV特征。

这是我看到的唯一特征:

// first layer keys are serviceUuid's // second layer keys are characteristicUuid's // with their respective name/description as values { "1800" /* Generic Access */ : { "2a00": "Device Name", "2a01": "Appearance", "2a02": "Peripheral Privacy Flag", "2a03": "Reconnection Address", "2a04": "Peripheral Preferred Connection Parameters" }, "1801" /* Generic Attribute */ : { "2a05": "Service Changed" }, "180d" /* Heart Rate */ : { "2a37": "Heart Rate Measurement", "2a38": "Body Sensor Location" // This is where it should show Heart Rate Variability // }, "180a" /* Device Information */ : { "2a23": "System ID", "2a24": "Model Number String", "2a25": "Serial Number String", "2a26": "Firmware Revision String", "2a27": "Hardware Revision String", "2a28": "Software Revision String", "2a29": "Manufacturer Name String" }, "180f" /* Battery Service */ : { "2a19": "Battery Level" }, "6217ff4b-fb31-1140-ad5a-a45545d7ecf3" /* unknown */: { "6217ff4c-c8ec-b1fb-1380-3ad986708e2d": "unknown", /* read:true */ // value = uInt16Array [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] "6217ff4d-91bb-91d0-7e2a-7cd3bda8a1f3": "unknown" /* write:true, indicate:true, descriptors:{ descriptorUuid: "2902" }*/ { /* 6172 */ this service has all the numbers which I have no idea about. Example: 10905, 10906, and etc. } } 

有谁知道我应该对代码进行哪些调整,以便我可以获得HRV?

  **EDIT::** private static ushort ParseHeartRateValue(byte[] data) { // Heart Rate profile defined flag values const byte heartRateValueFormat = 0x01; byte flags = data[0]; bool isHeartRateValueSizeLong = ((flags & heartRateValueFormat) != 0); if (isHeartRateValueSizeLong) { return BitConverter.ToUInt16(data, 1); } else { return data[1]; } } 

////更新方法后//////

  private static ushort ParseHeartRateValue(byte[] data) { ushort offset = 1; // Heart Rate profile defined flag values const byte heartRateValueFormat = 0x01; byte flags = data[0]; bool rr = (flags & (1 << 4)) != 0; if (rr) { int count = (data.Length - offset) / 2; for (int i = 0; i < count; i++) { ushort value = BitConverter.ToUInt16(data, offset); double intervalLengthInSeconds = value / 1024.0; offset += 2; } } bool isHeartRateValueSizeLong = ((flags & heartRateValueFormat) != 0); if (isHeartRateValueSizeLong) { return BitConverter.ToUInt16(data, 1); } else { return data[1]; } } 

您使用的设备遵循心率蓝牙规范。 所以它发送的数据应该遵守这个标准。 如果您参考此文档 ,您将阅读您在问题中列出的0x2A37特性,但不应将其作为int接收。

特征给出的不同值列在我链接的文档中。 我认为你会感兴趣的是’RR-Interval’,它的分辨率为1/1024秒。

您需要从值中检索所需的字节。 请注意字节顺序。 正如文件所述:

上表中的字段按照LSO到MSO的顺序排列。 其中LSO =最不重要的八位位组和MSO =最重要的八位位组。

所以你正在寻找值的最后2个字节,因为RR-Interval是一个uint16。

Interesting Posts