matth-x / MicroOcpp

OCPP 1.6 / 2.0.1 client for microcontrollers
MIT License
345 stars 149 forks source link

Error on Make - Invalid Initialization of Reference #295

Open rexngreen opened 6 months ago

rexngreen commented 6 months ago

When trying to compile the MicroOcpp project after a clean pull using make, throws multiple errors related to using DynamicJsonDocument

  39 |     T result; // Error here? See https://arduinojson.org/v7/non-default-constructible/
      |       ^~~~~~
In file included from /home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/../ArduinoJson/src/ArduinoJson.hpp:53,
                 from /home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/../ArduinoJson/src/ArduinoJson.h:9,
                 from /home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/./src/MicroOcpp/Core/RequestStore.h:10,
                 from /home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/src/MicroOcpp/Core/RequestStore.cpp:5:
/home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/../ArduinoJson/src/ArduinoJson/compatibility.hpp:128:3: note: candidate: ‘ArduinoJson::V704HB42::DynamicJsonDocument::DynamicJsonDocument(size_t)’
  128 |   DynamicJsonDocument(size_t capacity) : _capacity(capacity) {}
      |   ^~~~~~~~~~~~~~~~~~~
/home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/../ArduinoJson/src/ArduinoJson/compatibility.hpp:128:3: note:   candidate expects 1 argument, 0 provided
/home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/../ArduinoJson/src/ArduinoJson/compatibility.hpp:125:58: note: candidate: ‘ArduinoJson::V704HB42::DynamicJsonDocument::DynamicJsonDocument(const ArduinoJson::V704HB42::DynamicJsonDocument&)’
  125 | class ARDUINOJSON_DEPRECATED("use JsonDocument instead") DynamicJsonDocument
      |                                                          ^~~~~~~~~~~~~~~~~~~
/home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/../ArduinoJson/src/ArduinoJson/compatibility.hpp:125:58: note:   candidate expects 1 argument, 0 provided
/home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/../ArduinoJson/src/ArduinoJson/compatibility.hpp:125:58: note: candidate: ‘ArduinoJson::V704HB42::DynamicJsonDocument::DynamicJsonDocument(ArduinoJson::V704HB42::DynamicJsonDocument&&)’
/home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/../ArduinoJson/src/ArduinoJson/compatibility.hpp:125:58: note:   candidate expects 1 argument, 0 provided
In file included from /home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/../ArduinoJson/src/ArduinoJson.hpp:42,
                 from /home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/../ArduinoJson/src/ArduinoJson.h:9,
                 from /home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/./src/MicroOcpp/Core/RequestStore.h:10,
                 from /home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/src/MicroOcpp/Core/RequestStore.cpp:5:
/home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/../ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp:40:26: error: invalid initialization of reference of type ‘std::string&’ {aka ‘std::__cxx11::basic_string<char>&’} from expression of type ‘ArduinoJson::V704HB42::DynamicJsonDocument’
   40 |     convertFromJson(src, result);  // Error here? See https://arduinojson.org/v7/unsupported-as/
      |                          ^~~~~~
/home/spec/spec2/libraries/MicroOcpp_build/MicroOcpp-1.6/../ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp:295:64: note: in passing argument 2 of ‘void ArduinoJson::V704HB42::convertFromJson(ArduinoJson::V704HB42::JsonVariantConst, std::string&)’
  295 | inline void convertFromJson(JsonVariantConst src, std::string& dst) {
      |                                                   ~~~~~~~~~~~~~^~~
make[2]: *** [CMakeFiles/MicroOcpp.dir/build.make:286: CMakeFiles/MicroOcpp.dir/src/MicroOcpp/Core/RequestStore.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/MicroOcpp.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
matth-x commented 6 months ago

Hi, I assume you downloaded ArduinoJson v7? Unfortunately, MicroOcpp hasn't been upgraded to support v7 yet. You need to downgrade to v6.

Do you think there is a place in the sources / the docs where I could highlight this better?