diff --git a/UI.hpp b/UI.hpp index 1ca7524..073629c 100644 --- a/UI.hpp +++ b/UI.hpp @@ -4475,7 +4475,7 @@ void UI_func_load_performance(uint8_t param) mode = 0xff; lcd.setCursor(0, 1); - if (load_sd_performance(configuration.sys.performance_number) == false) + if (load_sd_performance_json(configuration.sys.performance_number) == false) lcd.print("Does not exist."); else { @@ -4580,10 +4580,10 @@ void UI_func_save_performance(uint8_t param) if (yesno == true) { char tmp[FILENAME_LEN]; - sprintf(tmp, "/%s/%s%d.syx", PERFORMANCE_CONFIG_PATH, PERFORMANCE_CONFIG_NAME, configuration.sys.performance_number); + sprintf(tmp, "/%s/%s%d.json", PERFORMANCE_CONFIG_PATH, PERFORMANCE_CONFIG_NAME, configuration.sys.performance_number); SD.remove(tmp); } - save_sd_performance(configuration.sys.performance_number); + save_sd_performance_json(configuration.sys.performance_number); lcd.show(1, 0, 16, "Done."); delay(MESSAGE_WAIT_TIME); LCDML.FUNC_goBackToMenu(); @@ -4603,7 +4603,7 @@ void UI_func_save_performance(uint8_t param) if (mode == 0) { char tmp[FILENAME_LEN]; - sprintf(tmp, "/%s/%s%d.syx", PERFORMANCE_CONFIG_PATH, PERFORMANCE_CONFIG_NAME, configuration.sys.performance_number); + sprintf(tmp, "/%s/%s%d.json", PERFORMANCE_CONFIG_PATH, PERFORMANCE_CONFIG_NAME, configuration.sys.performance_number); if (SD.exists(tmp)) overwrite = true; else diff --git a/config.h b/config.h index d178619..c872f52 100644 --- a/config.h +++ b/config.h @@ -278,7 +278,7 @@ #define MAX_PERFORMANCE 99 #define MAX_VOICECONFIG 99 #define BANK_NAME_LEN 11 // 10 (plus '\0') -#define VOICE_NAME_LEN 11 // 10 (plus '\0') +#define VOICE_NAME_LEN 12 // 11 (plus '\0') #define FILENAME_LEN BANK_NAME_LEN + VOICE_NAME_LEN #define FX_CONFIG_PATH "FXCFG" diff --git a/dexed_sd.cpp b/dexed_sd.cpp index e3373bd..6f2eb04 100644 --- a/dexed_sd.cpp +++ b/dexed_sd.cpp @@ -715,19 +715,146 @@ bool save_sd_performance(uint8_t p) return (false); } -/****************************************************************************** - HELPER FUNCTIONS - ******************************************************************************/ -bool get_sd_data_json(File sysex, uint8_t* conf) +bool load_sd_performance_json(int8_t p) { - return(false); + if (p < 0) + return (false); + + p = constrain(p, 0, MAX_PERFORMANCE); + + if (sd_card > 0) + { + File json; + char filename[FILENAME_LEN]; + + sprintf(filename, "/%s/%s%d.json", PERFORMANCE_CONFIG_PATH, PERFORMANCE_CONFIG_NAME, p); + + // first check if file exists... + AudioNoInterrupts(); + if (SD.exists(filename)) + { + // ... and if: load +#ifdef DEBUG + Serial.print(F("Found performance configuration [")); + Serial.print(filename); + Serial.println(F("]... loading...")); +#endif + json = SD.open(filename); + if (json) + { + StaticJsonDocument<256> data_json; + + deserializeJson(data_json, json); + +#ifdef DEBUG + Serial.println(F("Read JSON data:")); + serializeJsonPretty(data_json, Serial); + Serial.println(); +#endif + for (uint8_t i = 0; i < MAX_DEXED; i++) + { + configuration.performance.bank[i] = data_json["bank"][i]; + configuration.performance.voice[i] = data_json["voice"][i]; + configuration.performance.voiceconfig_number[i] = data_json["voiceconfig_number"][i]; + } + configuration.performance.fx_number = data_json["fx_number"]; + + json.close(); + AudioInterrupts(); + + for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) + { + load_sd_voiceconfig(configuration.performance.voiceconfig_number[instance_id], instance_id); + + MicroDexed[instance_id]->ControllersRefresh(); + MicroDexed[instance_id]->panic(); + } + load_sd_fx(configuration.performance.fx_number); + + return (true); + } +#ifdef DEBUG + else + { + Serial.print(F("E : Cannot open ")); + Serial.print(filename); + Serial.println(F(" on SD.")); + } +#endif + } + else + { +#ifdef DEBUG + Serial.print(F("No ")); + Serial.print(filename); + Serial.println(F(" available.")); +#endif + } + } + return (false); } -bool write_sd_data_json(File sysex, uint16_t len) +bool save_sd_performance_json(uint8_t p) { - return(false); + char filename[FILENAME_LEN]; + + p = constrain(p, 0, MAX_PERFORMANCE); + + if (sd_card > 0) + { + File json; + + sprintf(filename, "/%s/%s%d.json", PERFORMANCE_CONFIG_PATH, PERFORMANCE_CONFIG_NAME, p); + +#ifdef DEBUG + Serial.print(F("Saving performance config as JSON")); + Serial.print(p); + Serial.print(F(" to ")); + Serial.println(filename); +#endif + + AudioNoInterrupts(); + json = SD.open(filename, FILE_WRITE); + if (json) + { + StaticJsonDocument<256> data_json; + + for (uint8_t i = 0; i < MAX_DEXED; i++) + { + data_json["bank"][i] = configuration.performance.bank[i]; + data_json["voice"][i] = configuration.performance.voice[i]; + data_json["voiceconfig_number"][i] = configuration.performance.voiceconfig_number[i]; + } + data_json["fx_number"] = configuration.performance.fx_number; + +#ifdef DEBUG + Serial.println(F("Write JSON data:")); + serializeJsonPretty(data_json, Serial); + Serial.println(); +#endif + serializeJsonPretty(data_json, json); + json.close(); + AudioInterrupts(); + return (true); + } + json.close(); + } + else + { +#ifdef DEBUG + Serial.print(F("E : Cannot open ")); + Serial.print(filename); + Serial.println(F(" on SD.")); +#endif + } + + AudioInterrupts(); + return (false); } +/****************************************************************************** + HELPER FUNCTIONS + ******************************************************************************/ bool get_sd_data(File sysex, uint8_t format, uint8_t* conf) { uint16_t n; diff --git a/dexed_sd.h b/dexed_sd.h index c7924ca..563a837 100644 --- a/dexed_sd.h +++ b/dexed_sd.h @@ -62,11 +62,13 @@ bool save_sd_fx(uint8_t fx); bool load_sd_performance(int8_t p); bool save_sd_performance(uint8_t p); +bool load_sd_performance_json(int8_t p); +bool save_sd_performance_json(uint8_t p); + -bool get_sd_data_json(File sysex, uint8_t* conf); -bool write_sd_data_json(File sysex, uint8_t* data, uint16_t len); bool get_sd_data(File sysex, uint8_t format, uint8_t* conf); bool write_sd_data(File sysex, uint8_t format, uint8_t* data, uint16_t len); + uint8_t calc_checksum(uint8_t* data, uint16_t len); void strip_extension(const char* s, char* target); diff --git a/drums.h b/drums.h index 437c1ac..fbd81df 100644 --- a/drums.h +++ b/drums.h @@ -1,5 +1,10 @@ /* - Copyright (c) 2019-2021 H. Wirtz + MicroDexed + + MicroDexed is a port of the Dexed sound engine + Dexed ist heavily based on https://github.com/google/music-synthesizer-for-android + + (c)2018-2021 H. Wirtz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -181,7 +186,7 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { 0.0, 0.0 }, - { + { DRUM_NONE, 0, "/drm/EMPTY ", diff --git a/third-party/ArduinoJson/CHANGELOG.md b/third-party/ArduinoJson/CHANGELOG.md index 6e1997a..a1bbc5d 100644 --- a/third-party/ArduinoJson/CHANGELOG.md +++ b/third-party/ArduinoJson/CHANGELOG.md @@ -1,6 +1,12 @@ ArduinoJson: change log ======================= +v6.18.3 (2021-07-27) +------- + +* Changed return type of `convertToJson()` and `Converter::toJson()` to `void` +* Added `as()` and `is()` + v6.18.2 (2021-07-19) ------- diff --git a/third-party/ArduinoJson/CMakeLists.txt b/third-party/ArduinoJson/CMakeLists.txt index ef91e23..b83a318 100644 --- a/third-party/ArduinoJson/CMakeLists.txt +++ b/third-party/ArduinoJson/CMakeLists.txt @@ -11,7 +11,7 @@ if(ESP_PLATFORM) return() endif() -project(ArduinoJson VERSION 6.18.2) +project(ArduinoJson VERSION 6.18.3) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(CTest) diff --git a/third-party/ArduinoJson/README.md b/third-party/ArduinoJson/README.md index 319469b..a9dfbc7 100644 --- a/third-party/ArduinoJson/README.md +++ b/third-party/ArduinoJson/README.md @@ -2,7 +2,7 @@ --- -[![arduino-library-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.18.2)](https://www.ardu-badge.com/ArduinoJson/6.18.2) +[![arduino-library-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.18.3)](https://www.ardu-badge.com/ArduinoJson/6.18.3) [![Continuous Integration](https://github.com/bblanchon/ArduinoJson/workflows/Continuous%20Integration/badge.svg?branch=6.x)](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A6.x) [![Continuous Integration](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/6.x?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/arduinojson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) diff --git a/third-party/ArduinoJson/appveyor.yml b/third-party/ArduinoJson/appveyor.yml index 6ff755a..08c8db4 100644 --- a/third-party/ArduinoJson/appveyor.yml +++ b/third-party/ArduinoJson/appveyor.yml @@ -1,4 +1,4 @@ -version: 6.18.2.{build} +version: 6.18.3.{build} environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 diff --git a/third-party/ArduinoJson/extras/scripts/get-release-page.sh b/third-party/ArduinoJson/extras/scripts/get-release-page.sh index 73d073b..2acb8d8 100644 --- a/third-party/ArduinoJson/extras/scripts/get-release-page.sh +++ b/third-party/ArduinoJson/extras/scripts/get-release-page.sh @@ -2,14 +2,14 @@ set -eu -TAG="$1" +VERSION="$1" CHANGELOG="$2" FRONTMATTER="$3" cat << END --- branch: v6 -version: $TAG +version: $VERSION date: '$(date +'%Y-%m-%d')' $(cat "$FRONTMATTER") --- diff --git a/third-party/ArduinoJson/extras/scripts/publish.sh b/third-party/ArduinoJson/extras/scripts/publish.sh index 9d9ec8c..3552ef9 100644 --- a/third-party/ArduinoJson/extras/scripts/publish.sh +++ b/third-party/ArduinoJson/extras/scripts/publish.sh @@ -63,6 +63,6 @@ extras/scripts/build-arduino-package.sh . "../ArduinoJson-$TAG.zip" extras/scripts/build-single-header.sh "src/ArduinoJson.h" "../ArduinoJson-$TAG.h" extras/scripts/build-single-header.sh "src/ArduinoJson.hpp" "../ArduinoJson-$TAG.hpp" extras/scripts/wandbox/publish.sh "../ArduinoJson-$TAG.h" > "../ArduinoJson-$TAG-wandbox.txt" -extras/scripts/get-release-page.sh "$TAG" "CHANGELOG.md" "../ArduinoJson-$TAG-wandbox.txt" > "../ArduinoJson-$TAG.md" +extras/scripts/get-release-page.sh "$VERSION" "CHANGELOG.md" "../ArduinoJson-$TAG-wandbox.txt" > "../ArduinoJson-$TAG.md" echo "You can now copy ../ArduinoJson-$TAG.md into arduinojson.org/collections/_versions/$VERSION.md" diff --git a/third-party/ArduinoJson/extras/tests/Cpp17/string_view.cpp b/third-party/ArduinoJson/extras/tests/Cpp17/string_view.cpp index 7c00a4f..56ad48c 100644 --- a/third-party/ArduinoJson/extras/tests/Cpp17/string_view.cpp +++ b/third-party/ArduinoJson/extras/tests/Cpp17/string_view.cpp @@ -58,6 +58,20 @@ TEST_CASE("string_view") { doc.add(std::string_view("example two", 7)); REQUIRE(doc.memoryUsage() == JSON_ARRAY_SIZE(2) + 8); } + + SECTION("as()") { + doc["s"] = "Hello World"; + doc["i"] = 42; + REQUIRE(doc["s"].as() == std::string_view("Hello World")); + REQUIRE(doc["i"].as() == std::string_view()); + } + + SECTION("is()") { + doc["s"] = "Hello World"; + doc["i"] = 42; + REQUIRE(doc["s"].is() == true); + REQUIRE(doc["i"].is() == false); + } } using ARDUINOJSON_NAMESPACE::adaptString; @@ -71,9 +85,5 @@ TEST_CASE("StringViewAdapter") { CHECK(adapter.compare("bravo") == 0); CHECK(adapter.compare("charlie") < 0); - CHECK(adapter.equals("bravo")); - CHECK_FALSE(adapter.equals("charlie")); - CHECK_FALSE(adapter.equals(NULL)); - CHECK(adapter.size() == 5); } diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/converters.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/converters.cpp index 01e407b..51aedc1 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/converters.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/converters.cpp @@ -13,11 +13,10 @@ struct Date { int year; }; -bool convertToJson(const Date& src, JsonVariant dst) { +void convertToJson(const Date& src, JsonVariant dst) { dst["day"] = src.day; dst["month"] = src.month; dst["year"] = src.year; - return true; } void convertFromJson(JsonVariantConst src, Date& dst) { @@ -92,10 +91,9 @@ class Complex { namespace ARDUINOJSON_NAMESPACE { template <> struct Converter { - static bool toJson(const Complex& src, VariantRef dst) { + static void toJson(const Complex& src, VariantRef dst) { dst["real"] = src.real(); dst["imag"] = src.imag(); - return true; } static Complex fromJson(VariantConstRef src) { diff --git a/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp b/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp index 7a6f652..4250f90 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp @@ -2,146 +2,118 @@ // Copyright Benoit Blanchon 2014-2021 // MIT License +#define ARDUINOJSON_ENABLE_PROGMEM 1 +#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 + #include "custom_string.hpp" #include "progmem_emulation.hpp" #include "weird_strcmp.hpp" -#include -#include -#include -#include -#include +#include #include using namespace ARDUINOJSON_NAMESPACE; -TEST_CASE("ConstRamStringAdapter") { +TEST_CASE("const char*") { SECTION("null") { - ConstRamStringAdapter adapter(NULL); + StringAdapter adapter(NULL); CHECK(adapter.compare("bravo") < 0); CHECK(adapter.compare(NULL) == 0); - CHECK(adapter.equals(NULL)); - CHECK_FALSE(adapter.equals("charlie")); - CHECK(adapter.size() == 0); } SECTION("non-null") { - ConstRamStringAdapter adapter("bravo"); + StringAdapter adapter("bravo"); CHECK(adapter.compare(NULL) > 0); CHECK(adapter.compare("alpha") > 0); CHECK(adapter.compare("bravo") == 0); CHECK(adapter.compare("charlie") < 0); - CHECK(adapter.equals("bravo")); - CHECK_FALSE(adapter.equals("charlie")); - CHECK(adapter.size() == 5); } } -TEST_CASE("SizedRamStringAdapter") { +TEST_CASE("const char* + size") { SECTION("null") { - SizedRamStringAdapter adapter(NULL, 10); + StringAdapter adapter(NULL, 10); CHECK(adapter.compare("bravo") < 0); CHECK(adapter.compare(NULL) == 0); - CHECK(adapter.equals(NULL)); - CHECK_FALSE(adapter.equals("charlie")); - CHECK(adapter.size() == 10); } SECTION("non-null") { - SizedRamStringAdapter adapter("bravo", 5); + StringAdapter adapter("bravo", 5); CHECK(adapter.compare(NULL) > 0); CHECK(adapter.compare("alpha") > 0); CHECK(adapter.compare("bravo") == 0); CHECK(adapter.compare("charlie") < 0); - CHECK(adapter.equals("bravo")); - CHECK_FALSE(adapter.equals("charlie")); - CHECK(adapter.size() == 5); } } -TEST_CASE("FlashStringAdapter") { +TEST_CASE("const __FlashStringHelper*") { SECTION("null") { - FlashStringAdapter adapter(NULL); + StringAdapter adapter(NULL); CHECK(adapter.compare("bravo") < 0); CHECK(adapter.compare(NULL) == 0); - CHECK(adapter.equals(NULL)); - CHECK_FALSE(adapter.equals("charlie")); - CHECK(adapter.size() == 0); } SECTION("non-null") { - FlashStringAdapter adapter = adaptString(F("bravo")); + StringAdapter adapter = adaptString(F("bravo")); CHECK(adapter.compare(NULL) > 0); CHECK(adapter.compare("alpha") > 0); CHECK(adapter.compare("bravo") == 0); CHECK(adapter.compare("charlie") < 0); - CHECK(adapter.equals("bravo")); - CHECK_FALSE(adapter.equals("charlie")); - CHECK(adapter.size() == 5); } } TEST_CASE("std::string") { std::string str("bravo"); - StdStringAdapter adapter = adaptString(str); + StringAdapter adapter(str); CHECK(adapter.compare(NULL) > 0); CHECK(adapter.compare("alpha") > 0); CHECK(adapter.compare("bravo") == 0); CHECK(adapter.compare("charlie") < 0); - CHECK(adapter.equals("bravo")); - CHECK_FALSE(adapter.equals("charlie")); - CHECK(adapter.size() == 5); } TEST_CASE("Arduino String") { ::String str("bravo"); - ArduinoStringAdapter adapter = adaptString(str); + StringAdapter< ::String> adapter(str); CHECK(adapter.compare(NULL) > 0); CHECK(adapter.compare("alpha") > 0); CHECK(adapter.compare("bravo") == 0); CHECK(adapter.compare("charlie") < 0); - CHECK(adapter.equals("bravo")); - CHECK_FALSE(adapter.equals("charlie")); - CHECK(adapter.size() == 5); } TEST_CASE("custom_string") { custom_string str("bravo"); - StdStringAdapter adapter = adaptString(str); + StringAdapter adapter(str); CHECK(adapter.compare(NULL) > 0); CHECK(adapter.compare("alpha") > 0); CHECK(adapter.compare("bravo") == 0); CHECK(adapter.compare("charlie") < 0); - CHECK(adapter.equals("bravo")); - CHECK_FALSE(adapter.equals("charlie")); - CHECK(adapter.size() == 5); } diff --git a/third-party/ArduinoJson/library.json b/third-party/ArduinoJson/library.json index 0faad3a..9645daa 100644 --- a/third-party/ArduinoJson/library.json +++ b/third-party/ArduinoJson/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/bblanchon/ArduinoJson.git" }, - "version": "6.18.2", + "version": "6.18.3", "authors": { "name": "Benoit Blanchon", "url": "https://blog.benoitblanchon.fr" diff --git a/third-party/ArduinoJson/library.properties b/third-party/ArduinoJson/library.properties index a0354b0..6f2edfb 100644 --- a/third-party/ArduinoJson/library.properties +++ b/third-party/ArduinoJson/library.properties @@ -1,5 +1,5 @@ name=ArduinoJson -version=6.18.2 +version=6.18.3 author=Benoit Blanchon maintainer=Benoit Blanchon sentence=A simple and efficient JSON library for embedded C++. diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp index 219a6b8..4f8d0c6 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp @@ -173,8 +173,8 @@ class ArrayRef : public ArrayRefBase, template <> struct Converter { - static bool toJson(VariantConstRef src, VariantRef dst) { - return variantCopyFrom(getData(dst), getData(src), getPool(dst)); + static void toJson(VariantConstRef src, VariantRef dst) { + variantCopyFrom(getData(dst), getData(src), getPool(dst)); } static ArrayConstRef fromJson(VariantConstRef src) { @@ -189,8 +189,8 @@ struct Converter { template <> struct Converter { - static bool toJson(VariantConstRef src, VariantRef dst) { - return variantCopyFrom(getData(dst), getData(src), getPool(dst)); + static void toJson(VariantConstRef src, VariantRef dst) { + variantCopyFrom(getData(dst), getData(src), getPool(dst)); } static ArrayRef fromJson(VariantRef src) { diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp index 7ee7f03..c1016eb 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp @@ -178,8 +178,8 @@ class ElementProxy : public VariantOperators >, return _array.getOrAddElement(_index); } - friend bool convertToJson(const this_type& src, VariantRef dst) { - return dst.set(src.getUpstreamElement()); + friend void convertToJson(const this_type& src, VariantRef dst) { + dst.set(src.getUpstreamElement()); } TArray _array; diff --git a/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp b/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp index 49a24be..f814bcd 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp @@ -62,9 +62,9 @@ inline bool CollectionData::copyFrom(const CollectionData& src, VariantData* var; if (s->key() != 0) { if (s->ownsKey()) - var = addMember(RamStringAdapter(s->key()), pool); + var = addMember(adaptString(const_cast(s->key())), pool); else - var = addMember(ConstRamStringAdapter(s->key()), pool); + var = addMember(adaptString(s->key()), pool); } else { var = addElement(pool); } @@ -107,7 +107,7 @@ template inline VariantSlot* CollectionData::getSlot(TAdaptedString key) const { VariantSlot* slot = _head; while (slot) { - if (key.equals(slot->key())) + if (key.compare(slot->key()) == 0) break; slot = slot->next(); } diff --git a/third-party/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp b/third-party/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp index 64c76b8..d81853c 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp @@ -337,8 +337,8 @@ class JsonDocument : public Visitable { JsonDocument& operator=(const JsonDocument&); }; -inline bool convertToJson(const JsonDocument& src, VariantRef dst) { - return dst.set(src.as()); +inline void convertToJson(const JsonDocument& src, VariantRef dst) { + dst.set(src.as()); } } // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Memory/MemoryPool.hpp b/third-party/ArduinoJson/src/ArduinoJson/Memory/MemoryPool.hpp index 7d3cd0c..04e5b2d 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Memory/MemoryPool.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Memory/MemoryPool.hpp @@ -167,7 +167,7 @@ class MemoryPool { template const char* findString(const TAdaptedString& str) { for (char* next = _begin; next < _left; ++next) { - if (str.equals(next)) + if (str.compare(next) == 0) return next; // jump to next terminator diff --git a/third-party/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp b/third-party/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp index 882b1fd..f1463a3 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp @@ -187,8 +187,8 @@ class MemberProxy : public VariantOperators >, return _object.getOrAddMember(_key); } - friend bool convertToJson(const this_type &src, VariantRef dst) { - return dst.set(src.getUpstreamMember()); + friend void convertToJson(const this_type &src, VariantRef dst) { + dst.set(src.getUpstreamMember()); } TObject _object; diff --git a/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectRef.hpp b/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectRef.hpp index cb541bd..047d9b1 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectRef.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectRef.hpp @@ -239,8 +239,8 @@ class ObjectRef : public ObjectRefBase, template <> struct Converter { - static bool toJson(VariantConstRef src, VariantRef dst) { - return variantCopyFrom(getData(dst), getData(src), getPool(dst)); + static void toJson(VariantConstRef src, VariantRef dst) { + variantCopyFrom(getData(dst), getData(src), getPool(dst)); } static ObjectConstRef fromJson(VariantConstRef src) { @@ -255,8 +255,8 @@ struct Converter { template <> struct Converter { - static bool toJson(VariantConstRef src, VariantRef dst) { - return variantCopyFrom(getData(dst), getData(src), getPool(dst)); + static void toJson(VariantConstRef src, VariantRef dst) { + variantCopyFrom(getData(dst), getData(src), getPool(dst)); } static ObjectRef fromJson(VariantRef src) { diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits.hpp index 4a8ff4b..24440b1 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits.hpp @@ -20,5 +20,6 @@ #include "type_traits/is_signed.hpp" #include "type_traits/is_unsigned.hpp" #include "type_traits/make_unsigned.hpp" +#include "type_traits/make_void.hpp" #include "type_traits/remove_const.hpp" #include "type_traits/remove_reference.hpp" diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_void.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_void.hpp new file mode 100644 index 0000000..cb2ebde --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_void.hpp @@ -0,0 +1,14 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +namespace ARDUINOJSON_NAMESPACE { + +template +struct make_void { + typedef void type; +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ArduinoStringAdapter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ArduinoStringAdapter.hpp new file mode 100644 index 0000000..5e4b624 --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ArduinoStringAdapter.hpp @@ -0,0 +1,52 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +#include +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +template <> +class StringAdapter< ::String> { + public: + StringAdapter(const ::String& str) : _str(&str) {} + + void copyTo(char* p, size_t n) const { + memcpy(p, _str->c_str(), n); + } + + bool isNull() const { + // Arduino's String::c_str() can return NULL + return !_str->c_str(); + } + + int compare(const char* other) const { + // Arduino's String::c_str() can return NULL + const char* me = _str->c_str(); + return safe_strcmp(me, other); + } + + size_t size() const { + return _str->length(); + } + + typedef storage_policies::store_by_copy storage_policy; + + private: + const ::String* _str; +}; + +template <> +class StringAdapter< ::StringSumHelper> : public StringAdapter< ::String> { + public: + StringAdapter< ::StringSumHelper>(const ::String& s) + : StringAdapter< ::String>(s) {} +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ConstRamStringAdapter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ConstRamStringAdapter.hpp new file mode 100644 index 0000000..1ca7c02 --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ConstRamStringAdapter.hpp @@ -0,0 +1,51 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include // size_t +#include // strcmp + +#include +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +template <> +class StringAdapter { + public: + StringAdapter(const char* str = 0) : _str(str) {} + + int compare(const char* other) const { + return safe_strcmp(_str, other); + } + + bool isNull() const { + return !_str; + } + + size_t size() const { + if (!_str) + return 0; + return strlen(_str); + } + + const char* data() const { + return _str; + } + + typedef storage_policies::store_by_address storage_policy; + + protected: + const char* _str; +}; + +template +class StringAdapter : public StringAdapter { + public: + StringAdapter(const char* s) : StringAdapter(s) {} +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/FlashStringAdapter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/FlashStringAdapter.hpp new file mode 100644 index 0000000..3a95818 --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/FlashStringAdapter.hpp @@ -0,0 +1,48 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +template <> +class StringAdapter { + public: + StringAdapter(const __FlashStringHelper* str) : _str(str) {} + + int compare(const char* other) const { + if (!other && !_str) + return 0; + if (!_str) + return -1; + if (!other) + return 1; + return -strcmp_P(other, reinterpret_cast(_str)); + } + + bool isNull() const { + return !_str; + } + + void copyTo(char* p, size_t n) const { + memcpy_P(p, reinterpret_cast(_str), n); + } + + size_t size() const { + if (!_str) + return 0; + return strlen_P(reinterpret_cast(_str)); + } + + typedef storage_policies::store_by_copy storage_policy; + + private: + const __FlashStringHelper* _str; +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/JsonStringAdapter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/JsonStringAdapter.hpp new file mode 100644 index 0000000..c34abce --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/JsonStringAdapter.hpp @@ -0,0 +1,27 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +template <> +class StringAdapter : public StringAdapter { + public: + StringAdapter(const String& str) + : StringAdapter(str.c_str()), _isStatic(str.isStatic()) {} + + bool isStatic() const { + return _isStatic; + } + + typedef storage_policies::decide_at_runtime storage_policy; + + private: + bool _isStatic; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/RamStringAdapter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/RamStringAdapter.hpp new file mode 100644 index 0000000..f2b01d1 --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/RamStringAdapter.hpp @@ -0,0 +1,29 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +class StringAdapter::value>::type> + : public StringAdapter { + public: + StringAdapter(const TChar* str) + : StringAdapter(reinterpret_cast(str)) {} + + void copyTo(char* p, size_t n) const { + memcpy(p, _str, n); + } + + typedef ARDUINOJSON_NAMESPACE::storage_policies::store_by_copy storage_policy; +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/SizedFlashStringAdapter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/SizedFlashStringAdapter.hpp new file mode 100644 index 0000000..b2d012f --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/SizedFlashStringAdapter.hpp @@ -0,0 +1,48 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +template <> +class StringAdapter { + public: + StringAdapter(const __FlashStringHelper* str, size_t sz) + : _str(str), _size(sz) {} + + int compare(const char* other) const { + if (!other && !_str) + return 0; + if (!_str) + return -1; + if (!other) + return 1; + return -strncmp_P(other, reinterpret_cast(_str), _size); + } + + bool isNull() const { + return !_str; + } + + void copyTo(char* p, size_t n) const { + memcpy_P(p, reinterpret_cast(_str), n); + } + + size_t size() const { + return _size; + } + + typedef storage_policies::store_by_copy storage_policy; + + private: + const __FlashStringHelper* _str; + size_t _size; +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/SizedRamStringAdapter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/SizedRamStringAdapter.hpp new file mode 100644 index 0000000..a18d5ab --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/SizedRamStringAdapter.hpp @@ -0,0 +1,43 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include +#include +#include + +#include // strcmp + +namespace ARDUINOJSON_NAMESPACE { + +template +class StringAdapter { + public: + StringAdapter(const char* str, size_t n) : _str(str), _size(n) {} + + int compare(const char* other) const { + return safe_strncmp(_str, other, _size); + } + + bool isNull() const { + return !_str; + } + + void copyTo(char* p, size_t n) const { + memcpy(p, _str, n); + } + + size_t size() const { + return _size; + } + + typedef storage_policies::store_by_copy storage_policy; + + private: + const char* _str; + size_t _size; +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StdStringAdapter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StdStringAdapter.hpp new file mode 100644 index 0000000..4d2d32c --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StdStringAdapter.hpp @@ -0,0 +1,46 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include +#include +#include + +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +class StringAdapter > { + public: + typedef std::basic_string string_type; + + StringAdapter(const string_type& str) : _str(&str) {} + + void copyTo(char* p, size_t n) const { + memcpy(p, _str->c_str(), n); + } + + bool isNull() const { + return false; + } + + int compare(const char* other) const { + if (!other) + return 1; + return _str->compare(other); + } + + size_t size() const { + return _str->size(); + } + + typedef storage_policies::store_by_copy storage_policy; + + private: + const string_type* _str; +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StringViewAdapter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StringViewAdapter.hpp new file mode 100644 index 0000000..787f7c2 --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StringViewAdapter.hpp @@ -0,0 +1,44 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include +#include +#include + +#include + +namespace ARDUINOJSON_NAMESPACE { + +template <> +class StringAdapter { + public: + StringAdapter(std::string_view str) : _str(str) {} + + void copyTo(char* p, size_t n) const { + memcpy(p, _str.data(), n); + } + + bool isNull() const { + return false; + } + + int compare(const char* other) const { + if (!other) + return 1; + return _str.compare(other); + } + + size_t size() const { + return _str.size(); + } + + typedef storage_policies::store_by_copy storage_policy; + + private: + std::string_view _str; +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/String.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/String.hpp index 4f2abde..fff4077 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Strings/String.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/String.hpp @@ -4,10 +4,6 @@ #pragma once -#include -#include -#include - namespace ARDUINOJSON_NAMESPACE { class String { @@ -53,25 +49,4 @@ class String { bool _isStatic; }; -class StringAdapter : public RamStringAdapter { - public: - StringAdapter(const String& str) - : RamStringAdapter(str.c_str()), _isStatic(str.isStatic()) {} - - bool isStatic() const { - return _isStatic; - } - - typedef storage_policies::decide_at_runtime storage_policy; - - private: - bool _isStatic; -}; - -template <> -struct IsString : true_type {}; - -inline StringAdapter adaptString(const String& str) { - return StringAdapter(str); -} } // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/StringAdapter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/StringAdapter.hpp new file mode 100644 index 0000000..1d55b21 --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/StringAdapter.hpp @@ -0,0 +1,32 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +class StringAdapter; + +template +inline StringAdapter adaptString(const T& str) { + return StringAdapter(str); +} + +template +inline StringAdapter adaptString(const T& str, size_t sz) { + return StringAdapter(str, sz); +} + +template +struct IsString : false_type {}; + +template +struct IsString< + T, typename make_void::storage_policy>::type> + : true_type {}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/StringAdapters.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/StringAdapters.hpp index 1de86bc..ba763a6 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Strings/StringAdapters.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/StringAdapters.hpp @@ -4,23 +4,24 @@ #pragma once -#include -#include -#include +#include +#include +#include +#include #if ARDUINOJSON_ENABLE_STD_STRING -# include +# include #endif #if ARDUINOJSON_ENABLE_STRING_VIEW -# include +# include #endif #if ARDUINOJSON_ENABLE_ARDUINO_STRING -# include +# include #endif #if ARDUINOJSON_ENABLE_PROGMEM -# include -# include +# include +# include #endif diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp index 34e12bb..33f8c65 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp @@ -12,9 +12,9 @@ namespace ARDUINOJSON_NAMESPACE { template struct Converter { - static bool toJson(const T& src, VariantRef dst) { + static void toJson(const T& src, VariantRef dst) { // clang-format off - return convertToJson(src, dst); // Error here? See https://arduinojson.org/v6/unsupported-set/ + convertToJson(src, dst); // Error here? See https://arduinojson.org/v6/unsupported-set/ // clang-format on } @@ -38,13 +38,11 @@ template struct Converter< T, typename enable_if::value && !is_same::value && !is_same::value>::type> { - static bool toJson(T src, VariantRef dst) { + static void toJson(T src, VariantRef dst) { VariantData* data = getData(dst); ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T); - if (!data) - return false; - data->setInteger(src); - return true; + if (data) + data->setInteger(src); } static T fromJson(VariantConstRef src) { @@ -61,8 +59,8 @@ struct Converter< template struct Converter::value>::type> { - static bool toJson(T src, VariantRef dst) { - return dst.set(static_cast(src)); + static void toJson(T src, VariantRef dst) { + dst.set(static_cast(src)); } static T fromJson(VariantConstRef src) { @@ -78,12 +76,10 @@ struct Converter::value>::type> { template <> struct Converter { - static bool toJson(bool src, VariantRef dst) { + static void toJson(bool src, VariantRef dst) { VariantData* data = getData(dst); - if (!data) - return false; - data->setBoolean(src); - return true; + if (data) + data->setBoolean(src); } static bool fromJson(VariantConstRef src) { @@ -99,12 +95,10 @@ struct Converter { template struct Converter::value>::type> { - static bool toJson(T src, VariantRef dst) { + static void toJson(T src, VariantRef dst) { VariantData* data = getData(dst); - if (!data) - return false; - data->setFloat(static_cast(src)); - return true; + if (data) + data->setFloat(static_cast(src)); } static T fromJson(VariantConstRef src) { @@ -120,8 +114,8 @@ struct Converter::value>::type> { template <> struct Converter { - static bool toJson(const char* src, VariantRef dst) { - return variantSetString(getData(dst), adaptString(src), getPool(dst)); + static void toJson(const char* src, VariantRef dst) { + variantSetString(getData(dst), adaptString(src), getPool(dst)); } static const char* fromJson(VariantConstRef src) { @@ -163,12 +157,10 @@ canConvertFromJson(VariantConstRef src, const T&) { template <> struct Converter > { - static bool toJson(SerializedValue src, VariantRef dst) { + static void toJson(SerializedValue src, VariantRef dst) { VariantData* data = getData(dst); - if (!data) - return false; - data->setLinkedRaw(src); - return true; + if (data) + data->setLinkedRaw(src); } }; @@ -178,10 +170,11 @@ struct Converter > { template struct Converter, typename enable_if::value>::type> { - static bool toJson(SerializedValue src, VariantRef dst) { + static void toJson(SerializedValue src, VariantRef dst) { VariantData* data = getData(dst); MemoryPool* pool = getPool(dst); - return data != 0 && data->setOwnedRaw(src, pool); + if (data) + data->setOwnedRaw(src, pool); } }; @@ -189,9 +182,8 @@ struct Converter, template <> struct Converter { - static bool toJson(decltype(nullptr), VariantRef dst) { + static void toJson(decltype(nullptr), VariantRef dst) { variantSetNull(getData(dst)); - return true; } static decltype(nullptr) fromJson(VariantConstRef) { return nullptr; @@ -247,20 +239,33 @@ class MemoryPoolPrint : public Print { size_t _capacity; }; -inline bool convertToJson(const ::Printable& src, VariantRef dst) { +inline void convertToJson(const ::Printable& src, VariantRef dst) { MemoryPool* pool = getPool(dst); VariantData* data = getData(dst); if (!pool || !data) - return false; + return; MemoryPoolPrint print(pool); src.printTo(print); if (print.overflowed()) { pool->markAsOverflowed(); data->setNull(); - return false; + return; } data->setStringPointer(print.c_str(), storage_policies::store_by_copy()); - return true; +} + +#endif + +#if ARDUINOJSON_ENABLE_STRING_VIEW + +inline void convertFromJson(VariantConstRef src, std::string_view& dst) { + const char* str = src.as(); + if (str) // the standard doesn't allow passing null to the constructor + dst = std::string_view(str); +} + +inline bool canConvertFromJson(VariantConstRef src, const std::string_view&) { + return src.is(); } #endif diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp index 025ef90..4e0471a 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include namespace ARDUINOJSON_NAMESPACE { diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp index fd54a94..388b7e2 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include // VariantData can't have a constructor (to be a POD), so we have no way to fix @@ -103,7 +103,8 @@ class VariantData { case VALUE_IS_OBJECT: return toObject().copyFrom(src._content.asCollection, pool); case VALUE_IS_OWNED_STRING: - return setString(RamStringAdapter(src._content.asString), pool); + return setString(adaptString(const_cast(src._content.asString)), + pool); case VALUE_IS_OWNED_RAW: return setOwnedRaw( serialized(src._content.asRaw.data, src._content.asRaw.size), pool); diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp index 0661592..b05ed90 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp @@ -85,7 +85,8 @@ class VariantRef : public VariantRefBase, template FORCE_INLINE bool set(const T &value) const { - return Converter::toJson(value, *this); + Converter::toJson(value, *this); + return _pool && !_pool->overflowed(); } bool ARDUINOJSON_DEPRECATED( @@ -94,7 +95,8 @@ class VariantRef : public VariantRefBase, template FORCE_INLINE bool set(T *value) const { - return Converter::toJson(value, *this); + Converter::toJson(value, *this); + return _pool && !_pool->overflowed(); } template @@ -339,8 +341,8 @@ class VariantConstRef : public VariantRefBase, template <> struct Converter { - static bool toJson(VariantRef src, VariantRef dst) { - return variantCopyFrom(getData(dst), getData(src), getPool(dst)); + static void toJson(VariantRef src, VariantRef dst) { + variantCopyFrom(getData(dst), getData(src), getPool(dst)); } static VariantRef fromJson(VariantRef src) { @@ -362,8 +364,8 @@ struct Converter { template <> struct Converter { - static bool toJson(VariantConstRef src, VariantRef dst) { - return variantCopyFrom(getData(dst), getData(src), getPool(dst)); + static void toJson(VariantConstRef src, VariantRef dst) { + variantCopyFrom(getData(dst), getData(src), getPool(dst)); } static VariantConstRef fromJson(VariantConstRef src) { diff --git a/third-party/ArduinoJson/src/ArduinoJson/version.hpp b/third-party/ArduinoJson/src/ArduinoJson/version.hpp index cf20b1c..6ddc844 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/version.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/version.hpp @@ -4,7 +4,7 @@ #pragma once -#define ARDUINOJSON_VERSION "6.18.2" +#define ARDUINOJSON_VERSION "6.18.3" #define ARDUINOJSON_VERSION_MAJOR 6 #define ARDUINOJSON_VERSION_MINOR 18 -#define ARDUINOJSON_VERSION_REVISION 2 +#define ARDUINOJSON_VERSION_REVISION 3