bluetooth headsets can't connect when my laptop suspend and resume

Asked by knyterant on 2018-05-13

ubuntu 18.04 bionic, keep it with newest updates.
thinpad x200 with bluetooth 4.0 module,
"Bus 004 Device 003: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 [ThinkPad]"

my bluetooth headsets worked very well before. but recent days happened this:

my bluetooth headsets can not connect to my laptop when it suspend and resume. whether connect it automatically or manually, it will connect in a very short while and disconnect immediately, then fail.

only two ways can connect it:
1. reboot the OS can connect it successfully.
2. or remove the headsets from the bluetooth control pannel and pair it again, this can connect it successfully.

my bluetooth headsets works well with my smartphones, like my ios devices

how to fix it?

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
2018-05-17
Last reply:
2018-05-17

What is the output of:

lsmod

Thanks

knyterant (feidegg) said : #2

here is the output of 'lsmod':

~$ lsmod
Module Size Used by
rfcomm 77824 16
ccm 20480 6
snd_hrtimer 16384 1
pci_stub 16384 1
vboxpci 24576 0
vboxnetadp 28672 0
vboxnetflt 28672 0
vboxdrv 471040 3 vboxnetadp,vboxnetflt,vboxpci
cmac 16384 1
bnep 20480 2
binfmt_misc 20480 1
xfs 1200128 1
libcrc32c 16384 1 xfs
btusb 45056 0
btrtl 16384 1 btusb
btbcm 16384 1 btusb
btintel 16384 1 btusb
snd_hda_codec_conexant 24576 1
bluetooth 548864 43 btrtl,btintel,bnep,btbcm,rfcomm,btusb
snd_hda_codec_generic 73728 1 snd_hda_codec_conexant
cdc_acm 32768 0
coretemp 16384 0
kvm_intel 204800 0
uvcvideo 86016 0
videobuf2_vmalloc 16384 1 uvcvideo
videobuf2_memops 16384 1 videobuf2_vmalloc
videobuf2_v4l2 24576 1 uvcvideo
videobuf2_core 40960 2 uvcvideo,videobuf2_v4l2
videodev 184320 3 uvcvideo,videobuf2_core,videobuf2_v4l2
media 40960 2 uvcvideo,videodev
snd_hda_intel 40960 6
kvm 593920 1 kvm_intel
ecdh_generic 24576 2 bluetooth
snd_hda_codec 126976 3 snd_hda_intel,snd_hda_codec_conexant,snd_hda_codec_generic
irqbypass 16384 1 kvm
snd_seq_midi 16384 0
arc4 16384 2
snd_seq_midi_event 16384 1 snd_seq_midi
snd_hda_core 81920 4 snd_hda_intel,snd_hda_codec_conexant,snd_hda_codec,snd_hda_codec_generic
input_leds 16384 0
thinkpad_acpi 94208 0
serio_raw 16384 0
nvram 16384 1 thinkpad_acpi
iwldvm 229376 0
wmi_bmof 16384 0
mac80211 778240 1 iwldvm
lpc_ich 24576 0
iwlwifi 278528 1 iwldvm
snd_rawmidi 32768 1 snd_seq_midi
snd_hwdep 20480 1 snd_hda_codec
snd_pcm 98304 3 snd_hda_intel,snd_hda_codec,snd_hda_core
cfg80211 622592 3 iwlwifi,mac80211,iwldvm
mei_me 40960 0
snd_seq 65536 3 snd_seq_midi_event,snd_seq_midi
mei 90112 1 mei_me
snd_seq_device 16384 3 snd_seq,snd_rawmidi,snd_seq_midi
snd_timer 32768 3 snd_seq,snd_hrtimer,snd_pcm
shpchp 36864 0
snd 81920 24 snd_hda_intel,snd_hwdep,snd_hda_codec_conexant,snd_seq,snd_hda_codec,snd_timer,thinkpad_acpi,snd_rawmidi,snd_hda_codec_generic,snd_seq_device,snd_pcm
mac_hid 16384 0
soundcore 16384 1 snd
sch_fq_codel 20480 6
cuse 16384 3
tp_smapi 28672 0
thinkpad_ec 16384 1 tp_smapi
parport_pc 36864 0
ppdev 20480 0
lp 20480 0
parport 49152 3 lp,parport_pc,ppdev
ip_tables 28672 0
x_tables 40960 1 ip_tables
autofs4 40960 2
i915 1617920 69
i2c_algo_bit 16384 1 i915
drm_kms_helper 167936 1 i915
syscopyarea 16384 1 drm_kms_helper
sysfillrect 16384 1 drm_kms_helper
sysimgblt 16384 1 drm_kms_helper
psmouse 147456 0
ahci 36864 3
libahci 32768 1 ahci
fb_sys_fops 16384 1 drm_kms_helper
e1000e 249856 0
drm 401408 18 i915,drm_kms_helper
ptp 20480 1 e1000e
pps_core 20480 1 ptp
wmi 24576 1 wmi_bmof
video 40960 2 thinkpad_acpi,i915

Cause the problem then run:

sudo modprobe -r btrtl btintel bnep btbcm rfcomm btusb bluetooth

sleep 5

sudo modprobe btrtl btintel bnep btbcm rfcomm btusb bluetooth

Does it then work OK?

knyterant (feidegg) said : #4

it still does't work... after run the commands:

~$ sudo modprobe -r btrtl btintel bnep btbcm rfcomm btusb bluetooth
modprobe: FATAL: Module btrtl is in use.
~$ sleep 5
~$ sudo modprobe btrtl btintel bnep btbcm rfcomm btusb bluetooth
~$

knyterant (feidegg) said : #5

i found it will recover to work after run this command:

~$ sudo bluetooth restart

what cause this problem, and how to fix it automatically?

thanks!

That's basically what I was trying to find. You found the magic bullet.

OK, run:

sudo gedit /usr/bin/wakeupfix

Add the 2 lines to the file:

#!/bin/bash
sudo bluetooth restart

Save the file, close gedit and run:

sudo chmod +x /usr/bin/wakeupfix

You can now add your script to the system so when it wakes up it gets called

https://askubuntu.com/questions/226278/run-script-on-wakeup

https://mariogalan.com/en/content/execute-script-after-suspend-ubuntu-1604

Once it's added and working you can add more than to the same file if you like. The commands run as root so you'll need to use su/sudo to run stuff as other users as you expect

knyterant (feidegg) said : #9

ahaļ¼ a mistake in my command, it should be like this:

~$ sudo service bluetooth restart

this will fix the bug manually.

but there's another problem, i added the command and script to the system to hope it can work when it wakes up. but the bluetooth is still not OK. it seems that the script was not executed . i checked my script is executable. refer to the web link you gave. put the script either in the /lib/systemd/system-sleep/ or /usr/lib/pm-utils/sleep.d , it dosen't work. this is one of the way i have tried:

#!/bin/sh
# restart the bluetooth service
case "$1" in
        post)
          /usr/sbin/service bluetooth restart
                ;;
esac

it won't work.

is there something wrong in my codes? thank u!

Did you read what I wrote? Make the script file.....

knyterant (feidegg) said : #11

yes, i have read your advice. i also tried like this:

add 2 lines into /usr/bin/wakeupfix:

#!/bin/bash
sudo service bluetooth restart

save it, and chmod +x this file to root user.

then, make a file here, /lib/systemd/system-sleep/bt-wakeup-script.sh, add these lines and chmod +x it:

#!/bin/sh
# restart the bluetooth service
case "$1" in
        post)
          /usr/bin/wakeupfix
                ;;
esac

it also dosen't work...T_T

If you search for guides on how to run a command at wake up in Ubuntu then you will find what you need. You have the fix, it just needs automating

Can you help with this problem?

Provide an answer of your own, or ask knyterant for more information if necessary.

To post a message you must log in.