Skip to content

Instantly share code, notes, and snippets.

@wgbartley wgbartley/uptime.ino
Created May 26, 2014

Embed
What would you like to do?
Spark Uptime Test
char srvIP[] = "198.199.86.22";
char srvHost[] = "spark.wgb.me";
int srvPort = 80;
char srvPath[] = "/logger/?l=uptime-test";
void setup() {
delay(5000);
pinMode(D7, OUTPUT);
RGB.control(true);
RGB.color(0, 0, 0);
}
void loop() {
httpGetRequest(srvIP, srvHost, srvPort, srvPath);
Spark.sleep(60);
}
void httpGetRequest(char* ip, char* hostname, int port, char* url) {
digitalWrite(D7, HIGH);
char line[255];
TCPClient client;
if(client.connect(ip, port)) {
strcpy(line, "GET ");
strcat(line, url);
strcat(line, " HTTP/1.1");
client.println(line);
delay(100);
strcpy(line, "Host: ");
strcat(line, hostname);
client.println(line);
delay(100);
strcpy(line, "Content-Length: 0");
client.println(line);
delay(100);
client.println();
delay(100);
client.flush();
delay(100);
client.stop();
delay(250);
}
digitalWrite(D7, LOW);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.