Open userx14 opened 1 month ago
Since these errors are coming from Windows and there is no timeout paramter to pass to the Windows APIs, I'm not sure what we could do in Bleak to work around this.
Also note that Bleak currently only support just-works pairing. See #1100
Description
When trying to pair with a bluetooth device the timeout to accept the connection using the system dialog is extremely short (<2 seconds). When the dialog is not confirmed basically instantly I get various errors. This problem is not present on windows 10 or at least much less pronounced.
What I Did
Execute this script, the bluetooth pairing request notification appears after 2 seconds. When waiting for 2 seconds before accepting it,
unpair and disconnect
is printed and the errorCould not pair with device: 15
is raised. Sometimes the error code isCould not pair with device: 19
instead. According to the microsoft doc these correspond to15 = OperationAlreadyInProgress
,19 = Failed
.Here is the first error with enabled logging:
Here is the error which also occurs sometimes:
When accepting the dialog very quickly the script behaves as expected, but the timeout of <2 seconds is unreasonably short.
Is this error caused by improper usage of the library, or is this an issue with the backend on windows 11? I already tried adding a timeout value of 30 when creating the bleak.BleakClient, but that did not make any difference.