rendered paste body#!/bin/sh
module_id() {
awk 'BEGIN { FS=": " } /Hardware/ { print $2 } ' </proc/cpuinfo
}
# Read the h2200 bluetooth radio version out of the asset data in flash.
h2200_radio_version() {
dd if=/dev/mtdblock1 bs=1 skip=126968 count=5 2>/dev/null | tr -d \\0
}
if [ -f /etc/sysconfig/bluetooth ]; then
. /etc/sysconfig/bluetooth
if [ $BLUETOOTH = "yes" ]; then
# Turn echo off; if the bluetooth chip emits characters on power up,
# they would be echoed back to the chip, confusing it. This should only
# be necessary to do once, as hciattach turns echo off too (but too
# late the first time, since the bluetooth chip is powered up when the
# port is opened, before hciattach gets a chance to turn echo off).
echo "Turning echo off on ${BLUETOOTH_PORT}"
stty -echo < $BLUETOOTH_PORT
fi
else
echo -n "Checking for built-in Bluetooth: "
case `module_id` in
"HP iPAQ H2200")
BLUETOOTH=yes
PORT=/dev/ttyS3
SPEED=921600
PROBE=no
RADIO_VER=`h2200_radio_version`
case $RADIO_VER in
"141") # Zeevo
PROTO=any
;;
"525") # CSR
PROTO=bcsp
;;
*)
echo "Unknown radio version '${RADIO_VER}'"
;;
esac
;;
"HP iPAQ H5400")
BLUETOOTH=yes
PORT=/dev/ttyS3
SPEED=921600
PROTO=any
PROBE=yes
;;
"HP iPAQ H3900")
BLUETOOTH=yes
PORT=/dev/ttyS1
SPEED=921600
PROTO=bcsp
PROBE=yes
;;
"HP iPAQ H3800")
BLUETOOTH=yes
PORT=/dev/ttySB0
SPEED=230400
PROTO=bcsp
PROBE=yes
;;
"HP iPAQ H4100" | "HP iPAQ H4300")
BLUETOOTH=yes
PORT=/dev/ttyS1
SPEED=115200
PROTO=texas
PROBE=no
;;
"HP iPAQ HX4700")
BLUETOOTH=yes
PORT=/dev/ttyS1
SCRIPT=/etc/bluetooth/TIInit_3.2.26.bts
SPEED='`[ -f "$BLUETOOTH_SCRIPT" ] && echo 921600 || echo 115200`'
PROTO=texas
PROBE=no
;;
"HP iPAQ H6300")
BLUETOOTH=yes
PORT=/dev/ttyS0
SPEED=115200
PROTO=texas
PROBE=no
;;
"IPAQ-H1940")
BLUETOOTH=yes
PORT=/dev/s3c2410_serial0
SPEED=460800
PROTO=any
PROBE=no
;;
"Acer-N30")
BLUETOOTH=yes
PORT=/dev/s3c2410_serial2
SPEED=115200
PROTO=bcsp
PROBE=no
;;
"HTC Universal")
BLUETOOTH=yes
PORT=/dev/ttyS1
SCRIPT=/etc/bluetooth/TIInit_3.2.26.bts
SPEED='`[ -f "$BLUETOOTH_SCRIPT" ] && echo 921600 || echo 115200`'
PROTO=texas
PROBE=no
;;
"HTC Blueangel")
BLUETOOTH=yes
PORT=/dev/ttyS3
SCRIPT=/etc/bluetooth/TIInit_3.2.26.bts
SPEED='`[ -f "$BLUETOOTH_SCRIPT" ] && echo 921600 || echo 115200`'
PROTO=texas
PROBE=no
;;
*)
BLUETOOTH=no
;;
esac
if [ $BLUETOOTH = "yes" ]; then
stty -echo < $PORT
if [ $PROBE = "yes" ]; then
if ! blueprobe $PORT $SPEED; then
BLUETOOTH=no
fi
fi
fi
echo $BLUETOOTH
echo "BLUETOOTH=$BLUETOOTH" >/etc/sysconfig/bluetooth
if [ $BLUETOOTH = "yes" ]; then
echo "BLUETOOTH_PORT=$PORT" >>/etc/sysconfig/bluetooth
if [ "$SCRIPT" != "" ]; then
echo "BLUETOOTH_SCRIPT=$SCRIPT" >>/etc/sysconfig/bluetooth
fi
echo "BLUETOOTH_SPEED=$SPEED" >>/etc/sysconfig/bluetooth
echo "BLUETOOTH_PROTOCOL=$PROTO" >>/etc/sysconfig/bluetooth
fi
fi
. ./etc/sysconfig/bluetooth
# Check if irda is present.
[ $BLUETOOTH = "no" ] && exit 0
[ -f /usr/sbin/hciattach ] || exit 0
case "$1" in
start)
echo -n "Starting Bluetooth: "
hciattach -S $BLUETOOTH_SCRIPT $BLUETOOTH_PORT $BLUETOOTH_PROTOCOL $BLUETOOTH_SPEED
echo "$NAME."
;;
stop)
echo -n "Stopping Bluetooth: "
killall hciattach > /dev/null 2>&1
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting Bluetooth: "
killall hciattach > /dev/null 2>&1
sleep 1
hciattach -S $BLUETOOTH_SCRIPT $BLUETOOTH_PORT $BLUETOOTH_PROTOCOL $BLUETOOTH_SPEED
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac