Created
January 23, 2017 03:15
-
-
Save n0bisuke/ab1bb5124115fbb68e4e0b396ff82044 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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