Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Original thread:
Post 3 made on Thursday September 30, 2010 at 10:32
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,003
Training tips:

O'Reilly Webmaster in a Nutshell and online RFC's for HTTP are a bit help to me.

Flanagan Book first 11 chapters will get you started on pure javascript. Dev Guide will fill in holes. Also search for a thread I posted entitled something like: "But Really, what is Prontoscript" as it will shed some light on how all the pieces fit together.

You may also want to download the RSS Reader from Philips and also look at the HTTP module they provided. It is not that performant but it does show you how to process response headers from the html response you will be receiving to get to the <html>xxxxyyyyyyyy</html> as documented in the manual for the GetPower command.

Reading the manual for which you posted the link above, you are supposed to send via the http protocol a simple string:

username:[email protected]/Set.cmd?CMD=SetSchedule+Powe
r
=**+YY=****+MM=**+DD=**+HH=**+MN=**+SS=**+PARAM=****+ONOFF=*

So, assuming the equipment is at 192.168.0.50, you'd open a TCP socket to "192.168.0.50" on port 80 and send a string similar to the following with the MM, DD, YY, HH, MN, SS, PARAM values as you want to set them. [myusername] and [mypassword] should be the username and password you use to logon to the equipment:

[myusername]:[mypassword]@192.168.0.50/Set.cmd?CMD=SetSchedule+Powe
r
=**+YY=****+MM=**+DD=**+HH=**+MN=**+SS=**+PARAM=****+ONOFF=*

So, with your above script and the example from the manual using the new IP address, you'd do:

var socket = new TCPSocket(true);
var toSend = "admin:[email protected]/Set.cmd?CMD=SetSchedule+Power=1A+YY=2010+MM=09+DD=30+HH=23+MN=59+SS=59+PARAM=128+ONOFF=1";

socket.connect("192.168.0.50", 80, 3000);
socket.write(toSend + '\r\n\r\n'); // Note: the CRLF combination may not be required but for true HTTP, this signals the end of the HTTP transmission.
socket.close();

I also highly recommend that you use asynchronous sockets in which case you'd use the onConnect and onData functions as discussed in the dev guide (see the examples and read Appendix A for fine-grained detail) and tweak your socket constructor as follows:
var socket = new TCPSocket(false);

Note that this equipment also support simple string transmission via the telnet protocol, which is supported on port 23. So instead of using port 80 and having the overhead of HTTP reponse processing to get to the html body, you may want to try port 23 and the following:

var socket = new TCPSocket(true);
var toSend = "getpower";

socket.connect("192.168.0.50", 80, 3000);
socket.write(toSend + '\r'); // Note: the CR combination will likely be required to signal the end of message via telnet. If this does not work, change \r to \r\n.
socket.close();

Note that you will get a multi-line response for getPower(). Each line will likely be terminated with \r.

With regard to handling multi-line responses, you must build a buffer of received data and then "peel off" each line one-by one.

There are various buffering techniques folks use and these are likely discussed in a document Barry Gordon put together on his site. http:\\www.the-gordons.net (go to downloads link and then select Pronto Communications document download from left-hand frame).

I've tried to be informative here and realize that some of this may be vague. It is that way because I don't have equipment in front of me to test with and I can only go on information I see in the protocol spec which may or may not be accurate.
Lyndel McGee
Philips Pronto Addict/Beta Tester


Hosting Services by ipHouse