-2

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.

Use bleak's example file: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. (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

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.

ESP32 restarted several times, pyCharm wrote again several times, but they all reported the same error. 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

Captured Bluetooth packets:https://github.com/hbldh/bleak/files/8348459/ERROR.txt

How to resolve the sudden error:Could not get GATT services: Unreachable?

esqew
  • 42,425
  • 27
  • 92
  • 132
C.SH.K
  • 51
  • 7
  • what is the actual question please ? – D.L Mar 26 '22 at 10:52
  • How can I solve the problem of using bleak to report sudden errors? @D.L – C.SH.K Mar 26 '22 at 11:31
  • this appears to be the same (unresolved) error on github here: https://github.com/hbldh/bleak/issues/740 . Have you tried an alternative module or method ? – D.L Mar 26 '22 at 14:18
  • "*This question is closed.*" Can you elaborate as to why you've edited this text into your question? Your question is still clearly open for answers. If you've solved the problem that gave rise to this question, don't include the solution in the Question section - instead, post a self-answer below and accept it. – esqew Mar 27 '22 at 03:04
  • @esqew I'm sorry inigoselwood thought it was necessary to edit the question. I misunderstood. – C.SH.K Mar 27 '22 at 03:17

1 Answers1

1

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. Therefore, the services of Bluetooth cannot be obtained.

C.SH.K
  • 51
  • 7
  • Please edit your original question instead of answering it – Inigo Selwood Mar 26 '22 at 20:31
  • 2
    @InigoSelwood Why are you giving this guidance? [It's very much incorrect in the guidelines of Stack Exchange.](https://meta.stackoverflow.com/questions/267434/what-is-the-appropriate-action-when-the-answer-to-a-question-is-added-to-the-que) Straight from the linked thread: "*answers should not go into questions*". Please don't advise on matters of etiquette when you aren't fully informed. – esqew Mar 27 '22 at 03:06
  • @esqew the post has been edited since I posted my comment, before which it looked like a revision of the question -- not an answer. Please don't give well-meaning advice when you aren't fully informed – Inigo Selwood Mar 28 '22 at 12:54