Skip to content

Instantly share code, notes, and snippets.

@download13
Created February 21, 2017 20:58
Show Gist options
  • Save download13/a393b5d952ad988e3c67dfe833c8860c to your computer and use it in GitHub Desktop.
Save download13/a393b5d952ad988e3c67dfe833c8860c to your computer and use it in GitHub Desktop.
#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