Page 2 of 2

Re: smart error messages

Posted: 20. Dec 2019, 21:19
by alecasto
Hi again,
i have install the la version with upgrade from https://github.com/appzer/pushsafer-ard ... hsafer.cpp
i re-compile and upload on arduino but
first sent ok
22:12:46.104 -> Sent
second sent not work, only "Response" for many row is missing i received directly this:
22:13:35.212 -> eans, of course,
22:13:35.212 -> - that short error messages are censored by default.
22:13:35.212 -> - IIS always returns error messages that are long
22:13:35.212 -> - enough to make Internet Explorer happy. The
22:13:35.212 -> - workaround is pretty simple: pad the error
22:13:35.212 -> - message with a big comment like this to push it
22:13:35.247 -> - over the five hundred and twelve bytes minimum.
22:13:35.247 -> - Of course, that's exactly what you're reading
22:13:35.247 -> - right now.
22:13:35.247 -> -

Re: smart error messages

Posted: 20. Dec 2019, 22:24
by admin
please use this to send you messages. I disabled the debug mode and comment out all lines that print to serial.
now you should get no errors! if you get errors, then they do not come through the Pushsafer scripts

Code: Select all

#include <ESP8266WiFi.h>
/*#include <WiFiClientSecure.h>*/
#include <WiFiClient.h>
#include <Pushsafer.h>

// Initialize Wifi connection to the router
char ssid[] = "ssid";     // your network SSID (name)
char password[] = "password"; // your network key

// Pushsafer private or alias key
#define PushsaferKey "XXXXXXXXXXXXX"

/*WiFiClientSecure client;*/
WiFiClient client;
Pushsafer pushsafer(PushsaferKey, client);

void setup() {
  Serial.begin(115200);

  // Set WiFi to station mode and disconnect from an AP if it was Previously
  // connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  // Attempt to connect to Wifi network:
  //Serial.print("Connecting Wifi: ");
  //Serial.println(ssid);
  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 = false;

  // Take a look at the Pushsafer.com API at
  // https://www.pushsafer.com/en/pushapi
  
  struct PushSaferInput input;
  input.message = "This is a test message";
  input.title = "Hello!";
  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() {
}

Re: smart error messages

Posted: 22. Dec 2019, 12:42
by alecasto
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

Re: smart error messages

Posted: 22. Dec 2019, 13:50
by alecasto
Hi again,
i test my routine add a the end command client.stop();. In this moment work perfectly. it's correct solution?
void sendpushon() {
pushsafer.debug = true;
struct PushSaferInput input;
input.message = "On";
input.title = "Title";
input.sound = "3";
input.vibration = "3";
input.icon = "27";
input.iconcolor = "#007FFF";
input.priority = "2";
input.device = "a";
input.url = "";
input.urlTitle = "";
input.picture = "";
input.picture2 = "";
input.picture3 = "";
input.time2live = "";
input.retry = "";
input.expire = "";
input.answer = "0";
Serial.println(pushsafer.sendEvent(input));
//Serial.println("Sent");
//sent = true;
client.stop();
}

Re: smart error messages

Posted: 22. Dec 2019, 16:49
by admin
i'm not an arduino developer so it didn't know!

it works for you , who cares

Re: smart error messages

Posted: 22. Dec 2019, 22:03
by alecasto
Hi,
who cares? Hope it helps other users with the same problem.
I confirm that the system works but I spent around 500 of my payed api for trying to find a solution.
I Hope you can add this solution in a change log or API information or arduino example.
Thank you for your support.
Alessandro.