From 3fdcdd6a3e8491b2c80bbc58d2d31ea35a453feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Miko=C4=8Devi=C4=87?= Date: Fri, 29 Nov 2024 23:25:29 +0100 Subject: [PATCH] ArduinoJson 5->7 (#141) * ArduinoJson 5->7 * fix small typo in README.md enabaled -> enabled --- README.md | 2 +- example/OOK_Receiver/OOK_Receiver.ino | 13 +++++++------ example/OOK_Receiver/platformio.ini | 6 +++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4e714588..a02d49ef 100644 --- a/README.md +++ b/README.md @@ -342,7 +342,7 @@ DEVICE_DEBUG ; Validate fields are mapped to response object ( rtl_433 MEMORY_DEBUG ; display heap usage information RESOURCE_DEBUG : Monitor HEAP and STACK usage and report large jumps MY_DEVICES ; Only include my personal subset of devices -NO_DEAF_WORKAROUND ; Workaround for issue #16 ( by default the workaround is enabaled ) +NO_DEAF_WORKAROUND ; Workaround for issue #16 ( by default the workaround is enabled ) PUBLISH_UNPARSED ; Enable publishing of MQTT messages for unparsed signals, e.g. {model":"unknown","protocol":"signal parsing failed"… RAW_SIGNAL_DEBUG ; display raw received messages RSSI_SAMPLES ; Number of rssi samples to collect for average calculation, defaults to 50,000 diff --git a/example/OOK_Receiver/OOK_Receiver.ino b/example/OOK_Receiver/OOK_Receiver.ino index 7be5f3fb..7f780293 100644 --- a/example/OOK_Receiver/OOK_Receiver.ino +++ b/example/OOK_Receiver/OOK_Receiver.ino @@ -20,19 +20,20 @@ rtl_433_ESP rf; // use -1 to disable transmitter int count = 0; void rtl_433_Callback(char* message) { - DynamicJsonBuffer jsonBuffer2(JSON_MSG_BUFFER); - JsonObject& RFrtl_433_ESPdata = jsonBuffer2.parseObject(message); - logJson(RFrtl_433_ESPdata); + JsonDocument jsonDocument; + deserializeJson(jsonDocument,message); + logJson(jsonDocument); count++; } -void logJson(JsonObject& jsondata) { +void logJson(JsonDocument jsondata) { #if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) - char JSONmessageBuffer[jsondata.measureLength() + 1]; + char JSONmessageBuffer[measureJson(jsondata) + 1]; + serializeJson(jsondata, JSONmessageBuffer, measureJson(jsondata) + 1); #else char JSONmessageBuffer[JSON_MSG_BUFFER]; + serializeJson(jsondata, JSONmessageBuffer, JSON_MSG_BUFFER); #endif - jsondata.printTo(JSONmessageBuffer, sizeof(JSONmessageBuffer)); #if defined(setBitrate) || defined(setFreqDev) || defined(setRxBW) Log.setShowLevel(false); Log.notice(F(".")); diff --git a/example/OOK_Receiver/platformio.ini b/example/OOK_Receiver/platformio.ini index 4d8e69ff..726bb1da 100644 --- a/example/OOK_Receiver/platformio.ini +++ b/example/OOK_Receiver/platformio.ini @@ -15,7 +15,11 @@ src_dir = . [libraries] arduinolog = https://github.com/1technophile/Arduino-Log.git#d13cd80 -arduinojson = ArduinoJson@5.13.4 +arduinojson = + ArduinoJson + ; ArduinoJson @ 7.0.4 + ; ArduinoJson @ 6.21.5 + ; ArduinoJson @ 5.13.4 ; deprecated rtl_433_ESP = symlink://../../../rtl_433_ESP ; Builds library from source directory [env]