Skip to content

Instantly share code, notes, and snippets.

@n0bisuke
Created January 23, 2017 03:15
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 n0bisuke/ab1bb5124115fbb68e4e0b396ff82044 to your computer and use it in GitHub Desktop.
Save n0bisuke/ab1bb5124115fbb68e4e0b396ff82044 to your computer and use it in GitHub Desktop.
#include <Nefry.h>
bool httpRequest(String data="");
char *url = "nhzcuyokdz.localtunnel.me";
void setup() {
Nefry.println("Nefry Setup");
}
void loop() {
Nefry.setLed(0, 0, 0);
if(Nefry.push_SW()) {//SWを押した
if(httpRequest("n0bisuke")){
Nefry.println("OK");
Nefry.setLed(0, 255, 255);//成功、水色点灯
}else{
Nefry.println("Err");
Nefry.setLed(255, 0, 0);//失敗、赤色点灯
}
}
Nefry.ndelay(2000);
}
bool httpRequest(String data) {
WiFiClient client;
if (client.connect(url, 80)) {
Nefry.println("connection");
client.println("POST /ovlhtdov HTTP/1.1");
client.print("Host: ");
client.println(url);
client.print("Connection: close\n");
client.println("Content-Type: application/x-www-form-urlencoded");
client.println("User-Agent: Nefry/2.0");
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.println(data);
delay(10);
return true;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment