I'm trying to connect to a bluetooth device through a Python script using pybluez on a Khadas board (kind of like a Raspberry Pi, aarch64).
I have manually updated PyBluez to 5.65 as it contains a fix I need. Both bluetoothctl --version
and bluetoothd --version
return 5.65.
Upon launching my script, I get
> python main.py
...
File "/home/khadas/env/lib/python3.8/site-packages/bluetooth/bluez.py", line 271, in advertise_service
_bt.sdp_advertise_service (sock._sock, name, service_id, \
_bluetooth.error: (2, 'No such file or directory')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/khadas/copilot/copilot/process/process.py", line 126, in run
self._pre_run()
File "/home/khadas/copilot/copilot/task/bluetooth_connector_task.py", line 55, in _pre_run
bluetooth.advertise_service(
File "/home/khadas/env/lib/python3.8/site-packages/bluetooth/bluez.py", line 275, in advertise_service
raise BluetoothError (*e.args)
bluetooth.btcommon.BluetoothError: [Errno 2] No such file or directory
Following this, I have edited /etc/systemd/system/dbus-org.bluez.service
and /lib/systemd/system/bluetooth.service
to have
ExecStart=/usr/libexec/bluetooth/bluetoothd -C
I then restarted the daemon with
sudo systemctl daemon-reload & sudo systemctl restart bluetooth & sudo sdptool add SP
but my error persists.
Has any of you encountered this before?
Thank you for your time :)
Note: This thread indicates that, following sudo sdptool add SP
, a file at /var/run/sdp
should have been created; it is not.
Note: The bluetooth service is running, but there are errors, i.e.
(env) khadas@khadas > systemctl status bluetooth.service
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2022-08-11 13:23:09 UTC; 13min ago
Docs: man:bluetoothd(8)
Main PID: 14256 (bluetoothd)
Status: "Running"
Tasks: 1 (limit: 2932)
Memory: 676.0K
CGroup: /system.slice/bluetooth.service
└─14256 /usr/libexec/bluetooth/bluetoothd -C
Aug 11 13:23:09 khadas systemd[1]: Starting Bluetooth service...
Aug 11 13:23:09 khadas bluetoothd[14256]: Bluetooth daemon 5.65
Aug 11 13:23:09 khadas systemd[1]: Started Bluetooth service.
Aug 11 13:23:09 khadas bluetoothd[14256]: Starting SDP server
Aug 11 13:23:09 khadas bluetoothd[14256]: src/sdpd-server.c:init_server() binding UNIX socket: Read-only file system
Aug 11 13:23:09 khadas bluetoothd[14256]: src/sdpd-server.c:start_sdp_server() Server initialization failed
Aug 11 13:23:09 khadas bluetoothd[14256]: Bluetooth management interface 1.14 initialized
Aug 11 13:23:09 khadas bluetoothd[14256]: src/adapter.c:reset_adv_monitors_complete() Failed to reset Adv Monitors: Unknown Command (0x01)