../..
authorBernhard Tittelbach <xro@realraum.at>
Tue, 22 Oct 2013 22:29:18 +0000 (22:29 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Tue, 22 Oct 2013 22:29:18 +0000 (22:29 +0000)
router_gpio_relay_licht/mswitch.cgi
router_gpio_relay_licht/switch.cgi

index 6d0d587..94176ce 100755 (executable)
@@ -25,21 +25,21 @@ done
 print_gpio_state() {
   GPIOVALUE=$(cat "${GPIOPATH}${1}/value")
   if [ "$GPIOVALUE" = "1" ]; then
-    echo "1"
+    echo -n "true"
   else
-    echo "0"
+    echo -n "false"
   fi
 }
 
 gpio_is_on() {
-  GPIOVALUE=$(cat "${GPIOPATH}${1}/value")                                                                                                                                    
+  GPIOVALUE=$(cat "${GPIOPATH}${1}/value")
   [ "$GPIOVALUE" = "1" ]
 }
 
 echo "Content-type: text/html"
 echo ""
 
-
+echo "{"
 for CHECKID in $VALID_ONOFF_IDS; do
   VAL=""
   VAL="$(eval echo \$GPIO_$CHECKID)"
@@ -48,8 +48,9 @@ for CHECKID in $VALID_ONOFF_IDS; do
   fi
   echo -n "$CHECKID:"
   print_gpio_state $CHECKID
+  echo ","
 done
-
+echo "-1:false}"
 #      echo "<html>"
 #      echo "<head>"
 #      echo "<title>Realraum Relay Switch</title>"
index 9406356..926b941 100755 (executable)
@@ -35,7 +35,7 @@ print_gpio_state() {
 }
 
 gpio_is_on() {
-  GPIOVALUE=$(cat "${GPIOPATH}${1}/value")                                                                                                                                    
+  GPIOVALUE=$(cat "${GPIOPATH}${1}/value")
   [ "$GPIOVALUE" = "1" ]
 }
 
@@ -66,6 +66,10 @@ echo "<html>"
 echo "<head>"
 echo "<title>Realraum Relay Power</title>"
 echo '<script type="text/javascript">'
+echo 'function updateButtons(data)
+{
+
+}'
 echo 'function sendButton( onoff, btn )'
 echo '{'
 echo ' var req = new XMLHttpRequest();'
@@ -147,11 +151,11 @@ for DISPID in $VALID_ONOFF_IDS; do
 echo "<div class=\"switchbox\">"
   echo "<span class=\"alignbuttonsleft\">"
   if gpio_is_on $DISPID; then
-  echo " <button class=\"onbutton enableborder\" onClick='sendButton(\"1\",\"$DISPID\");'>On</button>"
-  echo " <button class=\"offbutton\" onClick='sendButton(\"0\",\"$DISPID\");'>Off</button>"
+  echo " <button id=\"onbtn_$DISPID\" class=\"onbutton enableborder\" onClick='sendButton(\"1\",\"$DISPID\");'>On</button>"
+  echo " <button id=\"offbtn_$DISPID\" class=\"offbutton\" onClick='sendButton(\"0\",\"$DISPID\");'>Off</button>"
   else
-  echo " <button class=\"onbutton\" onClick='sendButton(\"1\",\"$DISPID\");'>On</button>"
-  echo " <button class=\"offbutton enableborder\" onClick='sendButton(\"0\",\"$DISPID\");'>Off</button>"
+  echo " <button id=\"onbtn_$DISPID\" class=\"onbutton\" onClick='sendButton(\"1\",\"$DISPID\");'>On</button>"
+  echo " <button id=\"offbtn_$DISPID\" class=\"offbutton enableborder\" onClick='sendButton(\"0\",\"$DISPID\");'>Off</button>"
   fi
   echo "</span>"
   echo -n "<div class=\"switchnameright\">$NAME</div>"