如何强制蓝牙管理器在暂停后重新启动?

如何强制蓝牙管理器在暂停后重新启动?

我正在运行 20.04.3 LTS。当我启动我的机器时,蓝牙管理器按预期启动,我可以连接到蓝牙设备。在我的电源设置中,我启用了“可以关闭蓝牙以节省电量”。

如果我让计算机处于挂起状态,蓝牙管理器就会消失,我无法重新启动它,也无法再连接任何蓝牙设备。我怎样才能强制它重新启动而不必重新启动我的计算机?(或者首先防止出现问题?)

正常状态

在出现任何问题之前,的输出/etc/init.d/bluetooth status如下:

● bluetooth.service - Bluetooth service
     Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-02-15 11:20:46 GMT; 1h 18min ago
       Docs: man:bluetoothd(8)
   Main PID: 1857 (bluetoothd)
     Status: "Running"
      Tasks: 1 (limit: 18495)
     Memory: 2.2M
     CGroup: /system.slice/bluetooth.service
             └─1857 /usr/lib/bluetooth/bluetoothd

Feb 15 11:20:46 lenovo bluetoothd[1857]: audio-avrcp-target: Protocol not supported (93)
Feb 15 11:20:47 lenovo bluetoothd[1857]: Endpoint registered: sender=:1.42 path=/MediaEndpoint/A2DPSink/sbc
Feb 15 11:20:47 lenovo bluetoothd[1857]: Endpoint registered: sender=:1.42 path=/MediaEndpoint/A2DPSource/sbc
Feb 15 11:20:50 lenovo bluetoothd[1857]: L2CAP server failed for Message Notification: setsockopt(L2CAP_OPTIONS): Invalid argument (22)
Feb 15 11:20:50 lenovo bluetoothd[1857]: L2CAP server failed for Message Access: setsockopt(L2CAP_OPTIONS): Invalid argument (22)
Feb 15 11:20:50 lenovo bluetoothd[1857]: L2CAP server failed for Phone Book Access: setsockopt(L2CAP_OPTIONS): Invalid argument (22)
Feb 15 11:20:50 lenovo bluetoothd[1857]: L2CAP server failed for File Transfer: setsockopt(L2CAP_OPTIONS): Invalid argument (22)
Feb 15 11:20:50 lenovo bluetoothd[1857]: L2CAP server failed for Object Push: setsockopt(L2CAP_OPTIONS): Invalid argument (22)
Feb 15 11:21:22 lenovo bluetoothd[1857]: avrcp-controller profile connect failed for 00:08:8A:FF:53:3D: Input/output error
Feb 15 11:21:22 lenovo bluetoothd[1857]: /org/bluez/hci0/dev_00_08_8A_FF_53_3D/sep1/fd0: fd(38) ready

正常状态Ⅱ

$ systemctl list-unit-files | grep blue
blueman-mechanism.service                      disabled        enabled      
bluetooth.service                              enabled         enabled      
dbus-org.bluez.service                         enabled         enabled      
bluetooth.target                               static          enabled

我尝试过

重启服务

从睡眠状态恢复后蓝牙不工作,Ubuntu 18.04 LTS

modprobe -r btusb
sleep 1
service bluetooth restart
sleep 1
modprobe btusb

结果:没有变化。

检查设备状态

仍处于活跃和运行状态 (!?)

$ /etc/init.d/bluetooth status
● bluetooth.service - Bluetooth service
     Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-02-17 09:30:24 GMT; 7h ago
       Docs: man:bluetoothd(8)
   Main PID: 1859 (bluetoothd)
     Status: "Running"
      Tasks: 1 (limit: 18495)
     Memory: 2.9M
     CGroup: /system.slice/bluetooth.service
             └─1859 /usr/lib/bluetooth/bluetoothd

Feb 17 14:12:48 lenovo bluetoothd[1859]: Unable to get io data for Headset Voice gateway: getpeername: Transport endpoint is not connected (107)
Feb 17 14:13:33 lenovo bluetoothd[1859]: avrcp-controller profile connect failed for 00:08:8A:FF:53:3D: Input/output error
Feb 17 14:13:33 lenovo bluetoothd[1859]: /org/bluez/hci0/dev_00_08_8A_FF_53_3D/sep1/fd2: fd(37) ready
Feb 17 15:46:05 lenovo bluetoothd[1859]: No reply to Start request
Feb 17 15:46:05 lenovo bluetoothd[1859]: Unable to get io data for Headset Voice gateway: getpeername: Transport endpoint is not connected (107)
Feb 17 15:46:05 lenovo bluetoothd[1859]: avrcp-controller profile connect failed for 00:08:8A:FF:53:3D: Input/output error
Feb 17 15:46:05 lenovo bluetoothd[1859]: /org/bluez/hci0/dev_00_08_8A_FF_53_3D/sep1/fd3: fd(37) ready
Feb 17 16:16:46 lenovo bluetoothd[1859]: Unable to get io data for Headset Voice gateway: getpeername: Transport endpoint is not connected (107)
Feb 17 16:16:46 lenovo bluetoothd[1859]: Endpoint unregistered: sender=:1.41 path=/MediaEndpoint/A2DPSink/sbc
Feb 17 16:16:46 lenovo bluetoothd[1859]: Endpoint unregistered: sender=:1.41 path=/MediaEndpoint/A2DPSource/sbc

检查设备状态二

$ lsusb; dmesg | egrep -i 'blue|firm'
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 04ca:7070 Lite-On Technology Corp. Integrated Camera
Bus 003 Device 004: ID 27c6:55a4 Shenzhen Goodix Technology Co.,Ltd. Goodix FingerPrint Device
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[    6.728422] i915 0000:00:02.0: [drm] Finished loading DMC firmware i915/icl_dmc_ver1_09.bin (v1.9)
[  131.924258] iwlwifi 0000:00:14.3: loaded firmware version 63.c04f3485.0 Qu-c0-hr-b0-63.ucode op_mode iwlmvm
[  132.022131] Bluetooth: Core ver 2.22
[  132.022154] Bluetooth: HCI device and connection manager initialized
[  132.022159] Bluetooth: HCI socket layer initialized
[  132.022162] Bluetooth: L2CAP socket layer initialized
[  132.022166] Bluetooth: SCO socket layer initialized
[  132.147943] Bluetooth: hci0: Bootloader revision 0.4 build 0 week 11 2017
[  132.148943] Bluetooth: hci0: Device revision is 2
[  132.148945] Bluetooth: hci0: Secure boot is enabled
[  132.148946] Bluetooth: hci0: OTP lock is enabled
[  132.148947] Bluetooth: hci0: API lock is enabled
[  132.148947] Bluetooth: hci0: Debug lock is disabled
[  132.148947] Bluetooth: hci0: Minimum firmware build 1 week 10 2014
[  132.152089] Bluetooth: hci0: Found device firmware: intel/ibt-19-32-4.sfi
[  133.715425] Bluetooth: hci0: Waiting for firmware download to complete
[  133.715942] Bluetooth: hci0: Firmware loaded in 1527196 usecs
[  133.716026] Bluetooth: hci0: Waiting for device to boot
[  133.731078] Bluetooth: hci0: Device booted in 14720 usecs
[  133.731693] Bluetooth: hci0: Found Intel DDC parameters: intel/ibt-19-32-4.ddc
[  133.734061] Bluetooth: hci0: Applying Intel DDC parameters completed
[  133.736995] Bluetooth: hci0: Firmware revision 0.0 build 121 week 36 2020
[  133.796965] Bluetooth: hci0: MSFT filter_enable is already on
[  135.656768] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[  135.656771] Bluetooth: BNEP filters: protocol multicast
[  135.656778] Bluetooth: BNEP socket layer initialized
[  136.784480] Bluetooth: RFCOMM TTY layer initialized
[  136.784487] Bluetooth: RFCOMM socket layer initialized
[  136.784491] Bluetooth: RFCOMM ver 1.11
[  151.284331] audit: type=1107 audit(1645090240.283:147): pid=1864 uid=103 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" mask="send" name="org.bluez" pid=3385 label="snap.bitwarden.bitwarden" peer_pid=1859 peer_label="unconfined"
[ 1612.134048] audit: type=1107 audit(1645091700.798:179): pid=1864 uid=103 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" mask="send" name="org.bluez" pid=15716 label="snap.bitwarden.bitwarden" peer_pid=1859 peer_label="unconfined"

检查设备状态三

$ systemctl list-unit-files | grep blue
blueman-mechanism.service                      enabled         enabled      
bluetooth.service                              enabled         enabled      
dbus-org.bluez.service                         enabled         enabled      
bluetooth.target                               static          enabled

https://stackoverflow.com/a/68335639/236081

可能表示多个冲突的服务正在抑制蓝牙。(仍在调查。请注意,blueman-mechanism.service正常状态下处于禁用状态。)

从命令行启动 blueman-manager

$ blueman-manager
blueman-manager version 2.1.2 starting  
blueman-manager 12.42.28 ERROR    Manager:118 on_dbus_name_appeared: Default adapter not found, trying first available.  
blueman-manager 12.42.28 ERROR    Manager:122 on_dbus_name_appeared: No adapter(s) found, exiting

结果:启动失败。未找到适配器。

关闭并重新打开

  • 在电源设置中,我尝试关闭“蓝牙可以关闭”设置,然后重新打开。

  • 按下键盘上的“飞行模式”按钮,将其关闭然后重新打开。

结果:在每种情况下,蓝牙管理器指示器都会弹出然后消失。

相关内容