op_bluetooth: update for new kernel
authorGrazvydas Ignotas <notasas@gmail.com>
Tue, 3 Apr 2012 23:36:14 +0000 (02:36 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Wed, 4 Apr 2012 00:02:37 +0000 (03:02 +0300)
uses bluez userspace driver for new kernel, based on urjaman's work

recipes/pandora-system/pandora-scripts.bb
recipes/pandora-system/pandora-scripts/op_bluetooth.sh
recipes/pandora-system/pandora-scripts/op_bluetooth_work.sh [new file with mode: 0755]

index 9d4c234..459b4f3 100644 (file)
@@ -6,7 +6,7 @@ COMPATIBLE_MACHINE = "omap3-pandora"
 DEPENDS = "zenity dbus"
 RDEPENDS = "zenity dbus"
 
-PR = "r90"
+PR = "r91"
 
 SRC_URI = " \
           file://op_paths.sh \
@@ -17,6 +17,7 @@ SRC_URI = " \
           file://op_wifi.sh \
           file://op_wifi.pnd \  
           file://op_bluetooth.sh \
+          file://op_bluetooth_work.sh \
           file://op_bluetooth-check.desktop \
           file://op_bluetooth.desktop \          
           file://op_startupmanager.sh \
@@ -90,6 +91,7 @@ do_install() {
           install -m 0755 ${WORKDIR}/op_cpusettings.sh ${D}${prefix}/pandora/scripts/
           install -m 0755 ${WORKDIR}/op_wifi.sh ${D}${prefix}/pandora/scripts/
           install -m 0755 ${WORKDIR}/op_bluetooth.sh ${D}${prefix}/pandora/scripts/
+          install -m 0755 ${WORKDIR}/op_bluetooth_work.sh ${D}${prefix}/pandora/scripts/
           install -m 0755 ${WORKDIR}/op_startupmanager.sh ${D}${prefix}/pandora/scripts/
           install -m 0755 ${WORKDIR}/op_switchgui.sh ${D}${prefix}/pandora/scripts/
           install -m 0755 ${WORKDIR}/op_calibrate.sh ${D}${prefix}/pandora/scripts/
index 2d5b79a..b63fe76 100644 (file)
@@ -16,13 +16,14 @@ else
        then
                notify-send -u normal "Bluetooth" "Bluetooth is being disabled..." -i blueman -t 5000
                sudo /usr/sbin/hciconfig ${INTERFACE} down 1>/dev/null
+               sudo /usr/pandora/scripts/op_bluetooth_work.sh 0
                rm -f "$LOCK"
        else
-            kernel_major=`uname -r | cut -c 1`
-            if [ "$kernel_major" = "3" ]; then
-               zenity --info --title="Bluetooth not supported" --text "Sorry, the experimental kernel does not support Bluetooth (yet).\n\nIt could not be enabled."
-             exit 1
-            else
+               if ! sudo /usr/pandora/scripts/op_bluetooth_work.sh 1; then
+                       notify-send -u normal "Bluetooth" "Bluetooth error" -i blueman -t 3000
+                       exit 1
+               fi
+
                pgrep bluetoothd
                echo $INTERFACE
                 if [ $? -ne 1 ]; then
@@ -31,8 +32,6 @@ else
                        sudo /usr/sbin/hciconfig ${INTERFACE} up pscan 1>/dev/null
                        sudo /usr/sbin/bluetoothd 1>/dev/null
                        touch "$LOCK"
-
                fi
        fi
-    fi
 fi
diff --git a/recipes/pandora-system/pandora-scripts/op_bluetooth_work.sh b/recipes/pandora-system/pandora-scripts/op_bluetooth_work.sh
new file mode 100755 (executable)
index 0000000..7c0f2af
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+kernel_major=`uname -r | cut -c 1`
+if [ "$kernel_major" = "2" ]; then
+       # new kernel only (for now)
+       exit 0
+fi
+
+if [ "$1" = "1" ]; then
+       if [ ! -e /sys/class/gpio/gpio15/value ]; then
+               echo 15 > /sys/class/gpio/export
+               sleep 0.2
+               echo out > /sys/class/gpio/gpio15/direction
+       fi
+       echo 1 > /sys/class/gpio/gpio15/value
+       hciattach /dev/ttyO0 texasalt 3000000
+       INTERFACE="`hciconfig | grep "^hci" | cut -d ':' -f 1`"
+       if [ -z "$INTERFACE" ]; then
+               killall hciattach
+               echo 0 > /sys/class/gpio/gpio15/value
+               exit 1
+       fi
+       echo 255 > '/sys/class/leds/pandora::bluetooth/brightness'
+       exit 0
+elif [ "$1" = "0" ]; then
+       killall hciattach
+       echo 0 > /sys/class/gpio/gpio15/value
+       echo 0 > '/sys/class/leds/pandora::bluetooth/brightness'
+       exit 0
+else
+       echo "invalid argument"
+       exit 1
+fi
+