【问题标题】:pygatt NotificationTimeout: Nonepygatt 通知超时:无
【发布时间】:2020-08-24 11:41:04
【问题描述】:

我尝试从基于 BLE 的传感器中读取特征数据。因此我使用 pygatt 模块

import pygatt

adapter = pygatt.GATTToolBackend()

try:
   adapter.start()
   device = adapter.connect("2B:01:56:6C:F4:E6")
   value= device.char_read("00007502-0000-1000-8000-00805f9b34fb")

finally:
   adapter.stop()

每次我尝试在我的 Linux 控制台(使用 Python 2.7.16)中运行它时都会出现错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/device.py", line 17, in wrapper
    return func(self, *args, **kwargs)
  File "/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/device.py", line 40, in char_read
    return self._backend.char_read(self, uuid, *args, **kwargs)
  File "/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 50, in wrapper
    return func(self, *args, **kwargs)
  File "/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 593, in char_read
    self.sendline('char-read-uuid %s' % uuid)
  File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
    self.gen.next()
  File "/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 191, in event
    self.wait(event, timeout)
  File "/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 157, in wait
    raise NotificationTimeout()
pygatt.exceptions.NotificationTimeout: None

我完全迷失了这个错误。你知道如何解决这个问题吗? 对此非常感谢任何帮助。提前谢谢...

【问题讨论】:

    标签: python python-2.7 gatttool


    【解决方案1】:

    因为我遇到了同样的问题,而且似乎没有人有这个问题......

    嗯,问题在于请求的 UUID 特征不存在/无效。确保您输入正确,或者在从 putty 或类似内容复制时没有剪掉某些部分(完全没有经验!当然!)

    如果您从互联网或类似设备粘贴特征 UUID,可能您的设备没有此 UUID。

    如果您写入 不可写(只读/仅订阅)的 UUID,这也可能发生(未经测试,但应该是有意义的)。

    如果您确定一切正常,并且您已使用专用嗅探器或只是手机上的 BLE 扫描仪对 UUID 进行了三次检查,则设备可能关闭连接的速度过快。

    疑难解答:

    您可以手动连接设备并使用以下命令发出命令:

    gatttool -I

    当你进入程序时,输入:

    connect aa:bb:cc:dd:ee:ff

    然后,在连接关闭之前:

    char-read-uuid xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

    并分析发生了什么。如果它在那里工作,它应该也可以在 python 中工作。

    【讨论】:

    • 天哪!这个问题来自昨天。世界真小!
    猜你喜欢
    • 1970-01-01
    • 2017-12-11
    • 2016-07-14
    • 2017-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多