我在蓝牙服务状态上遇到错误。

我需要指导来解决此错误。

    pi@raspberrypi:~ $ sudo service bluetooth status
* bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled)
   Active: active (running) since Sat 2016-01-09 19:12:47 UTC; 1min 12s ago
     Docs: man:bluetoothd(8)
 Main PID: 370 (bluetoothd)
   Status: "Running"
   CGroup: /system.slice/bluetooth.service
           `-370 /usr/lib/bluetooth/bluetoothd

Jan 09 19:12:46 raspberrypi bluetoothd[370]: Bluetooth daemon 5.23
Jan 09 19:12:47 raspberrypi bluetoothd[370]: Starting SDP server
Jan 09 19:12:47 raspberrypi systemd[1]: Started Bluetooth service.
Jan 09 19:12:47 raspberrypi bluetoothd[370]: Bluetooth management interface 1.9 initialized
Jan 09 19:12:47 raspberrypi bluetoothd[370]: Sap driver initialization failed.
Jan 09 19:12:47 raspberrypi bluetoothd[370]: sap-server: Operation not permitted (1)
pi@raspberrypi:~ $


评论

在这种情况下,SAP似乎是SIM卡访问协议,因此可能与连接到手机(可能是互联网数据)有关。鉴于所有其他消息都与蓝牙守护程序的成功启动有关,我不完全确定这是否是一个错误...?

SAP与sim卡访问相关,有关此bug的更多信息。launchpad.net/ ubuntu / + source / bluez / + bug / 1629632

#1 楼

SAP代表SIM Access Profile,因此必须禁用它:


打开/etc/systemd/system/bluetooth.target.wants/bluetooth.service


更改:

ExecStart=/usr/lib/bluetooth/bluetoothd




ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap



重新加载系统:
重新启动蓝牙:

$ sudo systemctl daemon-reload



获取蓝牙状态:

$ sudo service bluetooth restart


>

评论


如果您愿意坚持使用systemctl,它也可以使systemctl重新启动蓝牙和systemctl状态蓝牙。这些可能也需要sudo。

– XTL
16 Sep 26 '19:42



在大多数网络教程和解决方案中,为了安全起见,我们不会编写sudo。我认为Linux用户已经知道特权。但是,这没问题,坦克,我会加那些sudo的。

– pylover
16 Sep 26 '21:12



正常工作一次,然后我发现需要寻址的文件是(也)/lib/systemd/system/bluetooth.service

–fcm
17年8月12日在22:02

为什么默认情况下不禁用此功能?

–沙爹脚趾
19年7月6日在4:13

我不知道为什么Linux音频是如此复杂。

– pylover
19年7月6日在17:52

#2 楼

如果您不想覆盖系统bluetooth.service文件,则是使用.service.d覆盖的好地方:

sudo mkdir  /etc/systemd/system/bluetooth.service.d/


然后在此文件中放置:

/etc/systemd/system/bluetooth.service.d/01-disable-sap-plugin.conf

[Service]
ExecStart=
ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap


sudo systemctl daemon-reload
sudo systemctl restart bluetooth.service


注意:在SystemD ExecStart=覆盖文件中重复使用bluetooth.service.d非常重要!空分配的第一行“ ExecStart=”清除了ExecStart的值,因此我们可以稍后覆盖它而不是附加到它。这个S.O.答案给出了更多细节。多次指定某些SystemD设置(例如ExecStart)时,它们会作为附加列表。当您使用foo.service.d/*.conf文件时,您要覆盖的许多选项将应用于此用例。因此,请务必注意,可能需要额外的Foo=设置来覆盖值而不是附加到列表。

评论


我认为最好使用sudo systemctl edit bluetooth.service而不是直接摆弄systemd目录和文件。

– Ingo
19-6-25在14:47

主要是在systemd的控制下这样做更安全吗?

– Ingo
19年6月26日在17:22

@SebMa:好的!最简单的解释是,它清除了ExecStart =的值,因此我们可以稍后覆盖它而不是附加到它。多次指定某些SystemD设置时,它们会作为附加列表。这个S.O.答案给出更多细节

– TrinitronX
20-2-28在22:01

@trinitronx谢谢。您能否将此说明添加到您的答案中,这样其他人就不必遍历所有注释来了解为什么首先将参数设置为空白?

–SebMa
20-2-29在8:22



@SebMa:好主意!我已经在答案中添加了解释。

– TrinitronX
20 Mar 4 '20 at 22:53