This repository was archived by the owner on Jan 21, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +19
-13
lines changed Expand file tree Collapse file tree 4 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 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
1215void 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
Original file line number Diff line number Diff line change 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
7780void 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+ }
Original file line number Diff line number Diff line change 11name =CayenneLPPDecode
2- version =1.0
2+ version =1.0.2
33author =Luiz Henrique Cassettari & The Things Network
44maintainer =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 .
77category =Communication
88url =https://github.com/ricaun/CayenneLPPDecode
99architectures =*
Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments