Subversion Repositories HomeAutomation

Rev

Blame | Last modification | View Log | SVN | RSS feed

  1. <?php
  2.  
  3. $DEBUG = false;
  4. //$DEBUG = true;
  5.  
  6. include('config.php');
  7.  
  8. if (array_key_exists("remote", $_REQUEST) && array_key_exists("button", $_REQUEST) && array_key_exists("state", $_REQUEST) && array_key_exists("code", $_REQUEST))
  9. {
  10.     $remote = $_REQUEST["remote"];
  11.     $state = $_REQUEST["state"];
  12.     $code = $_REQUEST["code"];
  13.     $button = $_REQUEST["button"];
  14.  
  15.     if ($DEBUG)
  16.     {
  17.         echo "remote=".$remote." button=".$button." code=".$code." state=".$state;
  18.     }
  19.    
  20.     if ($state=="Pressed")
  21.     {
  22.         $message1 = "ServiceManager.getService(\"Can\", \"irTransmit\", ".$irTransmitterID.").sendButton(\"".$remote."\", \"".$button."\", true);\n";
  23.     }
  24.     else
  25.     {
  26.         $message1 = "ServiceManager.getService(\"Can\", \"irTransmit\", ".$irTransmitterID.").sendButton(\"".$remote."\", \"".$button."\", false);\n";
  27.     }
  28.     $message2 = "quit();\n";
  29.    
  30.     $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("could not connect to atom");
  31.     $result = socket_connect($socket, $host, $port) or die("Could not connect to atom");
  32.     usleep (2000);
  33.     socket_write($socket, $message1, strlen($message1)) or die("Could not send data to atom");
  34.     usleep (2000);
  35.     socket_write($socket, $message2, strlen($message2)) or die("Could not send data to atom");
  36.     usleep (2000);
  37.     socket_close($socket);
  38.    
  39.     echo "Sent $button successfully";
  40.    
  41.     exit;
  42. }
  43.  
  44. ?>
  45.  
  46.  
  47.  
  48.