The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: X10 and xAP




Andrew,

I have just been re-reading these post and have realised you are using
php, I thought it was all cgi.  The following lets you send a xAP
message in php using the socket class,  the code was part of the xAP
intranet that i am working on. (phpnuke based).  You will need to tweak
the source address and uid as required.  I have used this on apache and
iis and it works fine on both,  but you need to ake sure the socket
class exists on your install (most seem to have it)

function SendxAP($xapclass,$xaptarget,$xapbody){
global $localip,$broadcastip;
$xap="xap-header".chr(10)
."{".chr(10)
."v=12".chr(10)
."hop=1".chr(10)
."uid=FF401000".chr(10)
."class=$xapclass".chr(10)
."source=mi4.php.nuke".chr(10);
if
($xaptarget!=""){$xap.="target=$xaptarget".chr(10);};
$xap.="}".chr(10)
.$xapbody;

$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if ($s == false) {
echo "Error creating socket!\n";
echo "Error:".socket_strerror(socket_last_error($s));
} else {
if (phpversion()<"4.3"){
$opt_ret =  socket_setopt($s, 1, 6, TRUE);
}
else
{
$opt_ret =  socket_set_option($s, 1, 6, TRUE);
};
$e = socket_sendto($s, $xap, strlen($xap), 0, $broadcastip, 3639);
socket_close($s);
};


return 0;
};


with these set also
//First section of IP of local net
$localip="192.168.0.";
//Broadcast address for sending xAP
$broadcastip="192.168.0.255";

I hope this helps

James


Andrew Jones wrote:

>Hi everyone, I was pointed to xAP from someone on UKHA. What I am
trying to do is write a website (hopefully in php) that will control my X10
modules. At the moment though I just want to get something working offline.
>
>I have downloaded and installed the message sender (Send-v1.2.8.1.zip)
and X10 connector (X10-CM1xConnector_GUI-v1.0.1587.36821.zip). But now what
do I do? I have tried to make a text file to be sent with the sender:
>
>{
>v=12
>hop=1
>uid=FF182000
>class=xap-x10.request
>source=acme.my.controller
>target=X10-CM1xConnector
>}
>
>xap-x10.request
>{
>command=(on)
>device=(A1)
>}
>
>but when I send it, nothing happens. The message doesn't even come up
in the X10 GUI. It doesn't look too compicated, but how do I find out what
the target should be, and what about the UID?
>
>Thanks for any help :)
>
>
>
>
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
>





xAP_Automation Main Index | xAP_Automation Thread Index | xAP_Automation Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.