Pushafer Arduino error

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
norris2022
Posts: 2
Joined: 11. Nov 2021, 11:49

Re: Pushafer Arduino error

Postby norris2022 » 11. Nov 2021, 11:57

Hey.
After a lot of mucking around and half from the content in this thread, I have mine working.

viewtopic.php?f=24&t=3215

Please see the code below.

I am using an Arduino UNO with PoE Ethernet Shield

Code: Select all

/*
   Pushsafer.ino
   Pushsafer.com sketch by Appzer.de Kevin Siml 2016-08-08
   Send pushsafer.com messages from the arduino
*/
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {0xDE,0xAC,0xBF,0xEF,0xFE,0xAA};

// pushsafer settings
char privatekey[] = "your20characterPrivateKey";
int length;
EthernetClient client;

void setup()
{
  Serial.begin(9600);
  Serial.print(F("Starting ethernet..."));
  if(!Ethernet.begin(mac)) Serial.println("failed");
  else Serial.println(Ethernet.localIP());
  delay(5000);
  Serial.println("Ready");
}

void loop()
{
  pushsafer("It works!!!","Test","1","1","1","a");  
  delay(60000); 
}
byte pushsafer(char *pushsafermessage, char *pushsafertitle, char *pssound, char *psvibration, char *psicon, char *psdevice)
{
  String title = pushsafertitle;
  String message = pushsafermessage;
  String device = psdevice;
  String sound = pssound;
  String vibration = psvibration;
  String icon = psicon;

  length = 41 + message.length() + title.length() + sound.length() + vibration.length() + icon.length() + device.length() + privatekey.length();

  if(client.connect("pushsafer.com",80))
  {
    client.println("POST /api HTTP/1.1");
    client.println("Host: 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("&d=");
    client.print(device); 
    client.print("&retry=60");
    client.print("&expire=3600");
    while(client.connected())  
    {
      while(client.available())
      {
        char ch = client.read();
        Serial.write(ch);
      }
    }
    client.stop();
  }  
}

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

Re: Pushafer Arduino error

Postby admin » 11. Nov 2021, 13:18

thanks for sharing your code.

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

Pushsafer.com Website - iOS - Android - Windows 10

norris2022
Posts: 2
Joined: 11. Nov 2021, 11:49

Re: Pushafer Arduino error

Postby norris2022 » 11. Nov 2021, 15:59

Hi Kevin
I'm now trying to get this code to be run when a button is pushed but I cant figure out how to run the code after an if statement is true, I keep getting the error of " 'push safer' was not declared in this scope."

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

Re: Pushafer Arduino error

Postby admin » 12. Nov 2021, 08:59

sorry, i cant help you.
It's better to ask your question in a arduino board.

Kevin
Pushsafer DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
Pushsafer 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