Hi,
I’m building a Philips HUE Wall switch.
So far I succeeded to create the actual switch logic using the HUE RESTful API.
Now I want the automate the registration process to the HUE IP Bridge. For this I used SSDP.
So far so good. The bridge responds to the SSDP query.
For me to identify if it is the HUE bridge that replied, I need to read the description.xml.
It seemed pretty simple but I can’t get it to work.
I build a little test program using the TCPClient example code.
After the connection is made there is no reply. At times it even crashes the core.
I used wireshark to check what happens. When the core connects I see a lot of TCP Retransmissions (Reassembly error, protocol TCP: New fragment overlaps old data) but no valid HTTP data.
Below is my test code. I hope someone can help me?
TCPClient client;
byte server[] = { 192, 168, 1, 196 };
void setup()
{
Serial.begin(9600);
while (!Serial.available()) SPARK_WLAN_Loop();
Serial.println("connecting...");
if (client.connect(server, 80))
{
Serial.println("connected");
client.flush();
client.println("GET /description.xml HTTP/1.1");
//client.println("GET /index.html HTTP/1.1");
client.println("HOST: 192.168.1.196:80");
client.println("USER-AGENT: Spark/1.0");
client.println("Accept: text/html, text/xml");
client.println("CONNECTION: close");
client.println();
client.flush();
}
else
{
Serial.println("connection failed");
}
}
void loop()
{
if (client.available())
{
char c = client.read();
Serial.print(c);
}
if (!client.connected())
{
Serial.println();
Serial.println("disconnecting...");
client.stop();
for(;;);
}
}