I am trying to connect a thermal printer to a raspberry pi 4 running Raspbian GNU/Linux 12 (bookworm)
using the Bluez API.
So far I managed to pair with the printer, but now I am struggling to connect the raspi with it. Since the printer uses a Bluetooth’s Serial Port Profile, I managed to connect with it via CLI with rfcomm
, but I want to do it 100% programatically in a sort of wizard embedded in a django application.
I understood I first need to configure the profile, which I apparently did with:
import dbus
bus = dbus.SystemBus()
device_path = "/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx"
manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
"org.bluez.ProfileManager1")
manager.RegisterProfile(device_path, "00001101-0000-1000-8000-00805f9b34fb", {})
When I try to connect to the printer via connect()
I get the following error:
dbus.exceptions.DBusException: org.bluez.Error.NotAvailable: br-connection-profile-unavailable
I would really appretiate some help on that issue.