gpt4 book ai didi

python-3.x - 通过 BLE 从 PolarH10 获取数据

转载 作者:行者123 更新时间:2023-12-02 03:23:47 25 4
gpt4 key购买 nike

我一直在尝试使用我的树莓派从我的 PolarH10 获取数据。我已经使用 bluez 通过命令行成功获取数据,但无法在 python 中重现该数据。我正在使用 pygatt(gatttool 绑定(bind))和 python3。

我一直在密切关注 bitbucket 上提供的示例并且能够检测我的设备并通过按名称过滤它的 MAC 地址。然而,我无法让任何一个“异步读取数据”示例正常工作。


#This doesnt work...
req = gattlib.GATTRequester(mymac)
response = gattlib.GATTResponse()

req.read_by_handle_async(0x15, response) # what does the 0x15 mean?
while not response.received():
time.sleep(0.1)

steps = response.received()[0]


...

#This doesn't work either
class NotifyYourName(gattlib.GATTResponse):
def on_response(self, data):
print("your data is: {}".format(data))

response = NotifyYourName()
req = gattlib.GATTRequester(mymac)
req.read_by_handle_async(0x15, response)

while True:
# here, do other interesting things
time.sleep(1)

我不知道也无法从“文档”中提取如何订阅/读取传感器 (PolarH10) 特征(心率)的通知。我收到的错误是调用 GATTRequester.connect(True)

运行时错误: channel 或属性未准备好

请告诉我如何在 Debian 上通过 Python 正确连接到 BLE 设备,以及如何以编程方式识别所提供的服务及其特征,以及如何使用 gattlib(pygatt) 或任何其他库在 python 中异步获取其通知。谢谢!

最佳答案

答案是:只需使用 bleak .

关于python-3.x - 通过 BLE 从 PolarH10 获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56669105/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com