summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-09-23 19:59:05 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-09-23 19:59:05 +0200
commit0330221d51421caa110b8c5dcb567cc3d0620eb9 (patch)
tree1ee1c31c1ba9a9f4ff09bd7af80115a4f4b43459
parent595c3e3a0baaf5181503b5bed3346c21a91c9ba2 (diff)
downloaddabmod-0330221d51421caa110b8c5dcb567cc3d0620eb9.tar.gz
dabmod-0330221d51421caa110b8c5dcb567cc3d0620eb9.tar.bz2
dabmod-0330221d51421caa110b8c5dcb567cc3d0620eb9.zip
Pull common code from 547c789
-rw-r--r--lib/edi/common.cpp13
-rw-r--r--lib/edi/common.hpp8
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/edi/common.cpp b/lib/edi/common.cpp
index 4629b55..ac8ec0c 100644
--- a/lib/edi/common.cpp
+++ b/lib/edi/common.cpp
@@ -339,4 +339,17 @@ bool TagDispatcher::decode_tagpacket(const vector<uint8_t> &payload)
return success;
}
+odr_version_data parse_odr_version_data(const std::vector<uint8_t>& data)
+{
+ if (data.size() < sizeof(uint32_t)) {
+ return {};
+ }
+
+ const size_t versionstr_length = data.size() - sizeof(uint32_t);
+ string version(data.begin(), data.begin() + versionstr_length);
+ uint32_t uptime_s = read_32b(data.begin() + versionstr_length);
+
+ return {version, uptime_s};
+}
+
}
diff --git a/lib/edi/common.hpp b/lib/edi/common.hpp
index 1aa2cb6..5d15f8d 100644
--- a/lib/edi/common.hpp
+++ b/lib/edi/common.hpp
@@ -94,4 +94,12 @@ class TagDispatcher {
std::function<void()> m_af_packet_completed;
};
+// Data carried inside the ODRv EDI TAG
+struct odr_version_data {
+ std::string version;
+ uint32_t uptime_s;
+};
+
+odr_version_data parse_odr_version_data(const std::vector<uint8_t>& data);
+
}