Skip to content

Commit

Permalink
Add ArduinoJson 6.x.x compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
gmag11 committed Apr 30, 2019
1 parent d01b0a2 commit 03c8284
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ Please check examples folder into repository source code.

In order to use **CayenneLPPdec** You will need these two libraries:

- [ArduinoJSON](https://arduinojson.org). (Please use version < 6.0.0)
- [ArduinoJSON](https://arduinojson.org). (Please use version > 6.10.0)
- [CayenneLPP encoder library](https://github.com/sabas1080/CayenneLPP) for data type definition.
6 changes: 3 additions & 3 deletions examples/CayenneLPPdec_test/CayenneLPPdec_test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ void setup () {
Serial.printf ("LPP Buffer: %s\n\n", printHexBuffer (buffer, len));

// Create a Json buffer big enough. You can use https://arduinojson.org/v5/assistant/ to do a calculation
StaticJsonBuffer<512> jsonBuffer;
StaticJsonDocument<512> jsonBuffer;

// Create an array to parse data to
JsonArray& root = jsonBuffer.createArray ();
JsonArray root = jsonBuffer.createNestedArray();

// Call parser
CayenneLPPDec::ParseLPP (buffer, len, root);

// Print JSON data to serial
root.prettyPrintTo (Serial);
serializeJsonPretty (root, Serial);

}

Expand Down
12 changes: 6 additions & 6 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "CayenneLPPdec",
"frameworks": "arduino",
"version": "0.1.2",
"version": "0.2.0",
"keywords": "sensor, comm, communication, packing, lpp, cayenne, cayennelpp",
"platforms": "*",
"license": "MIT",
"dependencies" :
[{
"name": "ArduinoJson",
"authors": "Benoit Blanchon",
"version": "^5.13.4"
"version": "^6.10.1"
},
{
"name": "CayenneLPP",
Expand All @@ -23,10 +23,10 @@
"name": "Germán Martín",
"email": "gmag11@gmail.com"
},
{
"name": "gizmocuz",
"url": "https://github.com/gizmocuz"
}],
{
"name": "gizmocuz",
"url": "https://github.com/gizmocuz"
}],
"repository":
{
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=CayenneLPPdec
version=0.1.2
version=0.2.0
author=German Martin
maintainer=gizmocuz,German Martin
sentence=CayenneLPP data decoder
Expand Down
26 changes: 13 additions & 13 deletions src/CayenneLPPDec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool CayenneLPPDec::ParseLPP (const uint8_t *pBuffer, size_t Len, JsonArray& roo
if (Len < LPP_DIGITAL_INPUT_SIZE)
return false;

JsonObject& data = root.createNestedObject ();
JsonObject data = root.createNestedObject ();
data["channel"] = channel;
data["type"] = "digital_input";
data["value"] = pBuffer[2];
Expand All @@ -70,7 +70,7 @@ bool CayenneLPPDec::ParseLPP (const uint8_t *pBuffer, size_t Len, JsonArray& roo
if (Len < LPP_DIGITAL_OUTPUT_SIZE)
return false;

JsonObject& data = root.createNestedObject ();
JsonObject data = root.createNestedObject ();
data["channel"] = channel;
data["type"] = "digital_output";
data["value"] = pBuffer[2];
Expand All @@ -81,7 +81,7 @@ bool CayenneLPPDec::ParseLPP (const uint8_t *pBuffer, size_t Len, JsonArray& roo
if (Len < LPP_ANALOG_INPUT_SIZE)
return false;

JsonObject& data = root.createNestedObject ();
JsonObject data = root.createNestedObject ();
data["channel"] = channel;
data["type"] = "analog_input";

Expand All @@ -94,7 +94,7 @@ bool CayenneLPPDec::ParseLPP (const uint8_t *pBuffer, size_t Len, JsonArray& roo
if (Len < LPP_ANALOG_OUTPUT_SIZE)
return false;

JsonObject& data = root.createNestedObject ();
JsonObject data = root.createNestedObject ();
data["channel"] = channel;
data["type"] = "analog_output";

Expand All @@ -107,7 +107,7 @@ bool CayenneLPPDec::ParseLPP (const uint8_t *pBuffer, size_t Len, JsonArray& roo
if (Len < LPP_LUMINOSITY_SIZE)
return false;

JsonObject& data = root.createNestedObject ();
JsonObject data = root.createNestedObject ();
data["channel"] = channel;
data["type"] = "luminosity";

Expand All @@ -120,7 +120,7 @@ bool CayenneLPPDec::ParseLPP (const uint8_t *pBuffer, size_t Len, JsonArray& roo
if (Len < LPP_PRESENCE_SIZE)
return false;

JsonObject& data = root.createNestedObject ();
JsonObject data = root.createNestedObject ();
data["channel"] = channel;
data["type"] = "presence";

Expand All @@ -132,7 +132,7 @@ bool CayenneLPPDec::ParseLPP (const uint8_t *pBuffer, size_t Len, JsonArray& roo
if (Len < LPP_TEMPERATURE_SIZE)
return false;

JsonObject& data = root.createNestedObject ();
JsonObject data = root.createNestedObject ();
data["channel"] = channel;
data["type"] = "temp";

Expand All @@ -145,7 +145,7 @@ bool CayenneLPPDec::ParseLPP (const uint8_t *pBuffer, size_t Len, JsonArray& roo
if (Len < LPP_RELATIVE_HUMIDITY_SIZE)
return false;

JsonObject& data = root.createNestedObject ();
JsonObject data = root.createNestedObject ();
data["channel"] = channel;
data["type"] = "humidity";

Expand All @@ -158,7 +158,7 @@ bool CayenneLPPDec::ParseLPP (const uint8_t *pBuffer, size_t Len, JsonArray& roo
if (Len < LPP_ACCELEROMETER_SIZE)
return false;

JsonObject& data = root.createNestedObject ();
JsonObject data = root.createNestedObject ();
data["channel"] = channel;
data["type"] = "accel";

Expand All @@ -178,7 +178,7 @@ bool CayenneLPPDec::ParseLPP (const uint8_t *pBuffer, size_t Len, JsonArray& roo
if (Len < LPP_BAROMETRIC_PRESSURE_SIZE)
return false;

JsonObject& data = root.createNestedObject ();
JsonObject data = root.createNestedObject ();
data["channel"] = channel;
data["type"] = "baro";

Expand All @@ -191,7 +191,7 @@ bool CayenneLPPDec::ParseLPP (const uint8_t *pBuffer, size_t Len, JsonArray& roo
if (Len < LPP_UNIXTIME_SIZE)
return false;

JsonObject& data = root.createNestedObject ();
JsonObject data = root.createNestedObject ();
data["channel"] = channel;
data["type"] = "unixtime";

Expand All @@ -204,7 +204,7 @@ bool CayenneLPPDec::ParseLPP (const uint8_t *pBuffer, size_t Len, JsonArray& roo
if (Len < LPP_GYROMETER_SIZE)
return false;

JsonObject& data = root.createNestedObject ();
JsonObject data = root.createNestedObject ();
data["channel"] = channel;
data["type"] = "gyro";

Expand All @@ -224,7 +224,7 @@ bool CayenneLPPDec::ParseLPP (const uint8_t *pBuffer, size_t Len, JsonArray& roo
if (Len < LPP_GPS_SIZE)
return false;

JsonObject& data = root.createNestedObject ();
JsonObject data = root.createNestedObject ();
data["channel"] = channel;
data["type"] = "gps";

Expand Down

0 comments on commit 03c8284

Please sign in to comment.