I’m making another attempt to write a Python script that can list the paired Bluetooth devices.
Add library dependencies for gatt bluetooth protocol.
sudo apt-get install libperl-dev libgtk2.0-dev libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-dev python-dev
Install the Python BlueZ libraries.
sudo apt-get install python-bluez
That allows the Python BlueZ library to install.
sudo pip install PyBluez sudo pip3 install PyBluez
Add the gattlib to support the gatt bluetooth protocol. Make sure all apps are closed as the `gattlib` setup scripts use a lot of memory and will not complete without sufficient RAM.
sudo pip install gattlib sudo pip3 install gattlib
The [test-device python script] is able to list paired Bluetooth devices.
python test/test-device list
The org.freedesktop.DBus.Properties has a block of data on the PLT_Legend Bluetooth headset.
dbus.Dictionary({dbus.String(u’Name’): dbus.String(u’PLT_Legend’, variant_level=1), dbus.String(u’Paired’): dbus.Boolean(True, variant_level=1), dbus.String(u’Modalias’): dbus.String(u’bluetooth:v0055p0113d005D’, variant_level=1), dbus.String(u’Adapter’): dbus.ObjectPath(‘/org/bluez/hci0′, variant_level=1), dbus.String(u’LegacyPairing’): dbus.Boolean(False, variant_level=1), dbus.String(u’Alias’): dbus.String(u’PLT_Legend’, variant_level=1), dbus.String(u’Connected’): dbus.Boolean(False, variant_level=1), dbus.String(u’UUIDs’): dbus.Array([dbus.String(u’00001108-0000-1000-8000-00805f9b34fb’), dbus.String(u’0000110b-0000-1000-8000-00805f9b34fb’), dbus.String(u’0000110c-0000-1000-8000-00805f9b34fb’), dbus.String(u’0000110e-0000-1000-8000-00805f9b34fb’), dbus.String(u’0000111e-0000-1000-8000-00805f9b34fb’), dbus.String(u’00001200-0000-1000-8000-00805f9b34fb’), dbus.String(u’82972387-294e-4d62-97b5-2668aa35f618′)], signature=dbus.Signature(‘s’), variant_level=1), dbus.String(u’Address’): dbus.String(u’48:C1:AC:E2:21:A7′, variant_level=1), dbus.String(u’Blocked’): dbus.Boolean(False, variant_level=1), dbus.String(u’Class’): dbus.UInt32(2360324L, variant_level=1), dbus.String(u’Trusted’): dbus.Boolean(True, variant_level=1), dbus.String(u’Icon’): dbus.String(u’audio-card’, variant_level=1)}, signature=dbus.Signature(‘sv’))
Resources:
[bluez]
[pybluez]
[Android Linux / Raspberry Pi Bluetooth communication]
[bluetooth commands]
List paired bluetooth devices.
pi@raspberrypi:~/ $ bluetoothctl [NEW] Controller B8:27:EB:05:8D:D8 raspberrypi [default] [NEW] Device 48:C1:AC:E2:21:A7 PLT_Legend
Get device info from `bluetoothctl` console.
[bluetooth]# info 48:C1:AC:E2:21:A7 Device 48:C1:AC:E2:21:A7 Name: PLT_Legend Alias: PLT_Legend Class: 0x240404 Icon: audio-card Paired: yes Trusted: yes Blocked: no Connected: no LegacyPairing: no UUID: Headset (00001108-0000-1000-8000-00805f9b34fb) UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb) UUID: Handsfree (0000111e-0000-1000-8000-00805f9b34fb) UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb) UUID: Vendor specific (82972387-294e-4d62-97b5-2668aa35f618) Modalias: bluetooth:v0055p0113d005D