我不响应 GET 请求,从 ESP8266 + Arduino Mega 发送到 Node.js。我在节点中的代码收到了请求,但我在 Arduino 代码中什么也没得到。
节点.js
app.get('/StatusSaidas', function(req,res){
res.charset = 'UTF-8';
console.log('Send to Arduino: ' + statusArdu);
res.send(statusArdu);
});
来自 Node.js 的控制台日志
Arduino中的代码
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");
我不知道我的代码有什么问题。我将 ESP8266 与 Arduino Mega 一起使用