moved mswitch.cgi switch.cgi to deckenlichtschalter git repo
authorBernhard Tittelbach <xro@realraum.at>
Sat, 20 Dec 2014 01:19:29 +0000 (01:19 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Sat, 20 Dec 2014 01:19:29 +0000 (01:19 +0000)
raspberrypi_gpio_relay_licht/mswitch.cgi [deleted file]
raspberrypi_gpio_relay_licht/switch.cgi [deleted file]

diff --git a/raspberrypi_gpio_relay_licht/mswitch.cgi b/raspberrypi_gpio_relay_licht/mswitch.cgi
deleted file mode 100755 (executable)
index d62bce9..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/bin/zsh
-
-VALID_ONOFF_IDS=(ceiling1 ceiling2 ceiling3 ceiling4 ceiling5 ceiling6)
-VALID_GPIO_IDS=(4 23 18 17 22 21)
-local -A IDGPIOMAP
-local -A GPIOIDMAP
-IDGPIOMAP[ceiling1]=4
-IDGPIOMAP[ceiling2]=23
-IDGPIOMAP[ceiling3]=18
-IDGPIOMAP[ceiling4]=17
-IDGPIOMAP[ceiling5]=22
-IDGPIOMAP[ceiling6]=21
-GPIOPATH=/sys/class/gpio/gpio
-SAVESTATE=/var/log/licht/mswitch.state
-
-for k v in ${(kv)IDGPIOMAP}; do
-  GPIOIDMAP[$v]=$k
-done
-
-local -A GPIOS
-for QUERY in `echo $QUERY_STRING | tr '&' ' '`; do
-  for VALIDID in $VALID_ONOFF_IDS; do
-    if [ "$QUERY" = "$VALIDID=1" ]; then
-      GPIOS[$IDGPIOMAP[$VALIDID]]=1
-    elif [ "$QUERY" = "$VALIDID=0" ]; then
-      GPIOS[$IDGPIOMAP[$VALIDID]]=0
-    fi
-  done
-  if [ "$QUERY" = "mobile=1" ]; then
-    MOBILE='1'
-    NOFLOAT='1'
-  elif [ "$QUERY" = "nofloat=1" ]; then
-    NOFLOAT='1'
-  fi
-done
-
-
-print_gpio_state() {
-  GPIO=${IDGPIOMAP[$1]}
-  GPIOVALUE=$(cat "${GPIOPATH}${GPIO}/value")
-  if [[ $GPIOVALUE == "0" ]]; then
-    echo -n "true"
-  else
-    echo -n "false"
-  fi
-}
-
-print_gpio_state_10() {
-  GPIO=${IDGPIOMAP[$1]}
-  GPIOVALUE=$(cat "${GPIOPATH}${GPIO}/value")
-  if [[ $GPIOVALUE == "0" ]]; then
-    echo -n "1"
-  else
-    echo -n "0"
-  fi
-}
-
-gpio_is_on() {
-  GPIO=${IDGPIOMAP[$1]}
-  GPIOVALUE=$(cat "${GPIOPATH}${GPIO}/value")
-  [ "$GPIOVALUE" = "0" ]
-}
-
-echo "Content-type: text/html"
-echo ""
-
-local -a GPIOSTATES
-for CHECKID in $VALID_ONOFF_IDS; do
-  VAL=$GPIOS[$IDGPIOMAP[$CHECKID]]
-  if [[ $VAL == 1 || $VAL == 0 ]]; then
-    [[ $VAL == 1 ]] && VAL=0 || VAL=1
-    echo "$VAL" > "${GPIOPATH}${IDGPIOMAP[$CHECKID]}/value"
-  fi
-  GPIOSTATES+=(\"${CHECKID}\":"$(print_gpio_state $CHECKID)")
-  URISTATES+=("${CHECKID}=$(print_gpio_state_10 $CHECKID)")
-done
-JSON_STATE="{${(j:,:)GPIOSTATES}}"
-print ${(q)JSON_STATE}
-if ((#GPIOS > 0)); then
-  print "[$(date +%s),\"$REMOTE_ADDR\",${(q)JSON_STATE}]," >> /var/log/licht/mswitch.log
-  echo -n "${(j:&:)URISTATES}">$SAVESTATE
-fi
-
diff --git a/raspberrypi_gpio_relay_licht/switch.cgi b/raspberrypi_gpio_relay_licht/switch.cgi
deleted file mode 100755 (executable)
index 5ff6ac6..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-#!/bin/sh
-
-for QUERY in `echo $QUERY_STRING | tr '&' ' '`; do
-  for VALUE in `echo $QUERY | tr '=' ' '`; do
-    if [ "$VALUE" = "id" ]; then
-      ID='?'
-    elif [ "$ID" = "?" ]; then
-      ID=$VALUE
-    elif [ "$VALUE" = "power" ]; then
-      POWER='?'
-    elif [ "$POWER" = "?" ]; then
-      POWER=$VALUE
-    elif [ "$VALUE" = "mobile" ]; then
-      MOBILE='1'
-      NOFLOAT='1'
-    elif [ "$VALUE" = "nofloat" ]; then
-      NOFLOAT='1'
-    fi
-    i=$i+1
-  done
-done
-
-VALID_ONOFF_IDS="ceiling1 ceiling2 ceiling3 ceiling4 ceiling5 ceiling6"
-VALID_SEND_IDS=""
-
-DESC_ceiling1="Decke E-Labor (SSW)"
-DESC_ceiling2="Decke Leinwand (S)"
-DESC_ceiling3="Decke Eingang (W)"
-DESC_ceiling4="Decke Durchgang (O)"
-DESC_ceiling5="Decke Auslage (N)"
-DESC_ceiling6="Decke K&uuml;che (NNO)"
-
-echo "Content-type: text/html"
-echo ""
-echo "<html>"
-echo "<head>"
-echo "<title>Realraum Relay Power</title>"
-echo '<script type="text/javascript">'
-
-echo 'function callbackUpdateButtons(req) {
-  if (req.status != 200) {
-    return;
-  }
-  var data = JSON.parse(req.responseText);
-  for (var keyid in data) {
-    on_btn = document.getElementById("onbtn_"+keyid);
-    off_btn = document.getElementById("offbtn_"+keyid);
-    if (on_btn && off_btn)
-    {
-      on_btn.className = "onbutton";
-      off_btn.className = "offbutton";
-      if (data[keyid])
-      { on_btn.className += " enableborder"; }
-      else
-      { off_btn.className += " enableborder"; }
-    }
-  }
-}'
-
-echo 'function updateButtons(uri) {
-  var req = new XMLHttpRequest;
-  req.overrideMimeType("application/json");
-  req.open("GET", uri, true);
-  req.onload  = function() {callbackUpdateButtons(req)};
-  req.setRequestHeader("googlechromefix","");
-  req.send(null);
-}'
-
-echo 'function sendMultiButton( str ) {
- url = "/cgi-bin/mswitch.cgi?"+str;
-  updateButtons(url);
-}'
-
-echo 'setInterval("updateButtons(\"/cgi-bin/mswitch.cgi\");", 30*1000);'
-echo 'updateButtons("/cgi-bin/mswitch.cgi");'
-
-echo '</script>'
-echo '<style>'
-echo 'div.switchbox {'
-echo '    float:left;'
-echo '    margin:2px;'
-#echo '    max-width:236px;'
-echo '    max-width:300px;'
-echo '    font-size:10pt;'
-echo '    border:1px solid black;'
-#echo '    height: 32px;'
-echo '    padding:0;'
-echo '}'
-
-echo 'div.switchnameleft {'
-echo '    width:12em; display:inline-block; vertical-align:middle; margin-left:3px;'
-echo '}'
-
-echo 'span.alignbuttonsright {'
-echo '    top:0px; float:right; display:inline-block; text-align:right; padding:0;'
-echo '}'
-
-echo 'div.switchnameright {'
-echo '    width:12em; display:inline-block; vertical-align:middle; float:right; display:inline-block; margin-left:1ex; margin-right:3px; margin-top:3px; margin-bottom:3px;'
-echo '}'
-
-echo 'span.alignbuttonsleft {'
-echo '    float:left; text-align:left; padding:0;'
-echo '}'
-
-echo '.onbutton {'
-echo '    font-size:11pt;'
-echo '    width: 40px;'
-echo '    height: 32px;'
-echo '    background-color: lime;'
-echo '    margin: 0px;'
-echo '}'
-
-echo '.offbutton {'
-echo '    font-size:11pt;'
-echo '    width: 40px;'
-echo '    height: 32px;'
-echo '    background-color: red;'
-echo '    margin: 0px;'
-echo '}'
-
-echo '.sendbutton {'
-echo '    font-size:11pt;'
-echo '    width: 40px;'
-echo '    height: 32px;'
-#echo '    background-color: grey;'
-echo '    margin: 0px;'
-echo '}'
-
-echo '.enableborder {
-    font-weight: bold;
-    font-variant: small-caps;
-    border-style: inset;'
-echo '}'
-echo '</style>'
-echo "</head>"
-echo "<body>"
-#echo "<h1>Realraum rf433ctl</h1>"
-#echo "<div style=\"float:left; border:1px solid black;\">"
-echo "<div style=\"float:left;\">"
-echo "<div style=\"float:left; border:1px solid black; margin-right:2ex; margin-bottom:2ex;\">"
-for DISPID in $VALID_ONOFF_IDS; do
-  NAME="$(eval echo -n \$DESC_$DISPID)"
-  [ -z "$NAME" ] && NAME=$DISPID
-
-  echo "<div class=\"switchbox\">"
-  echo "<span class=\"alignbuttonsleft\">"
-  if gpio_is_on $DISPID; then
-  echo " <button id=\"onbtn_$DISPID\" class=\"onbutton enableborder\" onClick='sendMultiButton(\"$DISPID=1\");'>On</button>"
-  echo " <button id=\"offbtn_$DISPID\" class=\"offbutton\" onClick='sendMultiButton(\"$DISPID=0\");'>Off</button>"
-  else
-  echo " <button id=\"onbtn_$DISPID\" class=\"onbutton\" onClick='sendMultiButton(\"$DISPID=1\");'>On</button>"
-  echo " <button id=\"offbtn_$DISPID\" class=\"offbutton enableborder\" onClick='sendMultiButton(\"$DISPID=0\");'>Off</button>"
-  fi
-  echo "</span>"
-  echo -n "<div class=\"switchnameright\">$NAME</div>"
-#  echo -n "<div class=\"switchnameright\">$NAME ("
-#  print_gpio_state $DISPID
-#  echo ")</div>"
-  echo "</div>"
-
-  if [ "$NOFLOAT" = "1" ]; then
-    echo "<br/>"
-  fi
-done
-
-#Alle
-echo "<div class=\"switchbox\">"
-echo "<span class=\"alignbuttonsleft\">"
-echo -n " <button class=\"onbutton\" onClick='sendMultiButton(\""
-for DISPID in $VALID_ONOFF_IDS; do echo -n "$DISPID=1&"; done
-echo "\");'>On</button>"
-echo -n " <button class=\"offbutton\" onClick='sendMultiButton(\""
-for DISPID in $VALID_ONOFF_IDS; do echo -n "$DISPID=0&"; done
-echo "\");'>Off</button>"
-echo "</span>"
-echo -n "<div class=\"switchnameright\">Alle</div>"
-echo "</div>"
-
-if [ "$NOFLOAT" = "1" ]; then
-  echo "<br/>"
-fi
-
-#Pattern1
-echo "<div class=\"switchbox\">"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=0&ceiling2=0&ceiling3=1&ceiling4=1&ceiling5=0&ceiling6=0\");'>[&nbsp;|&nbsp;]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=1&ceiling2=1&ceiling3=0&ceiling4=0&ceiling5=1&ceiling6=1\");'>[|&nbsp;|]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=1&ceiling2=0&ceiling3=0&ceiling4=0&ceiling5=1&ceiling6=1\");'>[|&nbsp;.]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=0&ceiling2=1&ceiling3=0&ceiling4=1&ceiling5=0&ceiling6=1\");'>[***]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=1&ceiling2=0&ceiling3=0&ceiling4=0&ceiling5=0&ceiling6=1\");'>[*&nbsp;.]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=0&ceiling2=0&ceiling3=0&ceiling4=0&ceiling5=1&ceiling6=1\");'>[|&nbsp;&nbsp;]</button>"
-echo "</div>"
-
-if [ "$NOFLOAT" = "1" ]; then
-  echo "<br/>"
-fi
-echo "</div>"
-
-if [ "$MOBILE" != "1" -a -n "$VALID_SEND_IDS" ]; then
-
-echo "<div style=\"float:left; border:1px solid black; margin-right:2ex; margin-bottom:2ex;\">"
-
-ITEMCOUNT=0
-
-echo "</div>"
-fi
-echo "</div>"
-echo "</body>"
-echo "</html>"