-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.php
executable file
·45 lines (32 loc) · 995 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?
require(dirname(__FILE__).'/src/mysensors.class.php');
// instance Class ---------------------------------------------
//Ethernet Gateway
$mys=new MySensorSendEthernet('10.1.7.40');
// or
//Serial Gateway
//$mys=new MySensorSendSerial('COM1');
// fetching the Gateway Version -------------------------------
echo "Gateway version is : ";
echo $mys->internal(0, 0, 'I_VERSION',false,true);
echo " <br>\n";
DisplayMessages(1);
echo "<hr>\n\n";
// Sending a message to a node -------------------------------
$node_id ='199';
$child_id ='0';
$type ='V_STATUS';
$payload =1;
echo "Sending $type=$payload to node $node_id , child $child_id<br>\n";
$mys->set($node_id, $child_id,$type,$payload);
DisplayMessages(0);
//-----------------------------------------------
function DisplayMessages($with_answer=0){
global $mys;
echo " - Message sent : ".$mys->GetRawMessage() ." <br>\n";
if($with_answer){
echo " - Answer received : ".$mys->GetRawAnswer()." <br>\n";;
}
echo "\n";
}
?>