-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Edimax BLE Dongle Fails After Teardown and Re-Instantiation #534
Conversation
This PR is good to go. Can you please just fix the linter/formatter errors before we can merge it? |
Done! |
There are still some type checker errors (see the output of the GitHub actions that run on the PR, or run
Those errors can be fixed easily: |
This patch addresses an issue where the some RTK BLE dongles fail to perform an HCI reset after the transport is torn down and re-instantiated. To address that, we prevent crashing the background threads when invalid data comes in, and time out if no response is received within a fixed amount of time. When the timeout occurs, we retry the reset, and ultimately skip over reading the local version information if that fails.
I'm not sure how to work around this one:
It seems like MyPy doesn't like how the constructors for the events are done, as it can't tell the class instance has an attribute called |
The comment |
8fee379
to
b7259ab
Compare
Bug: Edimax BLE Dongle Fails After Teardown and Re-Instantiation
Overview
Replacement for #497 with the logic for the HCI parser removed now that packets are handled without a parser for USB. This bug was observed with some RTK BLE dongles (specifically cheaper CSR dongles as well as the Edimax BT-8500). Sometimes, when a reset is attempted, the host will fail to receive a result, instead receiving an invalid packet or corrupt data. This results in blocking forever in
driver_info_for_host()
. In testing, I found that allowing that to time out, then trying again can work with dongles like the Edimax.With cheaper CSR dongles, sometimes the first packet in response to a command after the reset will be an invalid packet. This occurs when the Local Version request is sent. The result is similar to the above in which case we wait forever on a packet that isn't coming in. In testing, I found that re-sending the command can sometimes avoid this, but not in all cases, so in the case that we do not get the local version information, we should skip over it and return upstream.
Summary of Changes
driver_info_for_host
attempt a HCI reset with a timeout; on time out, retry the HCI reset and assume the host is ready.driver_info_for_host
exit if the Local Version Information response is invalid.bumble/host.py
, forsend_command()
allow an optionalresponse_timeout
to allow the caller to time out if a response is not received.bumble/host.py
, foron_packet()
, do not crash iffrom_bytes()
fails to parse an HCI packet as may be the case with invalid data.