Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<path>`; 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=<path>`; 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`.

Expand Down
20 changes: 10 additions & 10 deletions params/ParamMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand All @@ -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);
}
Expand All @@ -102,13 +102,13 @@ struct ParamSetReq PARAM_MSG_BASE {
void SetValue(const Value& v) { type = static_cast<uint8_t>(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);
Expand All @@ -130,15 +130,15 @@ struct ParamValueMsg PARAM_MSG_BASE {
void SetValue(const Value& v) { type = static_cast<uint8_t>(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);
ms.read(is, source);
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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions unit-tests/ParamServiceTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <chrono>
#include <functional>
#include <iostream>
#include <sstream>
#include <thread>
#include <vector>

Expand Down Expand Up @@ -202,10 +201,11 @@ template <class T>
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;
}

Expand Down