Hi again.
I use WiFiEspAT.h library for comunicate from arduino to esp8266 use AT command on serial1. ESP8266 AT version 1.7.
I modify your code with my library in this mode:
#include <WiFiEspAT.h>
#include <WiFiClient.h>
#include <Pushsafer.h>
// Initialize Wifi connection to the router
char ssid[] = "MySSID"; // your network SSID (name)
char password[] = "MyPSW"; // your network key
// Pushsafer private or alias key
#define PushsaferKey "MyKey"
/*WiFiClientSecure client;*/
WiFiClient client;
Pushsafer pushsafer(PushsaferKey, client);
void setup() {
Serial1.begin(115200);
Serial.begin(115200);
WiFi.init(Serial1);
WiFi.endAP(true);
WiFi.disconnect();
delay(100);
WiFi.setPersistent();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
pushsafer.debug = true;
struct PushSaferInput input;
input.message = "ON";
input.title = "Title" ;
input.sound = "8";
input.vibration = "1";
input.icon = "1";
input.iconcolor = "#FFCCCC";
input.priority = "1";
input.device = "a";
input.url = "
https://www.pushsafer.com";
input.urlTitle = "Open Pushsafer.com";
input.picture = "";
input.picture2 = "";
input.picture3 = "";
input.time2live = "";
input.retry = "";
input.expire = "";
input.answer = "";
Serial.println(pushsafer.sendEvent(input));
Serial.println("Sent");
}
void loop() {
}
In this case on startup i receive always a notification. ok but that's not the way I want to be notified.
I have modified the software according to my needs in this way: when I press the 0 key I send an ON notification. When I press the 1 key I send an off notification.
#include <WiFiEspAT.h>
#include <WiFiClient.h>
#include <Pushsafer.h>
// Initialize Wifi connection to the router
char ssid[] = "MySSID"; // your network SSID (name)
char password[] = "MyPSW"; // your network key
int tasto0 = 3;
int tasto1 = 4;
int StatoTasto0 = 0;
int StatoTasto1 = 0;
// Pushsafer private or alias key
#define PushsaferKey "MyKey"
/*WiFiClientSecure client;*/
WiFiClient client;
Pushsafer pushsafer(PushsaferKey, client);
void setup() {
pinMode(tasto0, INPUT);
pinMode(tasto1, INPUT);
Serial1.begin(115200);
Serial.begin(115200);
WiFi.init(Serial1);
WiFi.endAP(true);
WiFi.disconnect();
delay(100);
WiFi.setPersistent();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
StatoTasto0 = digitalRead(tasto1);
StatoTasto1 = digitalRead(tasto0);
if (StatoTasto0 ==1){
sendpushon();
}else{
StatoTasto0 =0;
}
if (StatoTasto1 ==1){
sendpushoff();
}else{
StatoTasto1 =0;
}
//fine loop
}
void sendpushon(){
pushsafer.debug = true;
struct PushSaferInput input;
input.message = "ON";
input.title = "Title" ;
input.sound = "8";
input.vibration = "1";
input.icon = "1";
input.iconcolor = "#FFCCCC";
input.priority = "1";
input.device = "a";
input.url = "
https://www.pushsafer.com";
input.urlTitle = "Open Pushsafer.com";
input.picture = "";
input.picture2 = "";
input.picture3 = "";
input.time2live = "";
input.retry = "";
input.expire = "";
input.answer = "";
Serial.println(pushsafer.sendEvent(input));
//Serial.println("Sent");
}
void sendpushoff(){
pushsafer.debug = true;
struct PushSaferInput input;
input.message = "Off";
input.title = "Title";
input.sound = "8";
input.vibration = "1";
input.icon = "1";
input.iconcolor = "#FFCCCC";
input.priority = "1";
input.device = "a";
input.url = "
https://www.pushsafer.com";
input.urlTitle = "Open Pushsafer.com";
input.picture = "";
input.picture2 = "";
input.picture3 = "";
input.time2live = "";
input.retry = "";
input.expire = "";
input.answer = "";
Serial.println(pushsafer.sendEvent(input));
//Serial.println("Sent");
}
In this case i have a same problems i recive a N( variable) notification and after i recive the error
Connected
Content-Length: 1121
--------------------------b8f610217e83e29b
content-disposition: form-data; name="k"
aJ7cAFtVNbLeFAZ8gyGo
--------------------------b8f610217e83e29b
content-disposition: form-data; name="m"
Off
--------------------------b8f610217e83e29b
content-disposition: form-data; name="d"
a
--------------------------b8f610217e83e29b
content-disposition: form-data; name="s"
8
--------------------------b8f610217e83e29b
content-disposition: form-data; name="v"
1
--------------------------b8f610217e83e29b
content-disposition: form-data; name="i"
1
--------------------------b8f610217e83e29b
content-disposition: form-data; name="c"
#FFCCCC
--------------------------b8f610217e83e29b
content-disposition: form-data; name="t"
Title
--------------------------b8f610217e83e29b
content-disposition: form-data; name="u"
https://www.pushsafer.com
--------------------------b8f610217e83e29b
content-disposition: form-data; name="ut"
Open Pushsafer.com
--------------------------b8f610217e83e29b
content-disposition: form-data; name="pr"
1
--------------------------b8f610217e83e29b--
response
response
response
course,
- that short error messages are censored by default.
- IIS always returns error messages that are long
- enough to make Internet Explorer happy. The
- workaround is pretty simple: pad the error
- message with a big comment like this to push it
- over the five hundred and twelve bytes minimum.
- Of course, that's exactly what you're reading
- right now.
-->
course,
- that short error messages are censored by default.
- IIS always returns error messages that are long
- enough to make Internet Explorer happy. The
- workaround is pretty simple: pad the error
- message with a big comment like this to push it
- over the five hundred and twelve bytes minimum.
- Of course, that's exactly what you're reading
- right now.
-->
I don't understand if it's a problem with my simple software. A programming error or something else