From 9e004d47549980bd32191f632f90c5c04392ae90 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sun, 6 Dec 2015 15:36:23 -0800 Subject: [PATCH] Move ERT packet type determination earlier. It'll eventually move into baseband. --- firmware/application/app_ert.cpp | 9 ++++++++- firmware/application/app_ert.hpp | 11 +++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/firmware/application/app_ert.cpp b/firmware/application/app_ert.cpp index 785f133c..39e2632c 100644 --- a/firmware/application/app_ert.cpp +++ b/firmware/application/app_ert.cpp @@ -99,7 +99,14 @@ void ERTView::on_show() { const auto message = static_cast(p); rtc::RTC datetime; rtcGetTime(&RTCD1, &datetime); - const ert::Packet packet { datetime, message->packet.preamble, message->packet.payload, message->packet.bits_received }; + ert::Packet::Type packet_type = ert::Packet::Type::Unknown; + if( message->packet.preamble == 0x1f2a60 ) { + packet_type = ert::Packet::Type::SCM; + } else if( message->packet.preamble == 0x555516a3 ) { + packet_type = ert::Packet::Type::IDM; + } + + const ert::Packet packet { datetime, packet_type, message->packet.payload, message->packet.bits_received }; if( this->model.on_packet(packet) ) { this->on_packet(packet); } diff --git a/firmware/application/app_ert.hpp b/firmware/application/app_ert.hpp index 8ca08d19..4230483e 100644 --- a/firmware/application/app_ert.hpp +++ b/firmware/application/app_ert.hpp @@ -56,7 +56,7 @@ public: Packet( const rtc::RTC& received_at, - const uint64_t preamble, + const Type type, const std::bitset<1024>& payload, const size_t payload_length ) : payload_ { payload }, @@ -64,13 +64,8 @@ public: received_at_ { received_at }, decoder_ { payload_, payload_length_ }, reader_ { decoder_ }, - type_ { Type::Unknown } + type_ { type } { - if( preamble == 0x1f2a60 ) { - type_ = Type::SCM; - } else if( preamble == 0x555516a3 ) { - type_ = Type::IDM; - } } size_t length() const; @@ -91,7 +86,7 @@ private: const rtc::RTC received_at_; const ManchesterDecoder decoder_; const Reader reader_; - Type type_; + const Type type_; const ID invalid_id = 0; const Consumption invalid_consumption = 0;