Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit 4ee7439

Browse files
committed
ArduinoJson V6
Update library to suport ArduinoJson version 6
1 parent d888fb1 commit 4ee7439

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

examples/Decode/Decode.ino

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
44
This code create a CayenneLPP package and decode to Json.
55
6+
Updated:
7+
02-04-2019 - Update to ArduinoJson v6
8+
69
created 18 October 2018
710
by Luiz H. Cassettari
811
*/
912

1013
#include <CayenneLPPDecode.h>
1114

1215
void setup() {
13-
DynamicJsonBuffer jsonBuffer;
16+
DynamicJsonDocument jsonBuffer(512);
1417
CayenneLPP lpp(64);
1518
CayenneLPPDecode lppd;
1619

17-
JsonObject& root = jsonBuffer.createObject();
20+
JsonObject root = jsonBuffer.to<JsonObject>();
1821

1922
Serial.begin(115200);
2023
Serial.println();
@@ -36,7 +39,7 @@ void setup() {
3639
lppd.write(lpp.getBuffer(), lpp.getSize());
3740

3841
lppd.decode(root);
39-
root.prettyPrintTo(Serial);
42+
serializeJsonPretty(root ,Serial);
4043
Serial.println();
4144
}
4245

examples/DecodeLoRaDuplex/DecodeLoRaDuplex.ino

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
1010
You need two devices to test this example.
1111
12+
Updated:
13+
02-04-2019 - Update to ArduinoJson v6
14+
1215
created 18 October 2018
1316
by Luiz H. Cassettari
1417
*/
@@ -76,10 +79,10 @@ void LoRa_sendMessage() {
7679

7780
void onReceive(int packetSize) {
7881

79-
DynamicJsonBuffer jsonBuffer;
82+
DynamicJsonDocument jsonBuffer(512);
8083
CayenneLPPDecode lppd;
8184

82-
JsonObject& root = jsonBuffer.createObject();
85+
JsonObject root = jsonBuffer.to<JsonObject>();
8386

8487
while (LoRa.available()) {
8588
lppd.write(LoRa.read());
@@ -90,7 +93,7 @@ void onReceive(int packetSize) {
9093
Serial.print("Receive: ");
9194
Serial.println();
9295

93-
root.prettyPrintTo(Serial);
96+
serializeJsonPretty(root ,Serial);
9497
Serial.println();
9598
}
9699

@@ -104,4 +107,4 @@ boolean runEvery(unsigned long interval)
104107
return true;
105108
}
106109
return false;
107-
}
110+
}

library.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=CayenneLPPDecode
2-
version=1.0
2+
version=1.0.2
33
author=Luiz Henrique Cassettari & The Things Network
44
maintainer=Luiz Henrique Cassettari <ricaun@gmail.com>
5-
sentence=Cayenne LPP Decode Library.
6-
paragraph=Cayenne LPP Decode Library.
5+
sentence=Decode CayenneLPP to Json format as TTN.
6+
paragraph=Library to deode CayenneLPP payload data to Json(ArduinoJson), the json field name was based on The Things Network payload format Cayenne LPP.
77
category=Communication
88
url=https://github.com/ricaun/CayenneLPPDecode
99
architectures=*

src/CayenneLPPDecode.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void CayenneLPPDecode::decode(JsonObject &_root)
132132
break;
133133
case LPP_ACCELEROMETER:
134134
{
135-
JsonObject &json = root.createNestedObject(s);
135+
JsonObject json = root.createNestedObject(s);
136136
json[F("x")] = read16() / 1000.0f;
137137
json[F("y")] = read16() / 1000.0f;
138138
json[F("z")] = read16() / 1000.0f;
@@ -143,15 +143,15 @@ void CayenneLPPDecode::decode(JsonObject &_root)
143143
break;
144144
case LPP_GYROMETER:
145145
{
146-
JsonObject &json = root.createNestedObject(s);
146+
JsonObject json = root.createNestedObject(s);
147147
json[F("x")] = read16() / 100.0f;
148148
json[F("y")] = read16() / 100.0f;
149149
json[F("z")] = read16() / 100.0f;
150150
break;
151151
}
152152
case LPP_GPS:
153153
{
154-
JsonObject &json = root.createNestedObject(s);
154+
JsonObject json = root.createNestedObject(s);
155155
json[F("latitude")] = read24() / 10000.0f;
156156
json[F("longitude")] = read24() / 10000.0f;
157157
json[F("altitude")] = read24() / 100.0f;

0 commit comments

Comments
 (0)