蓝牙服务无法正常重启:需要分两步完成

蓝牙服务无法正常重启:需要分两步完成

蓝牙服务无法正确重启:

$ sudo service bluetooth restart;service bluetooth status
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since jeu. 2020-02-27 11:18:05 CET; 398ms ago
     Docs: man:bluetoothd(8)
 Main PID: 18310 (bluetoothd)
   Status: "Running"
   CGroup: /system.slice/bluetooth.service
           └─18310 /usr/lib/bluetooth/bluetoothd

févr. 27 11:18:05 sebastien-B206 bluetoothd[18310]: gatt-time-server: Input/output error (5)
févr. 27 11:18:05 sebastien-B206 bluetoothd[18310]: Not enough free handles to register service
févr. 27 11:18:05 sebastien-B206 bluetoothd[18310]: Not enough free handles to register service
févr. 27 11:18:05 sebastien-B206 bluetoothd[18310]: Sap driver initialization failed.
févr. 27 11:18:05 sebastien-B206 bluetoothd[18310]: sap-server: Operation not permitted (1)
févr. 27 11:18:05 sebastien-B206 bluetoothd[18310]: Endpoint registered: sender=:1.55 path=/MediaEndpoint/A2DPSource
févr. 27 11:18:05 sebastien-B206 bluetoothd[18310]: Endpoint registered: sender=:1.55 path=/MediaEndpoint/A2DPSink
févr. 27 11:18:05 sebastien-B206 bluetoothd[18310]: Endpoint registered: sender=:1.43 path=/MediaEndpoint/A2DPSource
févr. 27 11:18:05 sebastien-B206 bluetoothd[18310]: Endpoint registered: sender=:1.43 path=/MediaEndpoint/A2DPSink
févr. 27 11:18:05 sebastien-B206 bluetoothd[18310]: RFCOMM server failed for Headset Voice gateway: rfcomm_bind: Address already in use (98)

它需要分两步完成(参见最后一行status):

$ sudo service bluetooth stop;sudo service bluetooth start;service bluetooth status
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since jeu. 2020-02-27 11:20:12 CET; 2s ago
     Docs: man:bluetoothd(8)
 Main PID: 18390 (bluetoothd)
   Status: "Running"
   CGroup: /system.slice/bluetooth.service
           └─18390 /usr/lib/bluetooth/bluetoothd

févr. 27 11:20:12 sebastien-B206 bluetoothd[18390]: Not enough free handles to register service
févr. 27 11:20:12 sebastien-B206 bluetoothd[18390]: Not enough free handles to register service
févr. 27 11:20:12 sebastien-B206 bluetoothd[18390]: Sap driver initialization failed.
févr. 27 11:20:12 sebastien-B206 bluetoothd[18390]: sap-server: Operation not permitted (1)
févr. 27 11:20:12 sebastien-B206 bluetoothd[18390]: Endpoint registered: sender=:1.55 path=/MediaEndpoint/A2DPSource
févr. 27 11:20:12 sebastien-B206 bluetoothd[18390]: Endpoint registered: sender=:1.55 path=/MediaEndpoint/A2DPSink
févr. 27 11:20:12 sebastien-B206 bluetoothd[18390]: Endpoint registered: sender=:1.43 path=/MediaEndpoint/A2DPSource
févr. 27 11:20:12 sebastien-B206 bluetoothd[18390]: Endpoint registered: sender=:1.43 path=/MediaEndpoint/A2DPSink
févr. 27 11:20:12 sebastien-B206 bluetoothd[18390]: RFCOMM server failed for Headset Voice gateway: rfcomm_bind: Address already in use (98)
févr. 27 11:20:15 sebastien-B206 systemd[1]: Started Bluetooth service.

我尝试RestartSec=5在( )[Service]部分添加参数,但没有效果:/lib/systemd/system/bluetooth.serviceman systemd.service

$ sudo systemctl edit --full bluetooth
$ systemctl cat bluetooth | grep RestartSec
RestartSec=5
$ sudo systemctl daemon-reload
$ sudo service bluetooth restart;service bluetooth status
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since jeu. 2020-02-27 11:30:28 CET; 524ms ago
     Docs: man:bluetoothd(8)
 Main PID: 18830 (bluetoothd)
   Status: "Running"
   CGroup: /system.slice/bluetooth.service
           └─18830 /usr/lib/bluetooth/bluetoothd

févr. 27 11:30:28 sebastien-B206 bluetoothd[18830]: gatt-time-server: Input/output error (5)
févr. 27 11:30:28 sebastien-B206 bluetoothd[18830]: Not enough free handles to register service
févr. 27 11:30:28 sebastien-B206 bluetoothd[18830]: Not enough free handles to register service
févr. 27 11:30:28 sebastien-B206 bluetoothd[18830]: Sap driver initialization failed.
févr. 27 11:30:28 sebastien-B206 bluetoothd[18830]: sap-server: Operation not permitted (1)
févr. 27 11:30:28 sebastien-B206 bluetoothd[18830]: Endpoint registered: sender=:1.55 path=/MediaEndpoint/A2DPSource
févr. 27 11:30:28 sebastien-B206 bluetoothd[18830]: Endpoint registered: sender=:1.55 path=/MediaEndpoint/A2DPSink
févr. 27 11:30:28 sebastien-B206 bluetoothd[18830]: Endpoint registered: sender=:1.43 path=/MediaEndpoint/A2DPSource
févr. 27 11:30:28 sebastien-B206 bluetoothd[18830]: Endpoint registered: sender=:1.43 path=/MediaEndpoint/A2DPSink
févr. 27 11:30:28 sebastien-B206 bluetoothd[18830]: RFCOMM server failed for Headset Voice gateway: rfcomm_bind: Address already in use (98)

这是我的bluetooth.service配置:

$ systemctl cat bluetooth
# /lib/systemd/system/bluetooth.service
[Unit]
Description=Bluetooth service
Documentation=man:bluetoothd(8)
ConditionPathIsDirectory=/sys/class/bluetooth

[Service]
Type=dbus
BusName=org.bluez
ExecStart=/usr/lib/bluetooth/bluetoothd
NotifyAccess=main
#WatchdogSec=10
#Restart=on-failure
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
LimitNPROC=1
RestartSec=5

[Install]
WantedBy=bluetooth.target,suspend.target
Alias=dbus-org.bluez.service

EDIT0:刚刚重新启动:

$ sudo systemctl restart bluetooth
$ systemctl status -n 20 bluetooth
● bluetooth.service - Bluetooth service
   Loaded: loaded (/etc/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since jeu. 2020-02-27 17:23:24 CET; 2min 42s ago
     Docs: man:bluetoothd(8)
 Main PID: 5050 (bluetoothd)
   Status: "Running"
   CGroup: /system.slice/bluetooth.service
           └─5050 /usr/lib/bluetooth/bluetoothd

févr. 27 17:23:24 sebastien-B206 systemd[1]: Started Bluetooth service.
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Starting SDP server
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Bluetooth management interface 1.10 initialized
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Failed to obtain handles for "Service Changed" characteristic
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Not enough free handles to register service
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Error adding Link Loss service
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Not enough free handles to register service
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Not enough free handles to register service
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Not enough free handles to register service
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Current Time Service could not be registered
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: gatt-time-server: Input/output error (5)
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Not enough free handles to register service
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Not enough free handles to register service
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Sap driver initialization failed.
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: sap-server: Operation not permitted (1)
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Endpoint registered: sender=:1.65 path=/MediaEndpoint/A2DPSource
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Endpoint registered: sender=:1.65 path=/MediaEndpoint/A2DPSink
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Endpoint registered: sender=:1.42 path=/MediaEndpoint/A2DPSource
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: Endpoint registered: sender=:1.42 path=/MediaEndpoint/A2DPSink
févr. 27 17:23:25 sebastien-B206 bluetoothd[5050]: RFCOMM server failed for Headset Voice gateway: rfcomm_bind: Address already in use (98)

EDIT1:rfkill list输出:

$ rfkill list
0: hci0: Bluetooth
    Soft blocked: no
    Hard blocked: no
1: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no

EDIT2:已尝试但它并没有解决RFCOMM server failed for Headset Voice gateway: rfcomm_bind: Address already in use (98)pb问题。

结论:我从命令行添加了该--noplugin=sap选项ExecStart=@6666 提出的解决方案它解决了我的重启 pb。仍然有其他错误,但每次蓝牙服务重启后蓝牙都能正常工作,所以谁在乎它们呢 :-)

答案1

关注第一个重大错误Sap 驱动程序初始化失败因为它会级联到您突出显示的最后一个错误:

RFCOMM server failed for Headset Voice gateway: rfcomm_bind: Address already in use (98)

从上而下开始调试。通常最后出现的错误都会自行解决。一般参考:这里是一些音频的蓝牙配置文件示例。

相关内容