Hi,
I'm trying to control my philips hue bulbs with Pronto. It uses en http protocol
(see:
[Link: developers.meethue.com])
Here is my code for now:
var socket = new TCPSocket(false);
var chaine=""
var JSON_Test = '{"devicetype":"test user","username":"newdeveloper"}';
System.print("call connect");
socket.connect('192.168.0.158', 80, 3000);
function getInfos()
{
socket.write("POST /api HTTP/1.1 \r\n\r\n"+JSON_Test);
}
socket.onConnect = function()
{
getInfos();
};
socket.onData = function()
{
result += socket.read();
};
socket.onClose = function()
{
var resultStartIndex =result.indexOf("\r\n\r\n");
var jsonData = result.substring(resultStartIndex+4);
System.print("resultas: "+jsonData);
}
When I use that, the response is:
[{"error":{"type":5,"address":"/","description":"invalid/missing parameters in body"}}]
I am probably wrong with the JSON object i tried to sent, but i don't know how to solve that.
Can anyone please help me ?