简体   繁体   English

如何确定应使用哪个 UUID 从 Polar H10 传感器请求数据?

[英]How do I find out which UUID I should use to request data from my Polar H10 sensor?

I want to connect to my Polar H10 and read its Heart Rate (PPI) values.我想连接到我的 Polar H10 并读取它的心率 (PPI) 值。 I am basically following this example Python code which reads Acceleration from the same device.我基本上遵循这个示例 Python 代码,它从同一设备读取加速。 I am however stuck in finding out which UUID I should use to request the Heart Rate data.然而,我一直在寻找我应该使用哪个 UUID 来请求心率数据。 The example uses a byte array of unknown origin (to me) to request the Acceleration data and I have no clue where I should retrieve the UUID for heart rate from.该示例使用未知来源的字节数组(对我而言)来请求加速度数据,我不知道应该从哪里检索心率的 UUID。 All I can find is this document, but it gives a, I believe hexidecimal, code which I cannot use.我所能找到的就是这个文档,但它给出了一个我认为无法使用的十六进制代码。 What do I do to get the right UUID?我该怎么做才能获得正确的 UUID? I'm new to this kind of sensor stuff so nothing seems obvious to me.我是这种传感器的新手,所以对我来说似乎没有什么显而易见的。

EDIT 1:编辑 1:

So these are the GATT characteristics on my device所以这些是我设备上的 GATT 特性所以这些是我设备上的 GATT 特性

This is the PMD measurement type I am trying to extract这是我要提取的 PMD 测量类型这是我要提取的 PMD 测量类型

And of that I want Byte0: Heart rate in bpm其中我想要 Byte0:以 bpm 为单位的心率其中我想要 Byte0:以 bpm 为单位的心率

What I am doing now (I'm not sure if you want all the code so I'm gonna post what seems relevant).我现在正在做什么(我不确定您是否需要所有代码,所以我将发布看似相关的内容)。 In Python:在 Python:

For setting the request for specific data (I think? this is what the example does with different data from the same sensor)用于设置对特定数据的请求(我想?这就是示例对来自同一传感器的不同数据所做的)

ECG_WRITE = bytearray([0x02, 0x00, 0x00, 0x01, 0x82, 0x00, 0x01, 0x01, 0x0E, 0x00])

What I've tried to change ECG data to heart rate data is:我试图将 ECG 数据更改为心率数据的是:

RR_UUID = "0000180D-0000-1000-8000-00805f9b34fb"

But I feel like it isn't working because it isn't a byte array.但我觉得它不起作用,因为它不是字节数组。

Then later on these lines are executed for actual data retrievement I think (again, I'm following a guide I'm not 100% sure what the code does)然后稍后在这些行上执行我认为的实际数据检索(同样,我正在遵循指南我不是 100% 确定代码的作用)

 
    att_read = await client.read_gatt_char(PMD_CONTROL)
    await client.write_gatt_char(PMD_CONTROL,  ECG_WRITE)

    ## ECG stream started
    await client.start_notify(PMD_DATA, data_conv)

And from there on the data_conv method converts the data into usable data, and in this same method I can just print out the data and see it.从那里开始,data_conv 方法将数据转换为可用数据,在同样的方法中,我可以打印出数据并查看它。 However, since I don't know what I should enter as byte array to request the heart rate data, I haven't been able to get any data out of it yet.但是,由于我不知道应该输入什么作为字节数组来请求心率数据,所以我还无法从中获取任何数据。 It also gives no errors/exceptions whatshowever so I am not sure what is going wrong.它也没有给出任何错误/异常,所以我不确定出了什么问题。 So I am working from a Windows computer using Python code, and the target machine is a Polar H10 heart sensor.所以我在 Windows 计算机上使用 Python 代码工作,目标机器是 Polar H10 心脏传感器。

The hex values in the "16-bit UUID Numbers Document" are the hex numbers missing from the base UUID of 0000xxxx-0000-1000-8000-00805F9B34FB “16 位 UUID 数字文档”中的十六进制值是0000xxxx-0000-1000-8000-00805F9B34FB的基本 UUID 中缺少的十六进制数字

These are the UUIDs to look for if they have followed the adopted characteristic.如果它们遵循采用的特性,则这些是要查找的 UUID。 If they have, then you can look in "GATT Specification Supplement" available at: https://www.bluetooth.com/specifications/specs/ to find the details of how to breakout the byte array.如果有,那么您可以查看位于以下网址的“GATT 规范补充”: https : //www.bluetooth.com/specifications/specs/以查找有关如何拆分字节数组的详细信息。

Using a generic Bluetooth Low Energy scanning and exploration tool (eg nRF Connect ) can be useful to understand what data is there on the device.使用通用的低功耗蓝牙扫描和探索工具(例如nRF Connect )有助于了解设备上的数据。

I've been trying to solve the same problem for some time now and finally got the hang of it.一段时间以来,我一直在尝试解决同样的问题,终于掌握了窍门。

The documentation is confusing as it leads one to think that the H10 sensor doesn't support HR and PPI readings.该文档令人困惑,因为它让人认为 H10 传感器不支持 HR 和 PPI 读数。 The reality, however, is that those measurements are of course supported by the sensor—just not through the PMD_DATA stream. The UUID for HR readings is:然而,现实情况是,这些测量当然由传感器支持——只是不通过PMD_DATA stream。HR 读数的 UUID 是:

HR_UUID = "00002A37-0000-1000-8000-00805F9B34FB"

So when you start a client.notify(HR_UUID) , you will get a 6 byte data stream, that follows the specifications given in the Polar Specification Document (see image below)因此,当您启动client.notify(HR_UUID)时,您将获得一个 6 字节数据 stream,它遵循 Polar 规范文档中给出的规范(见下图)

PPI 帧类型

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

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