MKR1010 Push

Pushsafer make it easy and safe to get push-notifications in real time on your Android or Windows mobile device, iPhone, iPad and Desktop!

Mit Pushsafer kann man in Echtzeit, einfach und sicher, Push-Benachrichtigungen auf sein iPhone, iPad, Android oder Windows Gerät sowie auf den Desktop senden lassen!

======================
Google Play
App Store
Windows 10 Store
Homepage
jdorm13
Posts: 5
Joined: 20. Nov 2018, 05:07

MKR1010 Push

Postby jdorm13 » 20. Nov 2018, 05:19

I'm trying to get this to work with the MKR1010 using the WiFiNINA library and can't get a message through. I have tried with two different templates. They both compile and connect, but no message goes through.

Here is the first template:

Code: Select all


#include <Pushsafer.h>
#include <SPI.h>
#include <WiFiNINA.h>

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

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

WiFiClient client;
Pushsafer pushsafer(PushsaferKey, client);

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

//  // 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 = true;

  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";

  // API description: https://www.pushsafer.com/en/pushapi
  // Other optional Options
  // input.url;
  // input.urlTitle;
  // input.picture;
  // input.picture2;
  // input.picture3;
  // input.time2live;
  // input.retry;
  // input.expire;
  // input.answer;

Serial.println(pushsafer.sendEvent(input));
 // pushsafer.sendEvent("Test","PS_test","12","3","62","#FF0000","https://www.pushsafer.com","Open Pushsafer","0","2","60","6000","1","a");
  Serial.println("Sent");
}

void loop() {
}
Here is the second template:

Code: Select all

/*
   Pushsafer.ino
   Pushsafer.com sketch by Appzer.de Kevin Siml 2018-07-04
   Send pushsafer.com messages from the arduino
*/

#include <SPI.h>
#include <WiFiNINA.h>

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

// Pushsafer private or alias key
String privatekey = "xxxx";

int length;

WiFiSSLClient client;

void setup()
{
  Serial.begin(9600);
  
  // 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("It works!!!","Test","1","1","1","#FF0000","https://www.pushsafer.com","Open Pushsafer","0","2","60","6000","1","a");  
 
}

void loop()
{

}

byte pushsafer(char *pushsafermessage, char *pushsafertitle, char *pssound, char *psvibration, char *psicon, char *pscolor, char *psurl, char *psurltitle, char *pstime2live, char *pspriority, char *psretry, char *psexpire, char *psanswer, char *psdevice)
{
  String title = pushsafertitle;
  String message = pushsafermessage;
  String device = psdevice;
  String sound = pssound;
  String vibration = psvibration;
  String icon = psicon;
  String color = pscolor;
  String url = psurl;
  String urltitle = psurltitle;
  String time2live = pstime2live;
  String priority = pspriority;
  String retry = psretry;
  String expire = psexpire;
  String answer = psanswer;

  length = 45 + message.length() + title.length() + sound.length() + vibration.length() + icon.length() + color.length() + url.length() + urltitle.length() + time2live.length() + device.length() + privatekey.length();

  if(client.connect("pushsafer.com",80))
  {
    client.println("POST /api HTTP/1.1");
    client.println("Host: https://www.pushsafer.com");
    client.println("Connection: close\r\nContent-Type: application/x-www-form-urlencoded");
    client.print("Content-Length: ");
    client.print(length);
    client.println("\r\n");;
    client.print("k=");
    client.print(privatekey);
    client.print("&m=");
    client.print(message);
    client.print("&t=");
    client.print(title);  
    client.print("&s=");
    client.print(sound);
    client.print("&v=");
    client.print(vibration);  
    client.print("&i=");
    client.print(icon);
    client.print("&c=");
    client.print(color);
    client.print("&u=");
    client.print(url);
    client.print("&ut=");
    client.print(urltitle);
    client.print("&l=");
    client.print(time2live);
    client.print("&pr=");
    client.print(priority);
    client.print("&re=");
    client.print(retry);
    client.print("&ex=");
    client.print(expire);
    client.print("&a=");
    client.print(answer);
    client.print("&d=");
    client.print(device); 
    while(client.connected())  
    {
      while(client.available())
      {
        char ch = client.read();
        Serial.write(ch);
      }
    }
    client.stop();
  }  
}

User avatar
admin
Site Admin
Posts: 331
Joined: 1. Dec 2014, 12:41
Location: Germany

Re: MKR1010 Push

Postby admin » 20. Nov 2018, 06:27

do you have any error log for me?

Kevin
DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
EN: You like Service and Support! Then we look forward to your review!

Pushsafer.com Website - iOS - Android - Windows 10

jdorm13
Posts: 5
Joined: 20. Nov 2018, 05:07

Re: MKR1010 Push

Postby jdorm13 » 21. Nov 2018, 17:20

admin wrote:
20. Nov 2018, 06:27
do you have any error log for me?

Kevin
Error logs from where? The Arduino doesn't generate any, does PushSafer? It wouldn't have any if the connection was never made.

jdorm13
Posts: 5
Joined: 20. Nov 2018, 05:07

Re: MKR1010 Push

Postby jdorm13 » 21. Nov 2018, 18:06

admin wrote:
20. Nov 2018, 06:27
do you have any error log for me?

Kevin

It doesn't look like it's connecting to the API properly. I can verify it it connects to the network, but I don't get any of the Serial.println outputs defined in Pushsafer.cpp.

User avatar
admin
Site Admin
Posts: 331
Joined: 1. Dec 2014, 12:41
Location: Germany

Re: MKR1010 Push

Postby admin » 21. Nov 2018, 19:48

yes, pushsafer response with a json string discribed in the api: https://www.pushsafer.com/en/pushapi

SUCCESS:

Code: Select all

{
    "status":1,
    "success":"message transmitted",
    "available":1823,
    "message_ids":"1324312:118,1324313:324"
}
ERROR (Example):

Code: Select all

{
    "status":0,
    "error":"invalid key"
}
If you do not get a response, i think you do not have an connection to the internet!

Please refer to this post, and try to get help in a arduino forum!

Kevin
DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
EN: You like Service and Support! Then we look forward to your review!

Pushsafer.com Website - iOS - Android - Windows 10

jdorm13
Posts: 5
Joined: 20. Nov 2018, 05:07

Re: MKR1010 Push

Postby jdorm13 » 23. Nov 2018, 02:09

Here is the console output from the "working example":

Code: Select all

WiFi connected
IP address: 10.0.1.112
Connected
Content-Length: 916
--------------------------b8f610217e83e29b
content-disposition: form-data; name="k"

XXXXXXXXXXXXXXXXXXXX
--------------------------b8f610217e83e29b
content-disposition: form-data; name="m"

This is a test message
--------------------------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"

Hello!
--------------------------b8f610217e83e29b
content-disposition: form-data; name="l"

1
--------------------------b8f610217e83e29b--




Sent

User avatar
admin
Site Admin
Posts: 331
Joined: 1. Dec 2014, 12:41
Location: Germany

Re: MKR1010 Push

Postby admin » 23. Nov 2018, 10:33

OK, but that only the form data!

Do you have an output for to post of this data to the the pushsafer.com API URL.

I think its a problem with the https connction!

Kevin
DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
EN: You like Service and Support! Then we look forward to your review!

Pushsafer.com Website - iOS - Android - Windows 10

jdorm13
Posts: 5
Joined: 20. Nov 2018, 05:07

Re: MKR1010 Push

Postby jdorm13 » 24. Nov 2018, 01:29

Sorry, I don't know what you're asking for. I don't work with HTTP much.

This generates the console output:

Code: Select all

Serial.println(pushsafer.sendEvent(input));
And this is the data sent:

Code: Select all

 pushsafer.debug = true;

  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";
The .cpp and .h files for PushSafer are from https://github.com/appzer/pushsafer-arduino-library

User avatar
admin
Site Admin
Posts: 331
Joined: 1. Dec 2014, 12:41
Location: Germany

Re: MKR1010 Push

Postby admin » 24. Nov 2018, 14:57

when you send a request to the pushsafer api and the request reach our server correctly, you got a respond from it.

So i think your internet connection or a safe https connection are not present.

To solve this issue you need to get support from an profi in a adurino board.

Kevin
DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
EN: You like Service and Support! Then we look forward to your review!

Pushsafer.com Website - iOS - Android - Windows 10


Who is online

Users browsing this forum: No registered users and 2 guests