diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ca8582..02cb882 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ else() endif() # DelegateMQ release to build against (.github/workflows/embedded.yml reads it too) -set(DMQ_GIT_TAG "v2.4.1" CACHE STRING "DelegateMQ release tag (or branch) to fetch") +set(DMQ_GIT_TAG "v3.0.0" CACHE STRING "DelegateMQ release tag (or branch) to fetch") include(FetchContent) FetchContent_Declare( diff --git a/README.md b/README.md index ca8d783..5691f7f 100644 --- a/README.md +++ b/README.md @@ -149,13 +149,13 @@ Remote sets go through the same range checks as local ones. ## Building -Requires a C++17 compiler and CMake 3.16+. [DelegateMQ](https://github.com/DelegateMQ/DelegateMQ) is fetched from GitHub by CMake's `FetchContent` when CMake configures, at the release tag set by `DMQ_GIT_TAG` in `CMakeLists.txt` (currently `v2.4.1`), and the app links the `DelegateMQ::DelegateMQ` target. To build against a local DelegateMQ checkout, add `-DFETCHCONTENT_SOURCE_DIR_DELEGATEMQ=`; to configure again offline, `-DFETCHCONTENT_FULLY_DISCONNECTED=ON`. +Requires a C++17 compiler and CMake 3.16+. [DelegateMQ](https://github.com/DelegateMQ/DelegateMQ) is fetched from GitHub by CMake's `FetchContent` when CMake configures, at the release tag set by `DMQ_GIT_TAG` in `CMakeLists.txt` (currently `v3.0.0`), and the app links the `DelegateMQ::DelegateMQ` target. To build against a local DelegateMQ checkout, add `-DFETCHCONTENT_SOURCE_DIR_DELEGATEMQ=`; to configure again offline, `-DFETCHCONTENT_FULLY_DISCONNECTED=ON`. | CMake option | Default | Effect | | :--- | :--- | :--- | | `PARAM_REMOTE` | `ON` | Build remote access (`ParamService`, `ParamClient`) | | `PARAM_BACKEND_SQLITE` | `ON` if SQLite is present | Build the SQLite backend | -| `DMQ_GIT_TAG` | `v2.4.1` | DelegateMQ release (or branch) to fetch | +| `DMQ_GIT_TAG` | `v3.0.0` | DelegateMQ release (or branch) to fetch | To use it in your project, add `params/` to your build and add DelegateMQ as described in its [build guide](https://github.com/DelegateMQ/DelegateMQ/blob/master/docs/BUILD.md), with its `src/delegate-mq` folder on the include path. On a microcontroller the core is `ParamStore.cpp` plus a backend such as `FlashLogBackend.cpp`. diff --git a/params/ParamMessages.h b/params/ParamMessages.h index 76fdd25..2a647b8 100644 --- a/params/ParamMessages.h +++ b/params/ParamMessages.h @@ -71,8 +71,8 @@ struct ParamListReq PARAM_MSG_BASE { uint32_t requestId = 0; #if defined(DMQ_SERIALIZE_SERIALIZE) - std::istream& read(serialize& ms, std::istream& is) PARAM_MSG_OVERRIDE { return ms.read(is, requestId); } - std::ostream& write(serialize& ms, std::ostream& os) PARAM_MSG_OVERRIDE { return ms.write(os, requestId); } + dmq::ByteReader& read(serialize& ms, dmq::ByteReader& is) PARAM_MSG_OVERRIDE { return ms.read(is, requestId); } + dmq::ByteWriter& write(serialize& ms, dmq::ByteWriter& os) PARAM_MSG_OVERRIDE { return ms.write(os, requestId); } #endif }; @@ -81,11 +81,11 @@ struct ParamGetReq PARAM_MSG_BASE { ParamId id = 0; #if defined(DMQ_SERIALIZE_SERIALIZE) - std::istream& read(serialize& ms, std::istream& is) PARAM_MSG_OVERRIDE { + dmq::ByteReader& read(serialize& ms, dmq::ByteReader& is) PARAM_MSG_OVERRIDE { ms.read(is, requestId); return ms.read(is, id); } - std::ostream& write(serialize& ms, std::ostream& os) PARAM_MSG_OVERRIDE { + dmq::ByteWriter& write(serialize& ms, dmq::ByteWriter& os) PARAM_MSG_OVERRIDE { ms.write(os, requestId); return ms.write(os, id); } @@ -102,13 +102,13 @@ struct ParamSetReq PARAM_MSG_BASE { void SetValue(const Value& v) { type = static_cast(v.type); bits = ToBits(v); } #if defined(DMQ_SERIALIZE_SERIALIZE) - std::istream& read(serialize& ms, std::istream& is) PARAM_MSG_OVERRIDE { + dmq::ByteReader& read(serialize& ms, dmq::ByteReader& is) PARAM_MSG_OVERRIDE { ms.read(is, requestId); ms.read(is, id); ms.read(is, type); return ms.read(is, bits); } - std::ostream& write(serialize& ms, std::ostream& os) PARAM_MSG_OVERRIDE { + dmq::ByteWriter& write(serialize& ms, dmq::ByteWriter& os) PARAM_MSG_OVERRIDE { ms.write(os, requestId); ms.write(os, id); ms.write(os, type); @@ -130,7 +130,7 @@ struct ParamValueMsg PARAM_MSG_BASE { void SetValue(const Value& v) { type = static_cast(v.type); bits = ToBits(v); } #if defined(DMQ_SERIALIZE_SERIALIZE) - std::istream& read(serialize& ms, std::istream& is) PARAM_MSG_OVERRIDE { + dmq::ByteReader& read(serialize& ms, dmq::ByteReader& is) PARAM_MSG_OVERRIDE { ms.read(is, requestId); ms.read(is, id); ms.read(is, result); @@ -138,7 +138,7 @@ struct ParamValueMsg PARAM_MSG_BASE { ms.read(is, type); return ms.read(is, bits); } - std::ostream& write(serialize& ms, std::ostream& os) PARAM_MSG_OVERRIDE { + dmq::ByteWriter& write(serialize& ms, dmq::ByteWriter& os) PARAM_MSG_OVERRIDE { ms.write(os, requestId); ms.write(os, id); ms.write(os, result); @@ -162,7 +162,7 @@ struct ParamDescMsg PARAM_MSG_BASE { char units[UNITS_LEN] = {}; #if defined(DMQ_SERIALIZE_SERIALIZE) - std::istream& read(serialize& ms, std::istream& is) PARAM_MSG_OVERRIDE { + dmq::ByteReader& read(serialize& ms, dmq::ByteReader& is) PARAM_MSG_OVERRIDE { ms.read(is, requestId); ms.read(is, index); ms.read(is, count); @@ -178,7 +178,7 @@ struct ParamDescMsg PARAM_MSG_BASE { name[NAME_LEN - 1] = units[UNITS_LEN - 1] = '\0'; return is; } - std::ostream& write(serialize& ms, std::ostream& os) PARAM_MSG_OVERRIDE { + dmq::ByteWriter& write(serialize& ms, dmq::ByteWriter& os) PARAM_MSG_OVERRIDE { ms.write(os, requestId); ms.write(os, index); ms.write(os, count); diff --git a/unit-tests/ParamServiceTests.cpp b/unit-tests/ParamServiceTests.cpp index f9819ba..6983d5c 100644 --- a/unit-tests/ParamServiceTests.cpp +++ b/unit-tests/ParamServiceTests.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -202,10 +201,11 @@ template static T RoundTrip(T& in) { serialize ms; - std::stringstream ss(std::ios::in | std::ios::out | std::ios::binary); - in.write(ms, ss); + dmq::ByteWriter os; + in.write(ms, os); + dmq::ByteReader is(os); T out; - out.read(ms, ss); + out.read(ms, is); return out; }