ESP8266 don't receive GET response from Node.js
Posted: Tue Oct 18, 2016 1:31 pm
0
down vote
favorite
i don't response from GET request, send from ESP8266 + Arduino Mega to Node.js. My code in node receive the request, but i don't get nothing in Arduino Code.
Node.js
Console log from Node.js
http://imgur.com/a/rKxYy
Code in Arduino
Then the esp don't receive the answer, but the Node.js send strings like a: {QTD1LAMP, ON}
I don't know what is the problem with my code. Using ESP8266 with Arduino Mega
down vote
favorite
i don't response from GET request, send from ESP8266 + Arduino Mega to Node.js. My code in node receive the request, but i don't get nothing in Arduino Code.
Node.js
Code: Select all
app.get('/StatusSaidas', function(req,res){
res.charset = 'UTF-8';
console.log('Send to Arduino: ' + statusArdu);
res.send(statusArdu);
});
Console log from Node.js
http://imgur.com/a/rKxYy
Code in Arduino
Code: Select all
uint8_t buffer[1024] = {0};
if (wifi.createTCP(HOST_NAME, HOST_PORT)) {
Serial.print("Connection with Host OK!\r\n");
} else {
Serial.print("Error to connected to Host!\r\n");
}
char *ComandoGET = "GET /StatusSaidas HTTP/1.1\r\nHost: SmartHouse\r\nConnection: close\r\n\r\n";
wifi.send((const uint8_t*)ComandoGET, strlen(ComandoGET));
uint32_t len = wifi.recv(buffer, sizeof(buffer), 10000);
char *resposta = buffer;
for (int i = 0; i < len; i++)
{
if (strncmp(resposta++, "\r\n\r\n", 4) == 0) break;
}
resposta += 3;
receive = resposta;
Serial.print(receive);
Serial.print("\n\r");
Then the esp don't receive the answer, but the Node.js send strings like a: {QTD1LAMP, ON}
I don't know what is the problem with my code. Using ESP8266 with Arduino Mega