pygatt: Unable to execute device.subscribe()

↘锁芯ラ 提交于 2020-04-07 01:20:04

问题


I am trying to subscribe to a GATT characteristic.

I have set the "Indicate", "Notify" and "Read" attributes for the GATT characteristic in my BLE device.

I am able to connect to my BLE device and read/write to other characteristics.

However, i am unable to execute the device.subscribe() function for this particular characteristic.

When i use

device.subscribe("845ce63c-d003-423c-8922-818676d34255", callback=handle_data)

i get the error

pygatt.backends.bgapi.exceptions.ExpectedResponseTimeout: Timed out after 10.000000s waiting for []

In the link https://github.com/peplin/pygatt/blob/master/pygatt/device.py, the subscribe function has the parameter "wait_for_response"

In my code, if i use

device.subscribe("845ce63c-d003-423c-8922-818676d34255", callback=handle_data, wait_for_response=True)

it shows the error

TypeError: subscribe() got an unexpected keyword argument 'wait_for_response'

How do i eliminate these errors and subscribe to the characteristic?

EDIT:

I added the properties Read and Write to the characteristic along-with Notify and Indicate

I can read and Write to the characteristic using the following code:-

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()

However, it is just that i am unable to subscribe to it.

I am really stuck here.

Any help is much appreciated!

来源:https://stackoverflow.com/questions/60888220/pygatt-unable-to-execute-device-subscribe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!