Que bluetooth soit activé automatiquement au démarrage

Salut
Depuis que j’utilise une mini enceinte bluetooth ça ma obligé à creuser le fonctionnement.
j’ai épuré les outils pour ne garder que gnome-bluetooth

 apt list --installed | grep blue

bluetooth/testing,testing,unstable,unstable,now 5.50-1 all  [installé]
bluewho/stable,stable,testing,testing,unstable,unstable,now 0.1-2 all  [installé]
bluez/testing,unstable,now 5.50-1 amd64  [installé]
bluez-obexd/testing,unstable,now 5.50-1 amd64  [installé]
gir1.2-gnomebluetooth-1.0/testing,unstable,now 3.28.2-2 amd64  [installé, automatique]
gnome-bluetooth/testing,unstable,now 3.28.2-2 amd64  [installé]
libbluetooth3/testing,unstable,now 5.50-1 amd64  [installé]
libgnome-bluetooth13/testing,unstable,now 3.28.2-2 amd64  [installé]
pulseaudio-module-bluetooth/testing,unstable,now 12.2-2 amd64  [installé]
python-bluez/testing,unstable,now 0.22-2 amd64  [installé, automatique]

Mon soucis était l’activation erratique et pas moyen d’activer bluetooth par le menu gnome dans la barre d’état

Après recherche j’ai mis l’activation à 1 dans /etc/default/bluetooth

# Defaults for bluez

# start bluetooth on boot?
# compatibility note: if this variable is _not_ found bluetooth will start
BLUETOOTH_ENABLED=1

# This setting used to switch HID devices (e.g mouse/keyboad) to HCI mode, that
# is you will have bluetooth functionality from your dongle instead of only
# HID. This is accomplished for supported devices by udev in
# /lib/udev/rules.d/62-bluez-hid2hci.rules by invoking hid2hci with correct
# parameters.
# See /usr/share/doc/bluez/NEWS.Debian.gz for further information.

# Older daemons like pand dund and hidd can be found in bluez-compat package as
# they are deprecated and provided for backward compatibility only.

# Note that not every bluetooth dongle is capable of switching back to HID mode,
# see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=355497
HID2HCI_ENABLED=0
HID2HCI_UNDO=0
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-09-22 10:12:12 CEST; 11min ago
     Docs: man:bluetoothd(8)
 Main PID: 548 (bluetoothd)
   Status: "Running"
    Tasks: 1 (limit: 4317)
   Memory: 3.0M
   CGroup: /system.slice/bluetooth.service
           └─548 /usr/lib/bluetooth/bluetoothd

sept. 22 10:12:08 debian bluetoothd[548]: Bluetooth daemon 5.50
sept. 22 10:12:12 debian systemd[1]: Started Bluetooth service.
sept. 22 10:12:12 debian bluetoothd[548]: Starting SDP server
sept. 22 10:12:12 debian bluetoothd[548]: Version mismatch for sixaxis
sept. 22 10:12:12 debian bluetoothd[548]: Bluetooth management interface 1.14 initialized
sept. 22 10:12:13 debian bluetoothd[548]: Sap driver initialization failed.
sept. 22 10:12:13 debian bluetoothd[548]: sap-server: Operation not permitted (1)
sept. 22 10:12:47 debian bluetoothd[548]: Endpoint registered: sender=:1.38 path=/MediaEndpoint/A2DPSource
sept. 22 10:12:47 debian bluetoothd[548]: Endpoint registered: sender=:1.38 path=/MediaEndpoint/A2DPSink
sept. 22 10:15:56 debian bluetoothd[548]: /org/bluez/hci0/dev_F4_4E_FD_A7_12_0D/fd0: fd(32) ready
hciconfig
hci0:	Type: Primary  Bus: USB
	BD Address: CC:52:AF:67:BA:34  ACL MTU: 1021:8  SCO MTU: 64:1
	UP RUNNING PSCAN 
	RX bytes:1124 acl:0 sco:0 events:63 errors:0
	TX bytes:3653 acl:0 sco:0 commands:63 errors:0

Donc c’est nickel, lorsque j’allume mon enceinte bluetooth le son bascule automatiquement des haut-parleurs du PC vers l’enceinte bluetooth et le logo bluetooth apparait dans la barre d’état.

Il y a encore des fois où le démarrage ne se fait pas bien et gnome n’affiche pas le Bluetooth actif.
Il me semble que c’est la gestion par Network-Manager avec bluez qui ne se fait pas
Dans le cas ok j’ai ça:

systemctl status NetworkManager -n 100 -l
....
sept. 24 08:43:56 debian NetworkManager[560]: <info>  [1537771436.3869] Loaded device plugin: NMBluezManager (/usr/lib/x86_64-linux-gnu/NetworkManager/1.12.2/libnm-device-plugin-bluetooth.so)
.....
sept. 24 08:43:57 debian NetworkManager[560]: <info>  [1537771437.6637] bluez: use BlueZ version 5
.....
sept. 24 08:43:57 debian NetworkManager[560]: <info>  [1537771437.6750] bluez5: NAP: added interface CC:52:AF:67:BA:34
sept. 24 08:43:57 debian NetworkManager[560]: <info>  [1537771437.6818] bluez: BT device Guy@HTC one A9 (04:C2:3E:09:C9:E6) added (NAP)

je suis tombé dans le cas de faute suite à une extinction brutale par coupure de batterie.

Après branchement du cable d’alimentation et démarrage du PC, Bluetooth est bloqué.

Gnome l’affiche éteint et pas moyen de l’activer par l’interface graphique

par commande

hciconfig -a
hci0:	Type: Primary  Bus: USB
	BD Address: 00:00:00:00:00:00  ACL MTU: 0:0  SCO MTU: 0:0
	DOWN 
	RX bytes:34 acl:0 sco:0 events:3 errors:0
	TX bytes:12 acl:0 sco:0 commands:4 errors:0
	Features: 0xff 0xff 0x8f 0xfe 0x9b 0xff 0x79 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: 
	Link mode: SLAVE ACCEPT 

j’utilise

 hciconfig hci0 up
hciconfig hci0 pscan

et le retour s’améliore

root@debian:~# hciconfig -a
hci0:	Type: Primary  Bus: USB
	BD Address: CC:52:AF:67:BA:34  ACL MTU: 1021:8  SCO MTU: 64:1
	UP RUNNING PSCAN 
	RX bytes:840 acl:0 sco:0 events:31 errors:0
	TX bytes:364 acl:0 sco:0 commands:31 errors:0
	Features: 0xff 0xff 0x8f 0xfe 0x9b 0xff 0x79 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH HOLD SNIFF PARK 
	Link mode: SLAVE ACCEPT 
	Name: 'Broadcom Bluetooth Device'

Mais gnome ne voit toujours rien et bluetoothctl non plus

bluetoothctl
Agent registered
[bluetooth]# show
No default controller available
[bluetooth]# list
[bluetooth]# devices
No default controller available
[bluetooth]# quit

En désespoir de cause j’appuie sur la touche "Antenne Radio " du clavier

le wifi passe en mode avion: normal

j’appuis de nouveau sur la touche “Antenne Radio” du clavier, wifi se réactive et… bluetooth aussi :grinning:

root@debian:~# bluetoothctl
Agent registered
[bluetooth]# show
Controller CC:52:AF:67:BA:34 (public)
	Name: debian
	Alias: debian
	Class: 0x000c010c
	Powered: yes
	Discoverable: no
	Pairable: yes
	UUID: Headset AG                (00001112-0000-1000-8000-00805f9b34fb)
	UUID: Headset                   (00001108-0000-1000-8000-00805f9b34fb)
	UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
	UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
	Modalias: usb:v1D6Bp0246d0532
	Discovering: no
[CHG] Device F4:4E:FD:A7:12:0D Connected: yes

Donc dans certains cas, le hardware se bloque mais maintenant j’arrive à le remettre en fonctionnement :astonished: