From 1ff84730d7f5a9b6bd6e154751bdc2b5824fab7f Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sun, 9 Apr 2017 20:35:10 +0300 Subject: [PATCH] automatically start bluetooth if conf defined --- board/common/overlay/etc/bluetooth/main.conf | 1 + board/common/overlay/etc/init.d/S30dbus | 7 +++++++ board/common/overlay/etc/init.d/S37bluetooth | 17 ++++++++++++++++- .../raspberrypi3/overlay/etc/init.d/S13btuart | 8 +++++++- board/raspberrypi3/overlay/usr/bin/hciattach | Bin 5 files changed, 31 insertions(+), 2 deletions(-) create mode 120000 board/common/overlay/etc/bluetooth/main.conf mode change 100644 => 100755 board/common/overlay/etc/init.d/S30dbus mode change 100644 => 100755 board/common/overlay/etc/init.d/S37bluetooth mode change 100644 => 100755 board/raspberrypi3/overlay/etc/init.d/S13btuart mode change 100644 => 100755 board/raspberrypi3/overlay/usr/bin/hciattach diff --git a/board/common/overlay/etc/bluetooth/main.conf b/board/common/overlay/etc/bluetooth/main.conf new file mode 120000 index 0000000000..42da82ff6d --- /dev/null +++ b/board/common/overlay/etc/bluetooth/main.conf @@ -0,0 +1 @@ +/data/etc/bluetooth.conf \ No newline at end of file diff --git a/board/common/overlay/etc/init.d/S30dbus b/board/common/overlay/etc/init.d/S30dbus old mode 100644 new mode 100755 index a05e6c92b4..82e9519ba6 --- a/board/common/overlay/etc/init.d/S30dbus +++ b/board/common/overlay/etc/init.d/S30dbus @@ -1,5 +1,12 @@ #!/bin/bash +sys_btconf="/etc/bluetooth.conf" +boot_btconf="/boot/bluetooth.conf" +btconf="/data/etc/bluetooth.conf" + +# dbus is only used by bluez +test -f $btconf || test -f $boot_btconf || test -f $sys_btconf || exit 0 + test -n "$os_version" || source /etc/init.d/base start() { diff --git a/board/common/overlay/etc/init.d/S37bluetooth b/board/common/overlay/etc/init.d/S37bluetooth old mode 100644 new mode 100755 index 35fe4e8584..0266cc1a5f --- a/board/common/overlay/etc/init.d/S37bluetooth +++ b/board/common/overlay/etc/init.d/S37bluetooth @@ -1,5 +1,19 @@ #!/bin/bash +sys_conf="/etc/bluetooth.conf" +boot_conf="/boot/bluetooth.conf" +conf="/data/etc/bluetooth.conf" + +if ! [ -f $conf ]; then + if [ -f $boot_conf ]; then + cp $boot_conf $conf + elif [ -f $sys_conf ]; then + cp $sys_conf $conf + fi +fi + +test -f $conf || exit 0 + test -n "$os_version" || source /etc/init.d/base hci=hci0 @@ -15,11 +29,12 @@ start() { count=$(($count + 1)) if [ $count -ge 10 ]; then msg_fail "no device" + logger -t bluetooth -s "bluetooth device not available, rebooting" + reboot return 1 fi done - hciconfig $hci up /usr/libexec/bluetooth/bluetoothd &>/dev/null & msg_done } diff --git a/board/raspberrypi3/overlay/etc/init.d/S13btuart b/board/raspberrypi3/overlay/etc/init.d/S13btuart old mode 100644 new mode 100755 index c830defe54..6899065c82 --- a/board/raspberrypi3/overlay/etc/init.d/S13btuart +++ b/board/raspberrypi3/overlay/etc/init.d/S13btuart @@ -1,5 +1,11 @@ #!/bin/bash +sys_conf="/etc/bluetooth.conf" +boot_conf="/boot/bluetooth.conf" +conf="/data/etc/bluetooth.conf" + +test -f $conf || test -f $boot_conf || test -f $sys_conf || exit 0 + test -n "$os_version" || source /etc/init.d/base function start() { @@ -24,7 +30,7 @@ case "$1" in stop) msg_begin "Detaching UART bluetooth modem" - killall hciattach + killall hciattach &>/dev/null test $? == 0 && msg_done || msg_fail ;; diff --git a/board/raspberrypi3/overlay/usr/bin/hciattach b/board/raspberrypi3/overlay/usr/bin/hciattach old mode 100644 new mode 100755