bluetooth-auto-recovery is a Python library designed to detect and recover Bluetooth adapters that enter an unresponsive or 'stuck' state. It actively monitors Bluetooth management sockets and initiates recovery procedures, such as resetting the adapter, when issues are detected. The current version is 1.5.3, with minor releases focusing on bug fixes and dependency updates, typically every few months.
pip install bluetooth-auto-recoveryVerified import paths — ran on the pinned version, not inferred.
Initializes `BluetoothAutoRecovery` and starts monitoring Bluetooth adapters in an asynchronous context. The recovery process runs in the background, attempting to fix unresponsive adapters. This example includes a robust shutdown on `KeyboardInterrupt`.
Run your Python script with `sudo python your_script.py` or ensure the user running the script has appropriate permissions to access `/var/run/bluetooth/mgmt` and interact with `rfkill`.
Ensure `pip` is able to fetch and install git dependencies. If issues arise, consider creating a clean virtual environment or checking the GitHub repository for the exact `pybluez` fork used.
Always use `async with BluetoothAutoRecovery(...)` and ensure your application's entry point uses `asyncio.run(main_async_function())` to correctly manage the event loop.
If running in a container, verify the correct path to the Bluetooth management socket within the container and pass it to the `bluetooth_management_socket` parameter of `BluetoothAutoRecovery`.