Permalink
Browse files

Initial version

  • Loading branch information...
fernadosilva committed Oct 7, 2015
0 parents commit a7be1a82e5fa5df2e512dea99208ed6d2c33d173
Showing with 1,533 additions and 0 deletions.
  1. +674 −0 COPYING.GPL3
  2. +136 −0 README
  3. +48 −0 css/orvfms.css
  4. +49 −0 lib/globals.php
  5. +364 −0 lib/orvfms.php
  6. +69 −0 lib/test.php
  7. +68 −0 lib/utils.php
  8. +125 −0 s20/index.php

Large diffs are not rendered by default.

Oops, something went wrong.
136 README
@@ -0,0 +1,136 @@
#*************************************************************************
# Copyright (C) 2015 by Fernando M. Silva fcr@netcabo.pt *
#*************************************************************************/
INSTALLATION NOTES
The set of tools contained in the orvfms S20 library comprise:
orvfms/lib
-a php library with a set of simple functions that are able to control
the orvibo S20 power switch (scan the network, retrieve the S20 names,
check the status and power off/power on each one
orvfms/s20
- One example of a web interface that makes use of the orvfms library.
This interface, while just a quite simple example, is fully functional
and it was conceived to be responsive in any web viewport size, in particular
smartphones. It divides the viewport in N horizontal buttons, each one with
the name of each S20 automatically found in the local network. Each button
is green or red according to the current S20 state (green = ON)
orvfms/css
- The css stylesheet used by the example in orvfms/s20
TESTING THE CODE
Before installing this code on a web server, please test if the library recognizes
and is able to operate your S20. For this purpose, the test program test.php
in the lib directory scans your network for devices, dump all the contents in a readble
format and makes a full power on / power off cycle in all your S20s. PLEASE TAKE INTO
ACCOUNT POSSIBLE SAFETY ISSUES of switching on/off! Uplug any device or appliance
that nay be affected by this test cycle!
In order to test the libray with your network in command line, just
open a console and:
1. cd to the lib directory
2. Check the file globals.php and please confirm (or update) the
broadcast address. Unappily, there is no portable and "clean"
way of finding it, since the host may have more than one
network interface.
3. Check if you do not have appliances connected that may be affected
by the power on/off cycle. Unplug any devices that you want to spare.
4. Just type in the command line:
prompt> php-cgi test.php
(or replace php-cgi with the name of your php interpreter).
The output is quite straightforward, and possibly you are immediately able
to recognize most of it. You should also see/hear the usual switch of
the S20. An example output is shown at the end of this file
INSTALLATION OF THE SERVER CODE
The main server code is located in s20/index.php.
The details of the installation will slightly depend on your HTTP server
configuration. Anyway, just move the index.php, css/orvfms.css and
orvfms/lib/* to the directories that suit your server and desired
configuration. You just have to check/update in the index.php
(1) the relative location of orvfms libray (2) the relative location
of the css/orvfms.css library.
In order to be able to operate the S20s from any place, I just installed
the webserver on a general purpose, low power, raspberry pi that
I keep always pwowered on at home and that I use also as a media server.
Of course, in order to reach the private network you have to configure
your router with some Dynamic DNS and add appropriate port forwarding
rules to your router. These operations are router dependent and are
beyond the scope of this document.
EXAMPLE OUTPUT OF THE TEST SCRIPT
Result of runing the test script test.php
(for 3 S20, names and initial state may of course differ):
X-Powered-By: PHP/5.4.45-0+deb7u1
Content-type: text/html
Array
(
[accf23358402] => Array
(
[ip] => 192.168.1.83
[st] => 0
[imac] => 02843523cfac
[name] => Living room
)
[accf2334e2b8] => Array
(
[ip] => 192.168.1.79
[st] => 1
[imac] => b8e23423cfac
[name] => Heater
)
[accf23350e50] => Array
(
[ip] => 192.168.1.85
[st] => 0
[imac] => 500e3523cfac
[name] => Room
)
)
Status of S20 named >Living room< (mac=accf23358402, IP=192.168.1.83) is OFF
...Turning it ON
...new status is ON
Status of S20 named >Heater< (mac=accf2334e2b8, IP=192.168.1.79) is ON
...Turning it OFF
...new status is OFF
Status of S20 named >Room< (mac=accf23350e50, IP=192.168.1.85) is OFF
...Turning it ON
...new status is ON
Status of S20 named >Living room< (mac=accf23358402, IP=192.168.1.83) is ON
...Turning it OFF
...new status is OFF
Status of S20 named >Heater< (mac=accf2334e2b8, IP=192.168.1.79) is OFF
...Turning it ON
...new status is ON
Status of S20 named >Room< (mac=accf23350e50, IP=192.168.1.85) is ON
...Turning it OFF
...new status is OFF
@@ -0,0 +1,48 @@
/*
Button code obtained at dabuttonfactory.com
*/
body { background: #e7e7e7; font-family: Verdana, sans-serif; font-size: 11pt; }
#page { background: #ffffff; margin: 50px; border: 2px solid #c0c0c0; padding: 10px; }
#header { background: #4b6983; border: 2px solid #7590ae; text-align: center; padding: 10px; color: #ffffff; }
#header h1 { color: #ffffff; }
#body { padding: 10px; }
span.tt { font-family: monospace; }
span.bold { font-weight: bold; }
a:link { text-decoration: none; font-weight: bold; color: #C00; background: #ffc; }
a:visited { text-decoration: none; font-weight: bold; color: #999; background: #ffc; }
a:active { text-decoration: none; font-weight: bold; color: #F00; background: #FC0; }
a:hover { text-decoration: none; color: #C00; background: #FC0; }
#redbutton {
width: 95vw;
height: 20vh;
display: inline-block;
background: #900 url('http://dabuttonfactory.com/button.png?w=1&h=40&bgt=gradient&bgc=f00&ebgc=900') repeat-x;
background: -moz-linear-gradient(#f00, #900);
background: -o-linear-gradient(#f00, #900);
background: -webkit-linear-gradient(#f00, #900);
background: linear-gradient(#f00, #900);
border-radius: 5px;
color: #fff;
font: normal 700 29px/1 "Calibri", sans-serif;
font-size: 5vh;
text-align: center;
text-shadow: 1px 1px 0 #000;
}
#greenbutton {
width: 95vw;
height: 20vh;
display: inline-block;
background: #38761d url('http://dabuttonfactory.com/button.png?w=1&h=163&bgt=gradient&bgc=23ca23&ebgc=38761d') repeat-x;
background: -moz-linear-gradient(#23ca23, #38761d);
background: -o-linear-gradient(#23ca23, #38761d);
background: -webkit-linear-gradient(#23ca23, #38761d);
background: linear-gradient(#23ca23, #38761d);
color: #fff;
font: normal 700 29px/1 "Calibri", sans-serif;
font-size: 5vh;
text-align: center;
text-shadow: 1px 1px 0 #000;
}
@@ -0,0 +1,49 @@
<?php
/************************************************************************
* Copyright (C) 2015 by Fernando M. Silva fcr at netcabo dot pt *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
*************************************************************************/
/*
Generic constants for the orvfms S20 control library
*/
//
// You should update the IP broadcast to your local network.
// If you are in a domestic network, it will be almost surely
// 192.168.XXX.255, with X probably being either 0 or 1.
// The broadcast address is required to find all S20 in your
// network.
// Unhappily, there is no portable and "clean" way of
// finding it. Of course, there are several tricks that could
// be done, but they would be system depedendt and prone to
// failures.
//
define("IP_BROADCAST","192.168.1.255");
define("PORT",10000);
define("TWENTIES","202020202020");
define("DISCOVERY_MSG","686400067161");
define("SUBSCRIBE","6864001e636C");
define("ACTION","686400176463");
define("ON" ,"0000000001");
define("OFF","0000000000");
define("MAX_RETRIES",30);
?>
Oops, something went wrong.

0 comments on commit a7be1a8

Please sign in to comment.