mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-04-06 06:05:42 +00: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() });
|
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 ) {
|
if( logger ) {
|
||||||
logger->on_packet(packet, target_frequency());
|
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() ) {
|
if( reading_opt.is_valid() ) {
|
||||||
const auto reading = reading_opt.value();
|
const auto reading = reading_opt.value();
|
||||||
recent.on_packet({ reading.type(), reading.id() }, reading);
|
recent.on_packet({ reading.type(), reading.id() }, reading);
|
||||||
|
@ -111,8 +111,8 @@ private:
|
|||||||
Message::ID::TPMSPacket,
|
Message::ID::TPMSPacket,
|
||||||
[this](Message* const p) {
|
[this](Message* const p) {
|
||||||
const auto message = static_cast<const TPMSPacketMessage*>(p);
|
const auto message = static_cast<const TPMSPacketMessage*>(p);
|
||||||
const tpms::Packet packet { message->packet };
|
const tpms::Packet packet { message->packet, message->signal_type };
|
||||||
this->on_packet(message->signal_type, packet);
|
this->on_packet(packet);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ private:
|
|||||||
|
|
||||||
TPMSRecentEntriesView recent_entries_view { recent };
|
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();
|
void on_show_list();
|
||||||
|
|
||||||
uint32_t target_frequency() const;
|
uint32_t target_frequency() const;
|
||||||
|
@ -33,8 +33,8 @@ ManchesterFormatted Packet::symbols_formatted() const {
|
|||||||
return format_manchester(decoder_);
|
return format_manchester(decoder_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Reading> Packet::reading(const SignalType signal_type) const {
|
Optional<Reading> Packet::reading() const {
|
||||||
if( signal_type == SignalType::FSK_19k2_Schrader ) {
|
if( signal_type() == SignalType::FSK_19k2_Schrader ) {
|
||||||
const auto length = crc_valid_length();
|
const auto length = crc_valid_length();
|
||||||
|
|
||||||
switch(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 flags = reader_.read(0, 3);
|
||||||
const auto checksum = reader_.read(35, 2);
|
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 {
|
return Reading {
|
||||||
Reading::Type::GMC_96,
|
Reading::Type::GMC_96,
|
||||||
reader_.read(20, 32),
|
reader_.read(20, 32),
|
||||||
|
@ -135,23 +135,27 @@ private:
|
|||||||
class Packet {
|
class Packet {
|
||||||
public:
|
public:
|
||||||
constexpr Packet(
|
constexpr Packet(
|
||||||
const baseband::Packet& packet
|
const baseband::Packet& packet,
|
||||||
|
const SignalType signal_type
|
||||||
) : packet_ { packet },
|
) : packet_ { packet },
|
||||||
|
signal_type_ { signal_type },
|
||||||
decoder_ { packet_, 0 },
|
decoder_ { packet_, 0 },
|
||||||
reader_ { decoder_ }
|
reader_ { decoder_ }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SignalType signal_type() const { return signal_type_; }
|
||||||
Timestamp received_at() const;
|
Timestamp received_at() const;
|
||||||
|
|
||||||
ManchesterFormatted symbols_formatted() const;
|
ManchesterFormatted symbols_formatted() const;
|
||||||
|
|
||||||
Optional<Reading> reading(const SignalType signal_type) const;
|
Optional<Reading> reading() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using Reader = FieldReader<ManchesterDecoder, BitRemapNone>;
|
using Reader = FieldReader<ManchesterDecoder, BitRemapNone>;
|
||||||
|
|
||||||
const baseband::Packet packet_;
|
const baseband::Packet packet_;
|
||||||
|
const SignalType signal_type_;
|
||||||
const ManchesterDecoder decoder_;
|
const ManchesterDecoder decoder_;
|
||||||
|
|
||||||
const Reader reader_;
|
const Reader reader_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user