Bluetooth Classic
Bluetooth Classic (BR/EDR) discovery, pairing, scans and RFCOMM serial connections on Linux.
Python has good libraries for Bluetooth Low Energy, such as Bleak, but none of them handle Bluetooth Classic devices: speakers, headphones, printers and serial adapters. This library fills that gap. It talks to BlueZ over D-Bus with dbus-fast, in your own asyncio event loop, without compiled extensions.
- Discover nearby Classic devices, with their names, services and signal strength.
- Pair with a built-in agent for devices without a screen or keyboard, and trust them.
- Find a device: whether a device is on and discoverable, with a short Classic scan that never connects to it, so it does not wake a device that wakes when connected to.
- Unpair a device, removing it from BlueZ.
Method names follow bleak's where there is an equivalent.
- Connect to a device's RFCOMM service, such as its serial port, with a
client shaped like bleak's
BleakClient. aio-rfcomm makes the connection (through BlueZ's profile API); this library is the one aio-rfcomm owner in the process, shared by every caller, and bytes to send on connect go out from a thread of its own the moment the channel opens.
It covers what a Classic device needs that the usual Python Bluetooth libraries do not, and nothing about any one kind of device.
Installation
Install this via pip (or your favourite package manager):
pip install bluetooth-classic
It needs Linux with BlueZ 5, and Python 3.11 or newer.
Usage
import asyncio
from bluetooth_classic import SERIAL_PORT, BluetoothClassic, RfcommClient
async def main() -> None:
async with BluetoothClassic() as bluetooth:
for device in await bluetooth.discover(timeout=10):
print(device.address, device.name, device.rssi)
device = await bluetooth.pair("00:11:22:33:44:55")
await bluetooth.trust(device.address)
found = await bluetooth.find_device_by_address(device.address)
print("on" if found else "off")
# The device's Serial Port service, connected by BlueZ; used like
# bleak's BleakClient.
async with RfcommClient(
"00:11:22:33:44:55", service=SERIAL_PORT, data_callback=print
) as client:
await client.write(b"hello")
asyncio.run(main())
A Classic scan uses the same radio as Low Energy scanning and interrupts it while it runs. Keep scans short, and in an application that also scans for Low Energy devices, let one part of it decide when they run.
Contributing
See CONTRIBUTING.md.
Credits
The project layout and tooling follow the Bluetooth-Devices libraries, which were created with browniebroke/cookiecutter-pypackage.
Metadata
Release files for bluetooth-classic 0.8.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bluetooth_classic-0.8.2.tar.gz | 24.9 kB | With provenance | Details for bluetooth_classic-0.8.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bluetooth_classic-0.8.2-py3-none-any.whl | Python 3 | none | any | Details for bluetooth_classic-0.8.2-py3-none-any.whl |
Total release size: 50.9 kB
Release files / bluetooth_classic-0.8.2.tar.gz
| Download URL | bluetooth_classic-0.8.2.tar.gz |
|---|---|
| Size | 24.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae8122ee3298a19d5ece19eb0fdb58310973ea16d42f9e26c22f6ffc3cb8ab96
|
|
BLAKE2b-256 checksum How to use checksums |
7674badd1f2bfd192976ef260dfaf39754fe83add62e92eba1dcb04f6d826a36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / bluetooth_classic-0.8.2-py3-none-any.whl
| Download URL | bluetooth_classic-0.8.2-py3-none-any.whl |
|---|---|
| Size | 26.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c9787f30ec39ed5d217afad04d1343f04a69507808845c12a153075f40d3ff3
|
|
BLAKE2b-256 checksum How to use checksums |
b097fe119939837bccea9b04a587a1dc9aa8aaf3d52656c71d69d4395bb2261f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logSecurity for bluetooth-classic 0.8.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for bluetooth_classic-0.8.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.