Power on Bluetooth in Ubuntu Core when boot

Hi,

I want to “power on” the bluetooth interface when the Ubuntu Core boot up. I tried the https://wiki.archlinux.org/index.php/bluetooth “auto power-on after boot” tutorial but it not worked. What I have to do? The command “sudo hciconfig hci0 up” worked fine, but I want to do this automatically.

I am working with: - RaspberryPi 3 - Ubuntu Core 16 - USB Dongle Bluetooth CSR 4.0

1 Like

I think in Ubuntu Core this is done via systemd service units. Try this:

Create a script file in ~/bin/blueup.sh and put the following script in that file:

#!/bin/bash
#blueup
sudo hciconfig hci0 up

Create a Systemd service unit file in /etc/systemd/system/bluetooth-interface.service and put the following script into that file (replace <username.> with your username):

# bluetooth-interface.service
[Unit] 
Description= Powers on the bluetooth interface
Documentation= https://forum.snapcraft.io/t/power-on-bluetooth-in-ubuntu-core-when-boot/7751/2

[Service] 
Type= simple 
User= <username> 

ExecStart= /home/<username>/bin/blueup.sh

ExecStop= /bin/kill -2 $MAINPID 

[Install] 
WantedBy= multi-user.target

Enable a unit to be started on bootup and Start immediately:

sudo systemctl enable bluetooth-interface
1 Like

Also, I have a question for the more initiated.
How would I go about snapping this or similar systemd unit together with the relevant bash scripts? Do tools like hciconfig or bluez have to be included also?

Hi KristijanZic,

I tried your tutorial but it not worked :frowning: The bluetooth still down when I reboot the RaspberryPi.

Regards Davi

see https://bugs.launchpad.net/snappy/+bug/1674509

@koza … will we ever finish this bit ? (how about setting a deadline at the sprint in january )

Hi Oliver,

I saw the link but don’t have any solution for this…

Regards
Davi