Power on Bluetooth in Ubuntu Core when boot


#1

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


#3

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

#4

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?


#5

Hi KristijanZic,

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

Regards
Davi


#6

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 )


#7

Hi Oliver,

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

Regards
Davi