简体   繁体   English

Python的蓝牙库Bleak报“bleak.exc.BleakError: Could not get GATT services: Unreachable”,如何解决?

[英]Python's Bluetooth library of the Bleak report "bleak.exc.BleakError: Could not get GATT services: Unreachable" , how to solve it?

I'm a rookie, I've been doing nothing for a few days and have to turn to overflow for help (┬┬﹏┬┬)我是菜鸟,几天无所事事只好求助溢出(┬┬﹏┬┬)

Windows 10 downloads a python third-party library of the bleak package and conda's virtual environment tf-gpu-3.7 local install it. Windows 10 下载一个 python 惨淡的第三方库 package 和conda的虚拟环境tf-gpu-3.7 本地安装吧。

Use bleak's example file: https://github.com/hbldh/bleak/blob/develop/examples/get_services.py使用 bleak 的示例文件: https://github.com/hbldh/bleak/blob/develop/examples/get_services.py

The bluetooth service characteristic value can be obtained normally.可以正常获取蓝牙服务特征值。 I will be according to the document using read_gatt_descriptor and read_gatt_char, Pycharm is suddenly the error.我将根据文档使用read_gatt_descriptor和read_gatt_char,突然报错Pycharm。 (I didn't change the code for example file at this point) (此时我没有更改示例文件的代码)

ERROR:错误:

C:\ProgramData\Anaconda3\envs\tf-gpu-3.7\python.exe C:/Users/Administrator/PycharmProjects/pythonProject/main.py
Traceback (most recent call last):
  File "C:/Users/Administrator/PycharmProjects/pythonProject/main.py", line 27, in <module>
    asyncio.run(main(sys.argv[1] if len(sys.argv) == 2 else ADDRESS))
  File "C:\ProgramData\Anaconda3\envs\tf-gpu-3.7\lib\asyncio\runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "C:\ProgramData\Anaconda3\envs\tf-gpu-3.7\lib\asyncio\base_events.py", line 587, in run_until_complete
    return future.result()
  File "C:/Users/Administrator/PycharmProjects/pythonProject/main.py", line 19, in main
    async with BleakClient(address) as client:
  File "C:\ProgramData\Anaconda3\envs\tf-gpu-3.7\lib\site-packages\bleak-0.15.0a1-py3.7.egg\bleak\backends\client.py", line 61, in __aenter__
    await self.connect()
  File "C:\ProgramData\Anaconda3\envs\tf-gpu-3.7\lib\site-packages\bleak-0.15.0a1-py3.7.egg\bleak\backends\winrt\client.py", line 276, in connect
    await self.get_services()
  File "C:\ProgramData\Anaconda3\envs\tf-gpu-3.7\lib\site-packages\bleak-0.15.0a1-py3.7.egg\bleak\backends\winrt\client.py", line 456, in get_services
    "Could not get GATT services",
  File "C:\ProgramData\Anaconda3\envs\tf-gpu-3.7\lib\site-packages\bleak-0.15.0a1-py3.7.egg\bleak\backends\winrt\client.py", line 105, in _ensure_success
    raise BleakError(f"{fail_msg}: Unreachable")
bleak.exc.BleakError: Could not get GATT services: Unreachable

Picture: https://tupian.li/images/2022/03/26/image4e67fd58c248b7b3.png图片: https://tupian.li/images/2022/03/26/image4e67fd58c248b7b3.png

I don't know how to solve it.The error is too sudden.不知道怎么解决,报错太突然了。 It was fine a while ago, but now it doesn't work.前段时间还好,现在不行了。

I recreated the virtual environment and re-installed the bleak, and unfortunately the error was repeated.我重新创建了虚拟环境,重新安装了bleak,不幸的是错误又重复了。

ESP32 restarted several times, pyCharm wrote again several times, but they all reported the same error. ESP32重启了几次,pyCharm又写了几次,但都报同样的错误。 A few days ago, I asked the author for help, but I haven't replied yet...前几天向作者求助,至今没有回复。。。

ESP32 Code: https://github.com/hbldh/bleak/files/8348469/BLE.UART.txt ESP32代码: https://github.com/hbldh/bleak/files/8348469/BLE.UART.txt

Captured Bluetooth packets: https://github.com/hbldh/bleak/files/8348459/ERROR.txt抓取的蓝牙数据包: https://github.com/hbldh/bleak/files/8348459/ERROR.txt

How to resolve the sudden error: Could not get GATT services: Unreachable ?如何解决突发错误: Could not get GATT services: Unreachable

Sorry, it's not clear where I will describe what is wrong...抱歉,目前尚不清楚我将在哪里描述错误...

The problem is over.问题结束了。 I find the cause of the error:我找到了错误的原因:

ESP.restart();

I forgot to comment on the esp.restart function, causing ESP32 to keep rebooting.我忘记评论esp.restart function,导致ESP32一直重启。 Therefore, the services of Bluetooth cannot be obtained.因此无法获取蓝牙的服务。

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

相关问题 使用Python和bleak库通知一个蓝牙GATT设备,结果不稳定 - Use Python and bleak library to notify a bluetooth GATT device, but the result is not stable 使用 asyncio 在后台运行 bleak(python 库) - Run bleak (python library) in background with asyncio Bleak(python)在连接时没有响应 - Bleak (python) does not respond on connect Python:使用bleak模块时如何连接BLE设备 - Python: How to connect BLE device when i use bleak module Python Bleak 扫描广告并退出事件循环 - Python Bleak scan for advertisements and exit event loop 使用 Bleak 和 PyQtGraph 包实时绘制 BLE 数据 - Real time plotting of BLE data using Bleak and PyQtGraph packages 我无法在 windows 10 上安装黯淡模块 - I can't install the bleak module on windows 10 如何解决 Python 的“Pyzbar”库上的导入错误? - How to solve Import Error on Python's 'Pyzbar' library? 如何解决 python 上的 openCV 问题 - 未加载库:@rpath/libglib-2.0.0.dylib - How could I solve the openCV issues on python - library not loaded : @rpath/libglib-2.0.0.dylib 无法连接到BLE设备? 使用令人沮丧的:“ AttributeError:&#39;NoneType&#39;对象没有属性&#39;ConnectionStatusChanged&#39;” - Not connecting to BLE Device? Using bleak: “AttributeError: 'NoneType' object has no attribute 'ConnectionStatusChanged'”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM