我正在尝试订阅 GATT 特性。
我已经为我的 BLE 设备中的 GATT 特性设置了“指示”、“通知”和“读取”属性。
我能够连接到我的 BLE 设备并读取/写入其他特性。
但是,我无法针对此特定特征执行 device.subscribe() 函数。
当我使用
device.subscribe("845ce63c-d003-423c-8922-818676d34255", callback=handle_data)
我得到了错误
pygatt.backends.bgapi.exceptions.ExpectedResponseTimeout:等待 10.000000 秒后超时 []
在链接 https://github.com/peplin/pygatt/blob/master/pygatt/device.py中,订阅函数有参数“wait_for_response”
在我的代码中,如果我使用
device.subscribe("845ce63c-d003-423c-8922-818676d34255", callback=handle_data, wait_for_response=True)
它显示错误
TypeError: subscribe() 得到了一个意外的关键字参数“wait_for_response”
我如何消除这些错误并订阅特性?
编辑:
我将属性读取和写入以及通知和指示添加到特征
我可以使用以下代码读取和写入特征:-
import pygatt
adapter = pygatt.BGAPIBackend()
try:
adapter.start()
device = adapter.connect('xx:xx:xx:xx:xx:xx')
print("Connected")
#value = device.char_write_handle(55, bytearray([0x00,0x01]), wait_for_response=True)
value = device.char_read_handle(55)
print(value)
finally:
adapter.stop()
但是,只是我无法订阅它。
我真的被困在这里了。
任何帮助深表感谢!