pandora-scripts and pandora-configtray: Moved Bluetooth into Wifi-packages as well
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts-wifi / op_bluetooth_work.sh
1 #!/bin/sh
2
3 kernel_major=`uname -r | cut -c 1`
4 if [ "$kernel_major" = "2" ]; then
5         # new kernel only (for now)
6         exit 0
7 fi
8
9 if [ "$1" = "1" ]; then
10         if [ ! -e /sys/class/gpio/gpio15/value ]; then
11                 echo 15 > /sys/class/gpio/export
12                 sleep 0.2
13                 echo out > /sys/class/gpio/gpio15/direction
14         fi
15         echo 0 > /sys/devices/platform/omap_uart.0/sleep_timeout
16         echo 1 > /sys/class/gpio/gpio15/value
17         hciattach /dev/ttyO0 texasalt 3000000
18         INTERFACE="`hciconfig | grep "^hci" | cut -d ':' -f 1`"
19         if [ -z "$INTERFACE" ]; then
20                 killall hciattach
21                 echo 0 > /sys/class/gpio/gpio15/value
22                 exit 1
23         fi
24         if [ -e /sys/class/leds/ ] ; then
25                 for led in /sys/class/leds/* ; do
26                         trigger=$(grep "$(basename $led)" /etc/default/leds | grep bluetooth | \
27                                         awk '{print $2}' )
28                         if [ "$trigger" = "bluetooth" ] ; then
29                                 echo default-on > "$led/trigger"
30                                 echo 255 > "$led/brightness"
31                         fi
32                 done
33         fi
34         exit 0
35 elif [ "$1" = "0" ]; then
36         killall hciattach
37         echo 0 > /sys/class/gpio/gpio15/value
38         if [ -e /sys/class/leds/ ] ; then
39                 for led in /sys/class/leds/* ; do
40                         trigger=$(grep "$(basename $led)" /etc/default/leds | grep bluetooth | \
41                                         awk '{print $2}' )
42                         if [ "$trigger" = "bluetooth" ] ; then
43                                 echo 0 > "$led/brightness"
44                         fi                      
45                 done
46         fi
47         echo 10 > /sys/devices/platform/omap_uart.0/sleep_timeout
48         exit 0
49 else
50         echo "invalid argument"
51         exit 1
52 fi
53