Im работает над проектом с Arduino и Ethernet Shield.Выполнение скрипта PHP с помощью Arduino и Ethernet Shield
Я хотел бы выполнить скрипт php (находящийся на моем сервере) в цикле.
#include <SPI.h>
#include <Ethernet.h>
// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,77); // IP address, may need to change depending on network
EthernetServer server(80); // create a server at port 80
String HTTP_req; // stores the HTTP request
void setup()
{
Ethernet.begin(mac, ip); // initialize Ethernet device
server.begin(); // start to listen for clients
Serial.begin(9600); // for diagnostics
}
void loop()
{
EthernetClient client = server.available(); // try to get client
if (client) { // got client?
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) { // client data available to read
char c = client.read(); // read 1 byte (character) from client
HTTP_req += c; // save the HTTP request 1 char at a time
Serial.print("connected");
client.println("GET http://domain.com/arduino/scripts/script_motion_detection_driveway.php HTTP/1.0");
client.println();
} // end if (client.available())
} // end while (client.connected())
delay(1); // give the web browser time to receive the data
client.stop(); // close the connection
} // end if (client)
}
Когда я запускаю код и загрузить страницу, вместо выполнения сценария он просто печатает строку:
GET http://domain.com/arduino/scripts/script_motion_detection_driveway.php HTTP/1.0
снова и снова ...
Причина ИТС цикл, в отличие от установки, состоит в том, что в конечном итоге запрос GET будет помещен внутри оператора if для проверки состояния.
Что мне нужно изменить для выполнения сценария?