nicokaiser / rpi-audio-receiver

Raspberry Pi Audio Receiver with Bluetooth A2DP, AirPlay 2, and Spotify Connect
MIT License
1.38k stars 148 forks source link

Bluetooth is off at reboot #59

Closed spoutn1k closed 4 years ago

spoutn1k commented 4 years ago

The board's bluetooth has to be manually powered on after every reboot. Using a raspberrypi 4, installed only bluetooth. The bthelper@hci0.service service fails at boot with the following status:

Aug 12 23:34:12 aut0 hciconfig[473]: Can't set scan mode on hci0: Network is down (100)
nicokaiser commented 4 years ago

Could you send the output of sudo journalctl -u bthelper@hci0.service? Maybe this is a timing issue (again), but I currently do not have a Raspberry Pi 4 to test this...

nicokaiser commented 4 years ago

Can you add one line (the one with Type=oneshot to /etc/systemd/system/bthelper@.service.d/override.conf, so it looks like this?

[Service]
Type=oneshot
ExecStartPost=/usr/bin/bluetoothctl discoverable on
ExecStartPost=/bin/hciconfig %I piscan
ExecStartPost=/bin/hciconfig %I sspmode 1

It seems like Raspbian's Bluetooth init scripts are a bit broken in this case...

spoutn1k commented 4 years ago

Sorry for the delay, I do not have access to the device anymore. I ended up removing the /etc/systemd/system/bthelper@.service.d/override.conf file, and adding Discoverable = true in the /etc/bluetooth/main.conf file. This worked for my purposes, and I am sure the scans and sspmode can be set the same way. Unfortunately those configuration files are horribly documented, so I am not sure what the option is.

spoutn1k commented 4 years ago

Looking at the sources, there is definitely a way to set this up entirely via the config files. Might provide a pull request but I have no way of testing my changes.

nicokaiser commented 4 years ago

I could not find anything about sspmode and discoverability in the BlueZ sources, neither did I find a way to reliably enable them other than calling hciconfig hci0 sspmode 1... But if you find a reliable solution, I'm very interested!

oli-magnin commented 4 years ago

I also had an Issue with Bluetooth on my Pi 4, after addingType=oneshot to /etc/systemd/system/bthelper@.service.d/override.conf it worked.