Skip to content

Instantly share code, notes, and snippets.

@u01jmg3
Created April 6, 2015 08:59
Show Gist options
  • Save u01jmg3/de953870a1d93d9a1733 to your computer and use it in GitHub Desktop.
Save u01jmg3/de953870a1d93d9a1733 to your computer and use it in GitHub Desktop.
Orvibo S20 WiFi Socket Controller
<?php
//Orvibo S20 - http://www.amazon.co.uk/gp/product/B00PQ0KNBA/
error_reporting(E_ALL | E_STRICT);
//================ CHANGE ME ================
$macAddress = strtolower('AC-CF-23-99-9Z-99'); //Keep hyphenated
$localIPAddress = '192.168.1.99';
//===========================================
$port = 10000;
$twenties = '202020202020';
$ma = implode('', explode('-', $macAddress));
$maReverse = implode('', array_reverse(explode('-', $macAddress)));
$subscribe = pack('H*', '6864001e636c' . $ma . $twenties . $maReverse . $twenties);
$on = pack('H*', '686400176463' . $ma . $twenties . '0000000001');
$off = pack('H*', '686400176463' . $ma . $twenties . '0000000000');
$socket = socket_create(AF_INET, SOCK_DGRAM, 0);
socket_sendto($socket, $subscribe, strlen($subscribe), 0, $localIPAddress, $port);
sleep(1);
socket_sendto($socket, $on, strlen($on), 0, $localIPAddress, $port);
sleep(2);
socket_sendto($socket, $off, strlen($off), 0, $localIPAddress, $port);
socket_close($socket);
@u01jmg3
Copy link
Author

u01jmg3 commented Apr 6, 2015

  • Assumptions
    • You need to set your S20 socket up using the WiWo app first.
      • This code only controls an already set up (network configured) socket.
    • You are on the same (local) network as the socket.
      • This code will not work unless you are on the same network.
    • The php_sockets extension must be enabled on your (WAMP) server so that this script can run.

@u01jmg3
Copy link
Author

u01jmg3 commented Apr 6, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment