rfcomm bluetooth permission denied error raspberry pi

前端 未结 2 1539
滥情空心
滥情空心 2021-02-02 02:15

I\'m using a bluetooth dongle to try and send information from ubuntu 15.04 to raspberry pi b+ running the latest debian jessie image. I\'m just following the http://people.csai

2条回答
  •  盖世英雄少女心
    2021-02-02 03:05

    Running your script as root kinda works, but it's not a good practice.

    According to this thread, you just need to adjust permissions to the /var/run/sdp file (which is created when using the --compat switch).

    So, to prevent link rot I'm reproducing dlech's post and adapting it to Raspberry Pi:

    1. make sure your pi user is in the bluetooth group:

      $ cat /etc/group | grep bluetooth
      bluetooth:x:113:pi
      

      1.1. If it's not, add pi to bluetooth group:

      $ sudo usermod -G bluetooth -a pi
      
    2. Change group of the /var/run/sdp file:

      $ sudo chgrp bluetooth /var/run/sdp
      
    3. To make the change persistent after reboot:

      3.1. Create file /etc/systemd/system/var-run-sdp.path with the following content:

      [Unit]
      Descrption=Monitor /var/run/sdp
      
      [Install]
      WantedBy=bluetooth.service
      
      [Path]
      PathExists=/var/run/sdp
      Unit=var-run-sdp.service
      

      3.2. And another file, /etc/systemd/system/var-run-sdp.service:

      [Unit]
      Description=Set permission of /var/run/sdp
      
      [Install]
      RequiredBy=var-run-sdp.path
      
      [Service]
      Type=simple
      ExecStart=/bin/chgrp bluetooth /var/run/sdp
      

      3.3. Finally, start it all up:

      sudo systemctl daemon-reload
      sudo systemctl enable var-run-sdp.path
      sudo systemctl enable var-run-sdp.service
      sudo systemctl start var-run-sdp.path
      

    Credit goes to user dlech who "figured it out" originally.

提交回复
热议问题