Controlling LAN UDP Relay board via PHP

 

 

 

PHP examples

 

-----------------------------------------------------

 

PHP code for STATUS Read UDP Relay board connected to

IP: 192.168.1.199

PORT:12345

UDP COMMAND: FF0000

 

<?php

 

$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);

$msg = "FF0000";
$len = strlen($msg);

socket_sendto($sock, $msg, $len, 0 ,'192.168.1.199', 12345);

socket_recvfrom($sock, $buf, 12, 0, $from, $port);
echo $buf;


socket_close($sock);

?>

 

-----------------------------------------------------

 

PHP code to turn ON first relay UDP Relay board connected to

IP: 192.168.1.199

PORT:12345

UDP COMMAND: FF0101

 

 

<?php

 

$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);

$msg = "FF0101";
$len = strlen($msg);

socket_sendto($sock, $msg, $len, 0 ,'192.168.1.199', 12345);
socket_close($sock);

echo "Relay 1 is ON";

?>

 

 

-----------------------------------------------------

 

PHP code to turn OFF first relay UDP Relay board connected to

IP: 192.168.1.199

PORT:12345

UDP COMMAND: FF0100

 

 

<?php


$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);

$msg = "FF0100";
$len = strlen($msg);

socket_sendto($sock, $msg, $len, 0 ,'192.168.1.199', 12345);
socket_close($sock);

echo "Relay 1 is OFF";

?>

 

 

-----------------------------------------------------

 

 

 

 

 

Read 5340 times