방에있는 인/아웃을 계산하고 내 데이터베이스에 업로드하기 만하면됩니다. 내 서버에 Communicator로 ESP8266과 함께 Arduino MEGA2560을 사용하고 있습니다.Http GET request non blocking Arduino
하지만 내 서버에서 HTTP GET 요청을 보낼 때 문제가 있습니다. 일단 HTTP GET 요청을 보내면 HTTP GET 요청이 완료 될 때까지 카운터 기능이 작동하지 않습니다. Arduino에서 비동기 함수가 사용하기 쉽고 서 있을지 궁금하거나 HTTP GET 요청을 사용하는 올바른 방법이 있습니까?
void loop{
counter(); // let's assume that this function is just counting in and out person in the room
// changing the value of variable count
uint8_t buffer[1024] = {0};
if (wifi.createTCP(HOST_NAME, HOST_PORT)) {
Serial.print("create tcp ok\r\n");
} else {
Serial.print("create tcp err\r\n");
}
char hello[];
strcpy(hello, "GET /vbus/insert.php?coount=");
strcat(hello, count);
strcat(hello," HTTP/1.1\r\nHost: www.test.com\r\nConnection:close\r\n\r\n");
wifi.send((const uint8_t*)hello, strlen(hello));
wifi.send((const uint8_t*)hello, strlen(hello));
uint32_t len = wifi.recv(buffer, sizeof(buffer), 10000);
if (len > 0) {
Serial.print("Received:[");
for(uint32_t i = 0; i < len; i++) {
Serial.print((char)buffer[i]);
}
Serial.print("]\r\n");
}
}
PS :
여기 내 코드의 나는 내가 말한 위의 단지 하나의 HTTP GET 요청을 전송 문제가 없습니다.
esp8266에서 arduino fw를 사용하고 있습니까? 질문에 arduino-esp8266 태그가 있습니다. – cagdas
내가 arduino를 esp8266과 함께 사용하고 있는데, 내 태그가 잘못되어 있으면 나를 수정하십시오. – zxcetera
아니요, 문제 없습니다. esp8266에서 arduino fw를 사용하려고합니다. – cagdas