From eb1402764ec42578c6d6ded27c4b860d03d61752 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Tue, 8 Dec 2015 16:19:27 -0800 Subject: [PATCH] Move ERT packet type to its rightful place. No longer mixed up with Message types. --- firmware/application/ert_app.cpp | 4 ++-- firmware/baseband/proc_ert.cpp | 4 ++-- firmware/common/ert_packet.cpp | 16 ++++++++-------- firmware/common/ert_packet.hpp | 13 +++++++++---- firmware/common/message.hpp | 9 ++------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/firmware/application/ert_app.cpp b/firmware/application/ert_app.cpp index cf91c9bd..1b4c4c83 100644 --- a/firmware/application/ert_app.cpp +++ b/firmware/application/ert_app.cpp @@ -81,14 +81,14 @@ void ERTView::on_hide() { void ERTView::on_packet(const ert::Packet& packet) { std::string msg; switch(packet.type()) { - case ERTPacketMessage::Type::SCM: + case ert::Packet::Type::SCM: msg += "SCM "; msg += to_string_dec_uint(packet.id(), 10); msg += " "; msg += to_string_dec_uint(packet.consumption(), 10); break; - case ERTPacketMessage::Type::IDM: + case ert::Packet::Type::IDM: msg += "IDM "; msg += to_string_dec_uint(packet.id(), 10); msg += " "; diff --git a/firmware/baseband/proc_ert.cpp b/firmware/baseband/proc_ert.cpp index 36f3d55c..c7c07074 100644 --- a/firmware/baseband/proc_ert.cpp +++ b/firmware/baseband/proc_ert.cpp @@ -98,7 +98,7 @@ void ERTProcessor::scm_handler( const baseband::Packet& packet ) { ERTPacketMessage message; - message.type = ERTPacketMessage::Type::SCM; + message.type = ert::Packet::Type::SCM; message.packet = packet; shared_memory.application_queue.push(message); } @@ -107,7 +107,7 @@ void ERTProcessor::idm_handler( const baseband::Packet& packet ) { ERTPacketMessage message; - message.type = ERTPacketMessage::Type::IDM; + message.type = ert::Packet::Type::IDM; message.packet = packet; shared_memory.application_queue.push(message); } diff --git a/firmware/common/ert_packet.cpp b/firmware/common/ert_packet.cpp index 7cec5fa7..e5c477f9 100644 --- a/firmware/common/ert_packet.cpp +++ b/firmware/common/ert_packet.cpp @@ -37,27 +37,27 @@ rtc::RTC Packet::received_at() const { return received_at_; } -ERTPacketMessage::Type Packet::type() const { +Packet::Type Packet::type() const { return type_; } ID Packet::id() const { - if( type() == ERTPacketMessage::Type::SCM ) { + if( type() == Type::SCM ) { const auto msb = reader_.read(0, 2); const auto lsb = reader_.read(35, 24); return (msb << 24) | lsb; } - if( type() == ERTPacketMessage::Type::IDM ) { + if( type() == Type::IDM ) { return reader_.read(5 * 8, 32); } return invalid_id; } Consumption Packet::consumption() const { - if( type() == ERTPacketMessage::Type::SCM ) { + if( type() == Type::SCM ) { return reader_.read(11, 24); } - if( type() == ERTPacketMessage::Type::IDM ) { + if( type() == Type::IDM ) { return reader_.read(25 * 8, 32); } return invalid_consumption; @@ -69,9 +69,9 @@ ManchesterFormatted Packet::symbols_formatted() const { bool Packet::crc_ok() const { switch(type()) { - case ERTPacketMessage::Type::SCM: return crc_ok_scm(); - case ERTPacketMessage::Type::IDM: return crc_ok_idm(); - default: return false; + case Type::SCM: return crc_ok_scm(); + case Type::IDM: return crc_ok_idm(); + default: return false; } } diff --git a/firmware/common/ert_packet.hpp b/firmware/common/ert_packet.hpp index d7489571..eaaa1763 100644 --- a/firmware/common/ert_packet.hpp +++ b/firmware/common/ert_packet.hpp @@ -28,7 +28,6 @@ #include "field_reader.hpp" #include "baseband_packet.hpp" #include "manchester.hpp" -#include "message.hpp" #include "lpc43xx_cpp.hpp" using namespace lpc43xx; @@ -40,9 +39,15 @@ using Consumption = uint32_t; class Packet { public: + enum class Type : uint32_t { + Unknown = 0, + IDM = 1, + SCM = 2, + }; + Packet( const rtc::RTC& received_at, - const ERTPacketMessage::Type type, + const Type type, const baseband::Packet& packet ) : packet_ { packet }, received_at_ { received_at }, @@ -58,7 +63,7 @@ public: rtc::RTC received_at() const; - ERTPacketMessage::Type type() const; + Type type() const; ID id() const; Consumption consumption() const; @@ -73,7 +78,7 @@ private: const rtc::RTC received_at_; const ManchesterDecoder decoder_; const Reader reader_; - const ERTPacketMessage::Type type_; + const Type type_; const ID invalid_id = 0; const Consumption invalid_consumption = 0; diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index fd232bef..d0628ffe 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -28,6 +28,7 @@ #include #include "baseband_packet.hpp" +#include "ert_packet.hpp" #include "utility.hpp" @@ -238,13 +239,7 @@ public: { } - enum class Type : uint32_t { - Unknown = 0, - IDM = 1, - SCM = 2, - }; - - Type type { Type::Unknown }; + ert::Packet::Type type { ert::Packet::Type::Unknown }; baseband::Packet packet; };