0

I had an issue like this on my Nano:

profiles = [ SERIAL_PORT_PROFILE ],
  File "/usr/lib/python2.7/site-packages/bluetooth/bluez.py", line 176, in advertise_service
    raise BluetoothError (str (e))
bluetooth.btcommon.BluetoothError: (2, 'No such file or directory')

I tried adding compatibility mode in the bluetooth.service file, reloading daemon, restarting bluetooth and then adding a serial port by doing

sudo sdptool add SP

These steps work fine on my ubuntu 20.04 laptop, but on jetpack 4.5.1, they don’t. And I checked also, they don’t work on jetson NX either.

I am really curious on how to solve this issue, otherwise, another way to use bluetooth inside a python code is welcomed.

Thanks

ucefM
  • 21
  • 2

2 Answers2

0

You might want to have a look at the following article which shows how to do the connection with core Python Socket library https://blog.kevindoran.co/bluetooth-programming-with-python-3/.

The way BlueZ does this now is with the Profile API.

There is a Python example of using the Profile API at https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/test-profile

hciattach, hciconfig, hcitool, hcidump, rfcomm, sdptool, ciptool, and gatttool were deprecated by the BlueZ project in 2017. If you are following a tutorial that uses them, there is a chance that it might be out of date and that Linux systems will choose not to support them.

ukBaz
  • 6,985
  • 2
  • 8
  • 31
  • Hi ukBaz, thanks for the answer. However, can you please share an example of how to use this to communicate with an external device? – ucefM Feb 03 '22 at 18:33
  • I'm assuming that `bluetoothctl` works on the command line? If so, what of the Python3 example is not working for you? What errors are you getting? What does your code look like? Do you want to update the question with more information? – ukBaz Feb 03 '22 at 20:26
  • Okey, found the solution, see my answer – ucefM Feb 04 '22 at 22:53
-1

The solution was in the path of the bluetooth configuration file (inspired from this https://developer.nvidia.com/embedded/learn/tutorials/connecting-bluetooth-audio)

this answer : bluetooth.btcommon.BluetoothError: (2, 'No such file or directory')

is not enough for jetson devices (jetpack). Although I didn't test if it works without changing the file mentioned in this link.

There is a .conf file that needs to be changed also : /lib/systemd/system/bluetooth.service.d/nv-bluetooth-service.conf

modify :

ExecStart=/usr/lib/bluetooth/bluetoothd -d --noplugin=audio,a2dp,avrcp

to :

ExecStart=/usr/lib/bluetooth/bluetoothd -C

after that it is necessary to do:

sudo systemctl daemon-reload
sudo systemctl restart bluetooth

Tested on jetson Nano and NX with jetpach 4.5.1

Thanks for the help !

ucefM
  • 21
  • 2