it keeps failing and failing and failing.
Arduino YUN i have this code. It has to go to a site and get a value "reboot" if the value "reboot" found it does the action, if "reboot" not then do nothing else.
Sometimes the reboot command is working, but its not always working, which is making me sad.
Does anyone know why is my code not working?
#include <Bridge.h>
#include <HttpClient.h>
String result = String("");
void setup() {
delay(5000);
pinMode(2, OUTPUT);
Bridge.begin();
digitalWrite(2, HIGH);
}
void loop() {
HttpClient client;
// PIN 2
client.get("http://www.example.com/output.php?value=reboot");// output.php outputs the value reboot and the reset the value to empty string. after 10 second php puts the value to reboot and then put the value to empty.
result = "";
while (client.available()) {
char c = client.read();
result = result + c;
}
if(result.indexOf("reboot") >= 0) {// this keeps failing, sometime working and sometime not working
digitalWrite(2, LOW);
delay(3000);
digitalWrite(2, HIGH);
}
delay(7000);
}