Is there any way to discover nearby Bluetooth devices using Python on macOS running on the newer Apple Silicon?
I tried Pybluez
, but lightblue
, one of its dependencies, doesn't seem to be supported.
Is there any way to discover nearby Bluetooth devices using Python on macOS running on the newer Apple Silicon?
I tried Pybluez
, but lightblue
, one of its dependencies, doesn't seem to be supported.
You can use bleak, it works for me on M1 macOS Ventura
Just make sure you have the necessary permissions to access Bluetooth from your terminal app (iTerm, for example), I spent really annoying 15 minutes on this error. go to "System Preferences" > "Privacy & Security" > "Bluetooth" and enable access for your terminal application.
Install bleak using pip:
pip install bleak
Here's a short example that demonstrates how to discover nearby Bluetooth devices:
import asyncio
from bleak import BleakScanner
async def discover_devices():
devices = await BleakScanner.discover()
for device in devices:
print(f"Device: {device.name}, Address: {device.address}")
asyncio.run(discover_devices())
Learn more at Bleak official documentation. Happy Bluetoothing!