mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Make tpms::Packet into real type.
This commit is contained in:
parent
feec99ac6a
commit
fbcf784959
@ -28,8 +28,20 @@ using namespace portapack;
|
||||
|
||||
#include "string_format.hpp"
|
||||
|
||||
void TPMSLogger::on_packet(const Timestamp& timestamp, const tpms::Packet& packet) {
|
||||
const auto hex_formatted = format_manchester(packet);
|
||||
namespace tpms {
|
||||
|
||||
Timestamp Packet::received_at() const {
|
||||
return packet_.timestamp();
|
||||
}
|
||||
|
||||
ManchesterFormatted Packet::symbols_formatted() const {
|
||||
return format_manchester(decoder_);
|
||||
}
|
||||
|
||||
} /* namespace tpms */
|
||||
|
||||
void TPMSLogger::on_packet(const tpms::Packet& packet) {
|
||||
const auto hex_formatted = packet.symbols_formatted();
|
||||
|
||||
if( log_file.is_ready() ) {
|
||||
const auto tuning_frequency = receiver_model.tuning_frequency();
|
||||
@ -37,7 +49,7 @@ void TPMSLogger::on_packet(const Timestamp& timestamp, const tpms::Packet& packe
|
||||
const auto tuning_frequency_str = to_string_dec_uint(tuning_frequency, 10);
|
||||
|
||||
std::string entry = tuning_frequency_str + " FSK 38.4 19.2 " + hex_formatted.data + "/" + hex_formatted.errors;
|
||||
log_file.write_entry(timestamp, entry);
|
||||
log_file.write_entry(packet.received_at(), entry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,7 +63,8 @@ TPMSAppView::TPMSAppView() {
|
||||
EventDispatcher::message_map().register_handler(Message::ID::TPMSPacket,
|
||||
[this](Message* const p) {
|
||||
const auto message = static_cast<const TPMSPacketMessage*>(p);
|
||||
this->on_packet(message->packet);
|
||||
const tpms::Packet packet { message->packet };
|
||||
this->on_packet(packet);
|
||||
}
|
||||
);
|
||||
|
||||
@ -72,14 +85,13 @@ void TPMSAppView::set_parent_rect(const Rect new_parent_rect) {
|
||||
console.set_parent_rect({ 0, 0, new_parent_rect.width(), new_parent_rect.height() });
|
||||
}
|
||||
|
||||
void TPMSAppView::on_packet(const baseband::Packet& baseband_packet) {
|
||||
const tpms::Packet tpms_packet { baseband_packet, 1 };
|
||||
this->logger.on_packet(baseband_packet.timestamp(), tpms_packet);
|
||||
this->draw(tpms_packet);
|
||||
void TPMSAppView::on_packet(const tpms::Packet& packet) {
|
||||
this->logger.on_packet(packet);
|
||||
this->draw(packet);
|
||||
}
|
||||
|
||||
void TPMSAppView::draw(const tpms::Packet& packet) {
|
||||
const auto hex_formatted = format_manchester(packet);
|
||||
const auto hex_formatted = packet.symbols_formatted();
|
||||
console.writeln(hex_formatted.data.substr(0, 240 / 8));
|
||||
}
|
||||
|
||||
|
@ -30,13 +30,29 @@
|
||||
|
||||
namespace tpms {
|
||||
|
||||
using Packet = ManchesterDecoder;
|
||||
class Packet {
|
||||
public:
|
||||
constexpr Packet(
|
||||
const baseband::Packet& packet
|
||||
) : packet_ { packet },
|
||||
decoder_ { packet_, 1 }
|
||||
{
|
||||
}
|
||||
|
||||
Timestamp received_at() const;
|
||||
|
||||
ManchesterFormatted symbols_formatted() const;
|
||||
|
||||
private:
|
||||
const baseband::Packet packet_;
|
||||
const ManchesterDecoder decoder_;
|
||||
};
|
||||
|
||||
} /* namespace tpms */
|
||||
|
||||
class TPMSLogger {
|
||||
public:
|
||||
void on_packet(const Timestamp& timestamp, const tpms::Packet& packet);
|
||||
void on_packet(const tpms::Packet& packet);
|
||||
|
||||
private:
|
||||
LogFile log_file { "tpms.txt" };
|
||||
@ -56,7 +72,7 @@ private:
|
||||
|
||||
Console console;
|
||||
|
||||
void on_packet(const baseband::Packet& packet);
|
||||
void on_packet(const tpms::Packet& packet);
|
||||
void draw(const tpms::Packet& packet);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user