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

前端 未结 2 426
执笔经年
执笔经年 2021-02-05 11:17

I\'m simply trying to run the RFCOMM server example at https://code.google.com/p/pybluez/source/browse/trunk/examples/simple/rfcomm-server.py

$ python2 rfcomm-se         


        
相关标签:
2条回答
  • 2021-02-05 11:32

    I had the same problem on Raspbian, and solved by:

    • Running bluetooth in compatibility mode,

      by modifying /etc/systemd/system/dbus-org.bluez.service,

      changing

      ExecStart=/usr/lib/bluetooth/bluetoothd

      into

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

    • Then adding the Serial Port Profile, executing: sudo sdptool add SP

    References:

    • https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=133263

    • https://github.com/karulis/pybluez/issues/161

    • https://raspberrypi.stackexchange.com/questions/41776/failed-to-connect-to-sdp-server-on-ffffff000000-no-such-file-or-directory

    0 讨论(0)
  • 2021-02-05 11:49

    I ran the same problem even after @GozzoMan's solution because /var/run/sdp file was not being generated at all after calling sudo sdptool add SP. The problem was the location of daemon service file was different on my system (Raspbian Buster on Raspberry Pi).

    If you experience the same;

    • Check the status of bluetooth daemon and look for the service file path (2nd line)
    sudo service bluetooth status
    
    # alternative: 
    # sudo systemctl status bluetooth
    

    In my case the service file was run at /lib/systemd/system/bluetooth.service, NOT FROM /etc/systemd/system/dbus-org.bluez.service.

    • Then modify the correct file (which was /lib/systemd/system/bluetooth.service in my case) to add -C to the ExecStart=/usr/lib/bluetooth/bluetoothd line as instructed in the previous answer.

    • Do not forget to reload daemons and restart bluetooth service before running sdptool:

    sudo systemctl daemon-reload
    sudo systemctl restart bluetooth
    
    sudo sdptool add SP
    

    Now /var/run/sdp should be generated.

    Note: If you experience permission errors, check the following answer: https://stackoverflow.com/a/42306883/4406572

    0 讨论(0)
提交回复
热议问题