From fea210aad912a0bb818f89cf94805a266c956df3 Mon Sep 17 00:00:00 2001 From: tillepille Date: Sat, 16 Dec 2017 16:57:36 +0100 Subject: [PATCH] Added two minimal php scripts. One for pulling a current state of one switch, one for switching the state of one switch. This is for simplifying the usage with other third-party-software like Z-Wave or Homebridge. The Usage is completely optional. Also made a little change to the readme --- README.md | 4 ++-- webinterface/click.php | 43 +++++++++++++++++++++++++++++++++++++++++ webinterface/status.php | 36 ++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 webinterface/click.php create mode 100644 webinterface/status.php diff --git a/README.md b/README.md index 5c8b3ce..6506c2a 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ https://github.com/Panzenbaby/Raspberry-Remote-for-Windows-10-IoT-Core ## Usage Try if all is working with the send program -* Switch on single socket: `./send 00001 1 1` -* Switch on multiple sockets: `./send 00001 1 00001 2 00001 3 1` +* Switch on single socket: `./send 1 00001 1 1` +* Switch on multiple sockets: `./send 1 00001 1 1 00001 2 1 00001 3 1` ### Options * `-b`, `--binary`: Use binary socket numbering instead of the common "only one switch up"-numbering. See [Binary Mode](#binary-mode) for further details. diff --git a/webinterface/click.php b/webinterface/click.php new file mode 100644 index 0000000..27d850d --- /dev/null +++ b/webinterface/click.php @@ -0,0 +1,43 @@ += 5) { + $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("Could not create socket\n"); + socket_bind($socket, $source) or die("Could not bind to socket\n"); + socket_connect($socket, $target, $port) or die("Could not connect to socket\n"); + socket_write($socket, $output, strlen ($output)) or die("Could not write output\n"); + socket_close($socket); + + echo "Success!"; +}else { + echo "Please set sys group switch action delay"; +} + +?> diff --git a/webinterface/status.php b/webinterface/status.php new file mode 100644 index 0000000..221fd8e --- /dev/null +++ b/webinterface/status.php @@ -0,0 +1,36 @@ += 3) { + $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("Could not create socket\n"); + socket_bind($socket, $source) or die("Could not bind to socket\n"); + socket_connect($socket, $target, $port) or die("Could not connect to socket\n"); + + socket_write($socket, $output, strlen ($output)) or die("Could not write output\n"); + $state = socket_read($socket, 2048); + echo $state; +}else { + echo "Please set sys group switch"; +} +?>