D-Bus 设置失败:名称已被使用

bri*_*esh 6 bluetooth

如何解决标题中提到的问题?

尝试执行以下命令(使用 bluez-5.37 和 Ubuntu 14.04):

brij@brij:~/Downloads/bluez-5.37/src$ sudo ./bluetoothd --plugin=time -n
bluetoothd[29255]: Bluetooth daemon 5.37
D-Bus setup failed: Name already in use
bluetoothd[29255]: Unable to get on D-Bus
Run Code Online (Sandbox Code Playgroud)

use*_*.dz 5

好吧,该消息意味着另一个/正在运行的守护程序正在使用相同的总线名称。

  • 检查使用:

    $ ps aux | grep blue
    sneetsh+  2226  0.0  0.0 333592  5432 ?        Ssl  08:00   0:00 /usr/lib/x86_64-linux-gnu/indicator-bluetooth/indicator-bluetooth-service
    sneetsh+  2318  0.0  0.6 605972 48636 ?        Sl   08:00   0:00 /usr/bin/python /usr/bin/blueman-applet
    sneetsh+  2765  0.0  0.0  31484  3348 ?        S    08:00   0:00 /usr/lib/bluetooth/obexd
    root      5327  0.0  0.0  29864  4504 ?        Ss   09:03   0:00 /usr/lib/bluetooth/bluetoothd
    sneetsh+  5361  0.0  0.0   9592  2192 pts/2    S+   09:04   0:00 grep --color=auto blue
    
    Run Code Online (Sandbox Code Playgroud)

    或系统监视器(图形用户界面)。

  • 另一种选择,d-feet它是 DBus 浏览器。在左下角,您可以看到所有者进程。

    d-feet 获取 DBUS 所有者 PID 和命令

然后sudo kill它或sudo service ... stop它,如果它的服务。对于默认的 Ubuntu 设置,它有一个服务,所以运行:

rfkill block bluetooth
sudo service bluetooth stop
Run Code Online (Sandbox Code Playgroud)

运行您的本地守护程序,然后再次启用蓝牙

rfkill unblock bluetooth
Run Code Online (Sandbox Code Playgroud)

在不切换蓝牙的情况下,蓝牙服务将再次重新生成。