-
Notifications
You must be signed in to change notification settings - Fork 13
/
getServerConfigJSON.ino
37 lines (33 loc) · 1016 Bytes
/
getServerConfigJSON.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <Arduino.h>
#include <MAGELLAN_SIM7600E_MQTT.h>
MAGELLAN_SIM7600E_MQTT magel;
void setup()
{
Serial.begin(115200);
magel.begin();
//{1.} json string
magel.getServerConfigJSON([](String payload){
Serial.print("# Config incoming JSON: ");
Serial.println(payload);
});
//or {2.} json object
// magel.getServerConfigJSON([](JsonObject docObject){
// String buffer = docObject["DELAY"]; // buffer value form config key "DELAY" if not found this key value is "null"
// if(buffer.indexOf("null") == -1)
// {
// Serial.print("# Config incoming JSON Object: ");
// Serial.print("# [Key] => Delay: ");
// Serial.println(buffer);
// }
// });
}
void loop()
{
magel.loop();
magel.subscribes([](){
magel.subscribe.serverConfig(); // subscribe server config content type JSON
});
magel.interval(10,[](){ //time interval function inside every 10000 millis
magel.serverConfig.request(); // request server config content type JSON
});
}