Open marianacalzon opened 2 years ago
OSError: [WinError -2147418113] Catastrophic failure
Unfortunately, this means the error comes from the OS and there probably isn't a way to fix it in Bleak.
There is #640 that would allow implementing the pairing in Python instead of using the OS dialog, but it needs some more work.
Logging Bluetooth packets might also offer more insight in to what Windows is actually doing.
@marianacalzon can you perhaps try again using test pairing branch
pip install --force-reinstall git+https://github.com/bojanpotocnik/bleak@pairing_no_service_discovery
and using
client = BleakClient(address, skip_service_discovery=True)
as described here https://github.com/bojanpotocnik/bleak/blob/cfd09baddfbd27538e9a1cdd2ef3c7b8f2af229c/examples/pairing_agent.py#L82-L88 (from https://github.com/hbldh/bleak/pull/1133)? Based on my tests, this should solve your issue.
Description
Trying to pair and connect to the device, after accepting to pair on the OS pop-up, Bleak fails. The device I am trying to connect to requires pairing. If I accept pairing as soon as it pops up, the script fails. If I wait until after services discovery has finished, and only then accept the pairing, it will work OK.
What I Did
With this code:
Use case 1: fails Accepting the pairing before it finished discovering services - fails
The traceback of the error:
Use case 2: succeeds Waiting to accept pairing, then succeeds
Alternative use of the API:
With the script modified to call pair() before connect():
The execution fails as follows:
The traceback of the error: