Created
February 21, 2017 20:58
-
-
Save download13/a393b5d952ad988e3c67dfe833c8860c 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 "easypush.h" | |
#include <ESP8266WiFi.h> | |
#include <WiFiClientSecure.h> | |
#define WIFI_SSID "" | |
#define WIFI_KEY "" | |
#define HOST "easypush.erindachtler.me" | |
#define PATH "/notify/GI0eafKjLYh3NzuY" | |
void sendDoneNotification() { | |
WiFi.begin(WIFI_SSID, WIFI_KEY); | |
while((WiFi.status() != WL_CONNECTED)) { | |
delay(100); | |
} | |
WiFiClientSecure client; | |
if(!client.connect(HOST, 443)) { | |
Serial.println("connection failed"); | |
return; | |
} | |
client.print( | |
String("POST ") + PATH + " HTTP/1.1\r\n" + | |
"Host: " + HOST + "\r\n" + | |
"User-Agent: ESP8266\r\n" + | |
"Content-Type: application/x-www-form-urlencoded\r\n" + | |
"Content-Length: 9\r\n" + | |
"Connection: close\r\n\r\n" + | |
"text=Done" | |
); | |
while(client.connected()) { | |
String line = client.readStringUntil('\n'); | |
if(line == "\r") { | |
Serial.println("headers received"); | |
break; | |
} | |
} | |
String line = client.readStringUntil('\n'); | |
Serial.println("reply was:"); | |
Serial.println("=========="); | |
Serial.println(line); | |
Serial.println("=========="); | |
Serial.println("closing connection"); | |
client.stop(); | |
WiFi.disconnect(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment