automatically start bluetooth if conf defined

This commit is contained in:
Calin Crisan 2017-04-09 20:35:10 +03:00
parent c8fefeb445
commit 1ff84730d7
5 changed files with 31 additions and 2 deletions

View File

@ -0,0 +1 @@
/data/etc/bluetooth.conf

7
board/common/overlay/etc/init.d/S30dbus Normal file → Executable file
View File

@ -1,5 +1,12 @@
#!/bin/bash #!/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 test -n "$os_version" || source /etc/init.d/base
start() { start() {

17
board/common/overlay/etc/init.d/S37bluetooth Normal file → Executable file
View File

@ -1,5 +1,19 @@
#!/bin/bash #!/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 test -n "$os_version" || source /etc/init.d/base
hci=hci0 hci=hci0
@ -15,11 +29,12 @@ start() {
count=$(($count + 1)) count=$(($count + 1))
if [ $count -ge 10 ]; then if [ $count -ge 10 ]; then
msg_fail "no device" msg_fail "no device"
logger -t bluetooth -s "bluetooth device not available, rebooting"
reboot
return 1 return 1
fi fi
done done
hciconfig $hci up
/usr/libexec/bluetooth/bluetoothd &>/dev/null & /usr/libexec/bluetooth/bluetoothd &>/dev/null &
msg_done msg_done
} }

8
board/raspberrypi3/overlay/etc/init.d/S13btuart Normal file → Executable file
View File

@ -1,5 +1,11 @@
#!/bin/bash #!/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 test -n "$os_version" || source /etc/init.d/base
function start() { function start() {
@ -24,7 +30,7 @@ case "$1" in
stop) stop)
msg_begin "Detaching UART bluetooth modem" msg_begin "Detaching UART bluetooth modem"
killall hciattach killall hciattach &>/dev/null
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
;; ;;

0
board/raspberrypi3/overlay/usr/bin/hciattach Normal file → Executable file
View File