btsocket is a Python library providing a high-level interface to the BlueZ Bluetooth Management API. It enables programmatic control over Bluetooth adapters and operations on Linux systems. The current version is `0.3.0`, with a release cadence that focuses on adding new BlueZ management commands and improving internal socket handling, typically with a few releases per year.
pip install btsocketVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `BTSocket` object, connect to the BlueZ Management API, and then disconnect. It handles common `PermissionError` and `FileNotFoundError` exceptions that might occur if BlueZ is not properly set up or permissions are insufficient. Replace the `time.sleep(1)` with actual Bluetooth management commands for real-world usage.
Ensure you are running on a Linux system with BlueZ (bluez-libs, bluez-utils, or similar packages) installed and the 'bluetooth' service enabled and running.
Run your script with `sudo` or add your user to the `bluetooth` group (`sudo usermod -aG bluetooth $USER` and log out/in) to grant necessary permissions. Always prioritize the least restrictive permissions necessary.
Verify your Bluetooth adapter status using system tools (e.g., `bluetoothctl show`, `hciconfig`, `rfkill list`). Ensure it's not blocked and is powered on.
No dependency data recorded yet.