diff options
Diffstat (limited to 'source/n/bluez/config')
-rw-r--r-- | source/n/bluez/config/bluetooth.modprobe | 3 | ||||
-rw-r--r-- | source/n/bluez/config/bluetooth.sh | 7 | ||||
-rw-r--r-- | source/n/bluez/config/defaultconfig | 9 | ||||
-rw-r--r-- | source/n/bluez/config/rc.bluetooth | 67 | ||||
-rw-r--r-- | source/n/bluez/config/uart.conf | 6 |
5 files changed, 71 insertions, 21 deletions
diff --git a/source/n/bluez/config/bluetooth.modprobe b/source/n/bluez/config/bluetooth.modprobe deleted file mode 100644 index 3072d7885..000000000 --- a/source/n/bluez/config/bluetooth.modprobe +++ /dev/null @@ -1,3 +0,0 @@ -# use "reset=1" as default, since it should be safe for recent devices and -# solves all kind of problems. -options btusb reset=1 diff --git a/source/n/bluez/config/bluetooth.sh b/source/n/bluez/config/bluetooth.sh deleted file mode 100644 index 22034551c..000000000 --- a/source/n/bluez/config/bluetooth.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# Check whether /etc/rc.d/rc.bluetooth is executable before starting -# the bluetooth subsystem for hotplugged bluetooth devices -[ -x /etc/rc.d/rc.bluetooth ] && exec /usr/sbin/bluetoothd --udev -exit 0 - diff --git a/source/n/bluez/config/defaultconfig b/source/n/bluez/config/defaultconfig new file mode 100644 index 000000000..b4da786e1 --- /dev/null +++ b/source/n/bluez/config/defaultconfig @@ -0,0 +1,9 @@ +# /etc/default/bluetooth + +# A space delimied list of devices to start at boot time +ACTIVE_HCI_DEVICES_ON_BOOT="hci0" + +# A semicolon delimited list of SDP (Service Discovery Protocol) +# operations for bluetooth devices. See the sdptool for more details. +SDPTOOL_OPTIONS="" + diff --git a/source/n/bluez/config/rc.bluetooth b/source/n/bluez/config/rc.bluetooth index 296c45422..b56fcd101 100644 --- a/source/n/bluez/config/rc.bluetooth +++ b/source/n/bluez/config/rc.bluetooth @@ -1,28 +1,73 @@ #!/bin/sh -bluez_start() { - /usr/sbin/bluetoothd +# /etc/rc.d/rc.bluetooth (based on BLFS script) + +# Populated from /etc/default/bluetooth: +# ACTIVE_HCI_DEVICES_ON_BOOT and SDPTOOL_OPTIONS + +[ -r /etc/default/bluetooth ] && . /etc/default/bluetooth + +start_hci_dev() { + for dev in ${ACTIVE_HCI_DEVICES_ON_BOOT} ; do + hciconfig $dev up > /dev/null 2>&1 + done +} + +run_sdptool() { + # Declaring IFS local in this function, removes the need to save/restore it + local IFS option + test -x /usr/bin/sdptool || return 1 + IFS=";" + for option in ${SDPTOOL_OPTIONS}; do + IFS=" " + /usr/bin/sdptool $option > /dev/null 2>&1 + done +} + +start_uarts() { + [ -r /etc/bluetooth/uart.conf ] || return + grep -v '^[[:space:]]*(#|$)' /etc/bluetooth/uart.conf | while read i; do + /usr/bin/hciattach $i > /dev/null 2>&1 + done +} + +stop_uarts() { + killall /usr/bin/hciattach > /dev/null 2>&1 +} + +start() { + if [ -d /sys/class/bluetooth ]; then + # Start as background process and assume OK + echo -n "Starting Bluetooth services: bluetoothd " + /usr/sbin/bluetoothd & + echo -n "hciconfig " + start_hci_dev + echo -n "sdptool " + run_sdptool + echo "hciattach" + start_uarts + fi } -bluez_stop() { - udevadm trigger --subsystem-match=bluetooth --action=remove - pkill -TERM bluetoothd 1>/dev/null 2>/dev/null +stop() { + stop_uarts + killall /usr/sbin/bluetoothd > /dev/null 2>&1 } -case "$1" in +case "${1}" in start) - bluez_start + start ;; stop) - bluez_stop + stop ;; restart) - bluez_stop + stop sleep 1 - bluez_start + start ;; *) - printf "Usage: $N {start|stop|restart}\n" + echo "Usage: ${0} {start|stop|restart}" exit 1 ;; esac diff --git a/source/n/bluez/config/uart.conf b/source/n/bluez/config/uart.conf new file mode 100644 index 000000000..b2e276f4e --- /dev/null +++ b/source/n/bluez/config/uart.conf @@ -0,0 +1,6 @@ +# /etc/bluetooth/uart.conf + +# Attach serial devices via UART HCI to BlueZ stack +# Use one line per device +# See the hciattach man page for options + |