Enable Bluetooth after each reboot?

Hey Guys!

First off, a noob here and would like to thank you all for the useful posts, tweaks, tricks and all. Especially the devs.

Second, apologies if this comes across as spam/irrelevant, but I felt my experience with this issue may help in some way. The problem is resolved in my case (took approx 1.5 hrs of meddling).

I’ve been using OSMC on my RPi3 over a month now using a wired keyboard. Got my hands on an Apple Magic Keyboard yesterday and paired it with my RPi3. Since then, every reboot required me to connect my wired keyboard to the Pi to enable bluetooth and manually pair the Magic Keyboard. I’ve tried (in the same order):

  1. ssh-ing into the Pi to enable bluetooth using connmanctl enable bluetooth, but it gave me “Error bluetooth: Method “SetProperty” with signature “sv” on interface “net.connman.Technology” doesn’t exist

  2. Tried sudo bluetoothctl, but the terminal becomes unresponsive and I’m forced to use “ctrl+c” to quit bluetoothctl.

  3. Tried running the update as suggested here through My OSMC->Updater, but it comes back with no updates available.

  4. Ran sudo apt-get update and sudo apt-get dist-upgrade. That didn’t help either.

  5. Tried @Kent_Martin’s technique. Now the bluetooth is enabled in My OSMC > Network, but does not connect to the paired Magic Keyboard automatically.

  6. Tried $ sudo bluetoothctl [bluetooth]# agent on [bluetooth]# default-agent [bluetooth]# scan on
    It found the keyboard
    [bluetooth]# pair xx:xx:xx:xx:xx:xx
    Gave an error and did not pair. Switched off and on the keyboard and tried again. Did not work. Rebooted the Pi and repeated the commands, it paired.
    [bluetooth]# trust xx:xx:xx:xx:xx:xx [bluetooth]# exit

And now it works. Each time OSMC starts, there’s a wait time of 3-7 seconds before the keyboard is responsive.

I tried this but it didn’t work after a power down and reboot. If I exit from OSMC and when things start back up it works but after powering down it doesn’t.

It works fine with Raspian but not OSMC.

Hello folks,

My father came over from the other side of the planet to visit, and, liked the look of my OSMC/Pi install, so I gave it to him and can’t test the following, but…

Side note: I’ve been so impressed by the quality and work that has been put into OSMC I have decided that, to replace the Pi I gave away, I will buy a Vero 2 so the OSMC folks can at least make a little money from me :). I’m quite curious to have a play. I will probably grab another Pi or 2 before too long anyway :blush:

…you could do the following to try to make it work on boot. This is now down the rabbit hole of hackiness, but if you’re desperate here goes.

As root, edit a file called /usr/sbin/start_bluetooth_hack, with the following content:

#!/bin/bash

bluetoothctl << EOF
agent on
default-agent
scan on
pair xx:xx:xx:xx:xx:xx
trust xx:xx:xx:xx:xx:xx
exit
EOF

Some notes about the above script. I stress, I can’t test this right now, so while I can’t see why it wouldn’t work it is possible that bluetoothctl needs commands to wait to complete before the next one is sent, and, doesn’t buffer properly, or something like that, in which case it won’t work, and you’d be getting even hackier using an expect script :slight_smile:

Then run the command

chmod 700 /usr/sbin/start_bluetooth_hack

Finally, put it in /etc/rc.local like before

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# I'm not sure if you'll want the next line or not
# (sleep 10 ; connmanctl enable bluetooth)
(sleep 10 ; /usr/sbin/start_bluetooth_hack) &

exit 0

Edit on 2016-10-14, added an & to the end of the line that says (sleep 10 ; /usr/sbin/start_bluetooth_hack)

1 Like

This worked like a charm for me thanks!

1 Like

Just so people know: I am watching this thread and I can see that some of you are affected by this. I will look in to this when I get a little time and update if I find a good solution.

I think things may have changed since June 2015, and the introduction of Pi 3 as the most prominent Bluetooth adapter for OSMC now, but the symptoms certainly seem the same. It may be a timing issue in bringing up the device or uploading firmware.

Cheers

Tried this multiple times and I can’t get it to work.
Somehow it breaks my Raspian setup and I need to fix it.
Strange.

Hi Jack,

Raspian is a completely different distribution to OSMC, so, without running up an instance of that, I have no idea if this should/should not work, or what an alternative implementation/solution would be.

This forum is OSMC specific, so, you’d likely have more luck asking on the Raspian forums.

Having the same issue with RPi3 build-in BT and OSMC Krypton Beta. Bluetooth disabled after reboot. I’ll try a few things but it is 1:1 the same as reported here in this thread.

@sam_nazarko Do you have any updates? The internal BT adapter on the RPI3 is still affected by this. Do you know of any hacks that we can use that won’t break future updates that you would push? Thanks!

FWIW, I have it working on boot now, I just had to call

sudo systemctl enable bluetooth.service

This shouldn’t be necessary at all if you enable Bluetooth via ConnMan / My OSMC

@sam_nazarko On both of my RPI3’s with the latest OSMC, image, I enable BT My OSMC and BT works fine…until a reboot, and then it becomes disabled. systemctl enable bluetooth.service is the first time it has stayed on in between reboots