私はPersonカウンタを作成しています。部屋のIn/Outを数えてデータベースにアップロードするだけです。私はArduino MEGA2560をESP8266で私のサーバーへのコミュニケータとして使用しています。Http GETリクエスト非閉塞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:
はここに私のコードです、私は私が言ったの上にちょうど1つのHTTP GETリクエストを送信して問題ありません。
esp8266でarduino fwを使用していますか? Arduino-esp8266タグがあります。 – cagdas
私はesp8266でarduinoを使用しています。私のタグが間違っていれば私を修正してください:) – zxcetera
いいえ、問題ありません。 esp8266にarduino fwを使用しています – cagdas