Move ERT packet type determination earlier.

It'll eventually move into baseband.
This commit is contained in:
Jared Boone 2015-12-06 15:36:23 -08:00
parent 2a55030d4e
commit 9e004d4754
2 changed files with 11 additions and 9 deletions

View File

@ -99,7 +99,14 @@ void ERTView::on_show() {
const auto message = static_cast<const ERTPacketMessage*>(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);
}

View File

@ -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;