Skip to content

Instantly share code, notes, and snippets.

@mrichardson23
Created August 23, 2012 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrichardson23/3436099 to your computer and use it in GitHub Desktop.
Save mrichardson23/3436099 to your computer and use it in GitHub Desktop.
XIG URL Checker
String check(String URL) {
String response = "";
Serial.println();
Serial.print("Connecting to ");
Serial.println(URL);
XBee.println(URL);
requestTime = millis();
while ((XBee.available() == 0) && (millis() - requestTime < responseTimeout))
{
//wait here until we hear something back or timeout
}
if (XBee.available()) { // if we received a response:
Serial.print("Server response: ");
int i = 0;
do {
char c = XBee.read();
Serial.print(c);
response += c;
i++;
delay(1);
} while (XBee.available());
}
else { // we timed out:
Serial.println("\nFailed to get a response.");
response = "ERR";
XBee.println("abort");
delay(1000);
}
Serial.print("\nPassing the value: ");
Serial.println(response);
if (response == "ERR"){
failCount++;
}
else {
failCount = 0;
}
while (XBee.available()) {
XBee.read(); //flush anything else.
}
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment