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 12 made on Tuesday October 1, 2013 at 07:56
bibi-12
Long Time Member
Joined:
Posts:
February 2008
16
here is the code:

var brightness=0;
currCounterValue=0;

onRotary = function(clicks)
{


if (clicks >= 3)
{
socket_bri=null;
var socket_bri = new TCPSocket(false);
socket_bri.myCounter = ++currCounterValue;
System.print("counter: " +socket_bri.myCounter);
brightness=parseInt(brightness)+5*clicks<=255?parseInt(brightness)+5*clicks:255;
var JSON_commande='{"bri":'+brightness+'}';
socket_bri.connect('192.168.0.158', 80, 500);

function setBright(sock,commands)
{
if (sock.connected)
socket_bri.write('PUT /api/newdeveloper/groups/all/action HTTP/1.1\r\nConnection: close\r\nContent-Length: '+commands.length+'\r\n\r\n'+commands);
System.print("counter_f: " +socket_bri.myCounter);

}
socket_bri.onConnect = function()
{
setBright(this,JSON_commande);
if (this.connected)
{
try{this.close()}catch(e){}
}
if (socket_bri === this)
{
// if what is happening is what I believe, this line will rarely be executed. System.print() will confirm.
System.print("It is happening");
System.print(socket_bri.myCounter);
socket_bri = null;
}

};
socket_bri.onClose = function()
{
System.print("count_close: "+socket_bri.myCounter);
socket_bri = null;


}
socket_bri.onIOerror = function()
{
System.print("error");
try {
socket_bri.close()
socket_bri = null
} catch(e) {}



}


}

};

It seems to work quite well with HTTP 1.0


Hosting Services by ipHouse