2020-05-20 02:16:23 +02:00
|
|
|
#ifdef push_enable
|
2020-02-10 01:06:18 +03:00
|
|
|
void pushControl() {
|
|
|
|
|
|
|
|
|
|
String title = sCmd.next();
|
|
|
|
|
title.replace("#", " ");
|
|
|
|
|
String body = sCmd.next();
|
|
|
|
|
body.replace("#", " ");
|
|
|
|
|
|
|
|
|
|
static String body_old;
|
|
|
|
|
|
|
|
|
|
const char* logServer = "api.pushingbox.com";
|
2020-06-11 22:51:34 +02:00
|
|
|
String deviceId = jsonReadStr(configSetupJson, "pushingboxid");
|
2020-02-10 01:06:18 +03:00
|
|
|
|
|
|
|
|
Serial.println("- starting client");
|
|
|
|
|
|
2020-04-22 20:35:50 +02:00
|
|
|
WiFiClient client_push;
|
2020-02-10 01:06:18 +03:00
|
|
|
|
|
|
|
|
Serial.println("- connecting to pushing server: " + String(logServer));
|
2020-04-25 16:39:36 +02:00
|
|
|
if (!client_push.connect(logServer, 80)) {
|
|
|
|
|
Serial.println("- not connected");
|
|
|
|
|
} else {
|
2020-02-10 01:06:18 +03:00
|
|
|
Serial.println("- succesfully connected");
|
|
|
|
|
|
|
|
|
|
String postStr = "devid=";
|
|
|
|
|
postStr += String(deviceId);
|
|
|
|
|
|
|
|
|
|
postStr += "&title=";
|
|
|
|
|
postStr += String(title);
|
|
|
|
|
|
|
|
|
|
postStr += "&body=";
|
|
|
|
|
postStr += String(body);
|
|
|
|
|
|
|
|
|
|
postStr += "\r\n\r\n";
|
|
|
|
|
|
|
|
|
|
Serial.println("- sending data...");
|
|
|
|
|
|
2020-04-22 20:35:50 +02:00
|
|
|
client_push.print("POST /pushingbox HTTP/1.1\n");
|
|
|
|
|
client_push.print("Host: api.pushingbox.com\n");
|
|
|
|
|
client_push.print("Connection: close\n");
|
|
|
|
|
client_push.print("Content-Type: application/x-www-form-urlencoded\n");
|
|
|
|
|
client_push.print("Content-Length: ");
|
|
|
|
|
client_push.print(postStr.length());
|
|
|
|
|
client_push.print("\n\n");
|
|
|
|
|
client_push.print(postStr);
|
2020-02-10 01:06:18 +03:00
|
|
|
}
|
2020-04-22 20:35:50 +02:00
|
|
|
client_push.stop();
|
2020-02-10 01:06:18 +03:00
|
|
|
Serial.println("- stopping the client");
|
|
|
|
|
}
|
2020-05-20 02:16:23 +02:00
|
|
|
#endif
|