mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-28 08:49:45 -05:00
Push SignalType inside tpms::Packet.
This commit is contained in:
parent
83e4aec49c
commit
04c472e802
@ -191,12 +191,12 @@ void TPMSAppView::set_parent_rect(const Rect new_parent_rect) {
|
||||
recent_entries_view.set_parent_rect({ 0, 0, new_parent_rect.width(), new_parent_rect.height() });
|
||||
}
|
||||
|
||||
void TPMSAppView::on_packet(const tpms::SignalType signal_type, const tpms::Packet& packet) {
|
||||
void TPMSAppView::on_packet(const tpms::Packet& packet) {
|
||||
if( logger ) {
|
||||
logger->on_packet(packet, target_frequency());
|
||||
}
|
||||
|
||||
const auto reading_opt = packet.reading(signal_type);
|
||||
const auto reading_opt = packet.reading();
|
||||
if( reading_opt.is_valid() ) {
|
||||
const auto reading = reading_opt.value();
|
||||
recent.on_packet({ reading.type(), reading.id() }, reading);
|
||||
|
@ -111,8 +111,8 @@ private:
|
||||
Message::ID::TPMSPacket,
|
||||
[this](Message* const p) {
|
||||
const auto message = static_cast<const TPMSPacketMessage*>(p);
|
||||
const tpms::Packet packet { message->packet };
|
||||
this->on_packet(message->signal_type, packet);
|
||||
const tpms::Packet packet { message->packet, message->signal_type };
|
||||
this->on_packet(packet);
|
||||
}
|
||||
};
|
||||
|
||||
@ -121,7 +121,7 @@ private:
|
||||
|
||||
TPMSRecentEntriesView recent_entries_view { recent };
|
||||
|
||||
void on_packet(const tpms::SignalType signal_type, const tpms::Packet& packet);
|
||||
void on_packet(const tpms::Packet& packet);
|
||||
void on_show_list();
|
||||
|
||||
uint32_t target_frequency() const;
|
||||
|
@ -33,8 +33,8 @@ ManchesterFormatted Packet::symbols_formatted() const {
|
||||
return format_manchester(decoder_);
|
||||
}
|
||||
|
||||
Optional<Reading> Packet::reading(const SignalType signal_type) const {
|
||||
if( signal_type == SignalType::FSK_19k2_Schrader ) {
|
||||
Optional<Reading> Packet::reading() const {
|
||||
if( signal_type() == SignalType::FSK_19k2_Schrader ) {
|
||||
const auto length = crc_valid_length();
|
||||
|
||||
switch(length) {
|
||||
@ -67,7 +67,7 @@ Optional<Reading> Packet::reading(const SignalType signal_type) const {
|
||||
}
|
||||
}
|
||||
|
||||
if( signal_type == SignalType::OOK_8k192_Schrader ) {
|
||||
if( signal_type() == SignalType::OOK_8k192_Schrader ) {
|
||||
const auto flags = reader_.read(0, 3);
|
||||
const auto checksum = reader_.read(35, 2);
|
||||
|
||||
@ -80,7 +80,7 @@ Optional<Reading> Packet::reading(const SignalType signal_type) const {
|
||||
};
|
||||
}
|
||||
|
||||
if( signal_type == SignalType::OOK_8k4_Schrader ) {
|
||||
if( signal_type() == SignalType::OOK_8k4_Schrader ) {
|
||||
return Reading {
|
||||
Reading::Type::GMC_96,
|
||||
reader_.read(20, 32),
|
||||
|
@ -135,23 +135,27 @@ private:
|
||||
class Packet {
|
||||
public:
|
||||
constexpr Packet(
|
||||
const baseband::Packet& packet
|
||||
const baseband::Packet& packet,
|
||||
const SignalType signal_type
|
||||
) : packet_ { packet },
|
||||
signal_type_ { signal_type },
|
||||
decoder_ { packet_, 0 },
|
||||
reader_ { decoder_ }
|
||||
{
|
||||
}
|
||||
|
||||
SignalType signal_type() const { return signal_type_; }
|
||||
Timestamp received_at() const;
|
||||
|
||||
ManchesterFormatted symbols_formatted() const;
|
||||
|
||||
Optional<Reading> reading(const SignalType signal_type) const;
|
||||
Optional<Reading> reading() const;
|
||||
|
||||
private:
|
||||
using Reader = FieldReader<ManchesterDecoder, BitRemapNone>;
|
||||
|
||||
const baseband::Packet packet_;
|
||||
const SignalType signal_type_;
|
||||
const ManchesterDecoder decoder_;
|
||||
|
||||
const Reader reader_;
|
||||
|
Loading…
Reference in New Issue
Block a user