pandora-scripts: BT suspend fix from urjaman
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_power.sh
index 9b0e1b2..0401d07 100644 (file)
@@ -25,13 +25,15 @@ fi
 debug && echo "powerstate=$powerstate"
 
 suspend_net() {
-       hcistate=$(hciconfig hci0 | grep DOWN)
-       if [ $hcistate ]; then
-               echo "down" > /tmp/hcistate
+       # This is kernel 3.x only,
+       # but ignored since 2.6 only has lowpower anyways (no suspend)
+       if (ps -A | grep -q hciattac[h]); then
+               touch /tmp/bt-state-up
+               /usr/pandora/scripts/op_bluetooth_work.sh 0
        else
-               echo "up" > /tmp/hcistate
-               hciconfig hci0 down
+               rm -f /tmp/bt-state-up
        fi
+
        wlstate=$(lsmod | grep -m1 wl1251)
        if [ -z "$wlstate" ]; then
                echo "down" > /tmp/wlstate
@@ -44,8 +46,8 @@ suspend_net() {
 }
 
 resume_net() {
-       hcistate=$(cat /tmp/hcistate)
-       if [ "$hcistate" = "up" ]; then
+       if [ -f /tmp/bt-state-up ]; then
+               /usr/pandora/scripts/op_bluetooth_work.sh 1
                hciconfig hci0 up pscan
        fi
        wlstate=$(cat /tmp/wlstate)