· 6 years ago · Mar 01, 2020, 11:26 AM
1ENVIANDO NOTIFICAÇÃO COM PUSHSAFER
2
3INSTALAR BIBLIOTECA COMO RAR:
4https://github.com/appzer/pushsafer-arduino-library
5
6Sketch -> Include Library -> Escolher Arquivo
7
8INSTALAR ARDUINO JSON:
9Sketch -> Include Library -> Manage Library -> ArduinoJson By Benoit Blanchon
10
11
12=================================================================================
13=================================================================================
14
15#include <WiFi.h>
16#include <Pushsafer.h>
17
18char ssid[] = "Bruno";
19char password[] = "81290889";
20
21// Pushsafer private or alias key
22#define PushsaferKey "Q5O8ulh5M2gul5DuzP4g"
23
24/*WiFiClientSecure client;*/
25WiFiClient client;
26Pushsafer pushsafer(PushsaferKey, client);
27
28void setup() {
29 Serial.begin(115200);
30
31 // Set WiFi to station mode and disconnect from an AP if it was Previously
32 // connected
33 WiFi.mode(WIFI_STA);
34 WiFi.disconnect();
35 delay(100);
36
37 // Attempt to connect to Wifi network:
38 Serial.print("Connecting Wifi: ");
39 Serial.println(ssid);
40 WiFi.begin(ssid, password);
41
42 while (WiFi.status() != WL_CONNECTED) {
43 Serial.print(".");
44 delay(500);
45 }
46
47 Serial.println("");
48 Serial.println("WiFi connected");
49 Serial.print("IP address: ");
50 Serial.println(WiFi.localIP());
51
52 pushsafer.debug = true;
53
54 // Take a look at the Pushsafer.com API at
55 // https://www.pushsafer.com/en/pushapi
56
57 struct PushSaferInput input;
58 input.message = "This is a test message";
59 input.title = "Hello!";
60 input.sound = "8";
61 input.vibration = "1";
62 input.icon = "1";
63 input.iconcolor = "#FFCCCC";
64 input.priority = "1";
65 input.device = "a";
66 input.url = "https://www.pushsafer.com";
67 input.urlTitle = "Open Pushsafer.com";
68 input.picture = "";
69 input.picture2 = "";
70 input.picture3 = "";
71 input.time2live = "";
72 input.retry = "";
73 input.expire = "";
74 input.answer = "";
75
76 Serial.println(pushsafer.sendEvent(input));
77 Serial.println("Sent");
78
79 // client.stop();
80}
81
82void loop() {
83}