Using HTTP response to change relay state
Posted: Tue Apr 25, 2017 1:04 pm
I'm trying to compare every line of the HTTP response to change the state of a relay. I know it's not ideal and there are more elegant ways to do it but for the moment I just need a working prototype to test the module.
the code I have is this:
-> False is returned for everything
the code I have is this:
Code: Select all
// Read the entire response and flush it to Serial output
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
if(!strcmp(line.c_str(),"OFF")){
Serial.println(" -> True");
} else {
Serial.println(" -> False");
}
-> False is returned for everything
Code: Select all
Request sent - waiting for reply...
HTTP/1.1 200 OK -> False
Content-Type: text/html; charset=UTF-8 -> False
Content-Length: 3 -> False
Date: Tue, 25 Apr 2017 18:02:28 GMT -> False
Accept-Ranges: bytes -> False
Server: LiteSpeed -> False
Connection: close -> False
-> False
OFF -> False
Connection closed.