mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-25 07:19:28 -05:00
Push packet timestamping earlier in packet handling.
Ideally, it'd get pushed back into baseband, and baseband would correct for the length of the packet (based on preamble/access code match timestamp minus preamble/access code duration) to give the exact time the packet started.
This commit is contained in:
parent
0909cdb31e
commit
bb3cb6f080
@ -220,6 +220,10 @@ bool Packet::is_valid() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
rtc::RTC Packet::received_at() const {
|
||||
return received_at_;
|
||||
}
|
||||
|
||||
uint32_t Packet::message_id() const {
|
||||
return field_.read(0, 6);
|
||||
}
|
||||
@ -303,7 +307,7 @@ bool AISModel::on_packet(const baseband::ais::Packet& packet) {
|
||||
entry += (nibble >= 10) ? ('W' + nibble) : ('0' + nibble);
|
||||
}
|
||||
|
||||
log_file.write_entry(entry);
|
||||
log_file.write_entry(packet.received_at(), entry);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -318,7 +322,9 @@ void AISView::on_show() {
|
||||
message_map.register_handler(Message::ID::AISPacket,
|
||||
[this](Message* const p) {
|
||||
const auto message = static_cast<const AISPacketMessage*>(p);
|
||||
const baseband::ais::Packet packet { message->packet.payload, message->packet.bits_received };
|
||||
rtc::RTC datetime;
|
||||
rtcGetTime(&RTCD1, &datetime);
|
||||
const baseband::ais::Packet packet { datetime, message->packet.payload, message->packet.bits_received };
|
||||
if( this->model.on_packet(packet) ) {
|
||||
this->log(packet);
|
||||
}
|
||||
|
@ -27,6 +27,9 @@
|
||||
#include "log_file.hpp"
|
||||
#include "field_reader.hpp"
|
||||
|
||||
#include "lpc43xx_cpp.hpp"
|
||||
using namespace lpc43xx;
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
@ -61,10 +64,12 @@ using MMSI = uint32_t;
|
||||
class Packet {
|
||||
public:
|
||||
constexpr Packet(
|
||||
const rtc::RTC& received_at,
|
||||
const std::bitset<1024>& payload,
|
||||
const size_t payload_length
|
||||
) : payload_ { payload },
|
||||
payload_length_ { payload_length },
|
||||
received_at_ { received_at },
|
||||
field_ { payload_ }
|
||||
{
|
||||
}
|
||||
@ -73,6 +78,8 @@ public:
|
||||
|
||||
bool is_valid() const;
|
||||
|
||||
rtc::RTC received_at() const;
|
||||
|
||||
uint32_t message_id() const;
|
||||
MMSI user_id() const;
|
||||
MMSI source_id() const;
|
||||
@ -89,6 +96,7 @@ public:
|
||||
private:
|
||||
const std::bitset<1024> payload_;
|
||||
const size_t payload_length_;
|
||||
const rtc::RTC received_at_;
|
||||
const FieldReader field_;
|
||||
};
|
||||
|
||||
|
@ -26,6 +26,9 @@ using namespace portapack;
|
||||
|
||||
#include "manchester.hpp"
|
||||
|
||||
#include "lpc43xx_cpp.hpp"
|
||||
using namespace lpc43xx;
|
||||
|
||||
ERTModel::ERTModel() {
|
||||
receiver_model.set_baseband_configuration({
|
||||
.mode = 6,
|
||||
@ -38,6 +41,9 @@ ERTModel::ERTModel() {
|
||||
}
|
||||
|
||||
std::string ERTModel::on_packet(const ERTPacketMessage& message) {
|
||||
rtc::RTC received_at;
|
||||
rtcGetTime(&RTCD1, &received_at);
|
||||
|
||||
std::string entry;
|
||||
|
||||
if( message.packet.preamble == 0x555516a3 ) {
|
||||
@ -55,7 +61,7 @@ std::string ERTModel::on_packet(const ERTPacketMessage& message) {
|
||||
entry += hex_formatted.errors;
|
||||
|
||||
if( log_file.is_ready() ) {
|
||||
log_file.write_entry(entry);
|
||||
log_file.write_entry(received_at, entry);
|
||||
}
|
||||
|
||||
return entry;
|
||||
|
@ -26,6 +26,9 @@ using namespace portapack;
|
||||
|
||||
#include "string_format.hpp"
|
||||
|
||||
#include "lpc43xx_cpp.hpp"
|
||||
using namespace lpc43xx;
|
||||
|
||||
TPMSModel::TPMSModel() {
|
||||
receiver_model.set_baseband_configuration({
|
||||
.mode = 5,
|
||||
@ -38,6 +41,9 @@ TPMSModel::TPMSModel() {
|
||||
}
|
||||
|
||||
ManchesterFormatted TPMSModel::on_packet(const TPMSPacketMessage& message) {
|
||||
rtc::RTC received_at;
|
||||
rtcGetTime(&RTCD1, &received_at);
|
||||
|
||||
const ManchesterDecoder decoder(message.packet.payload, message.packet.bits_received, 1);
|
||||
const auto hex_formatted = format_manchester(decoder);
|
||||
|
||||
@ -47,7 +53,7 @@ ManchesterFormatted TPMSModel::on_packet(const TPMSPacketMessage& message) {
|
||||
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(entry);
|
||||
log_file.write_entry(received_at, entry);
|
||||
}
|
||||
|
||||
return hex_formatted;
|
||||
|
@ -53,9 +53,7 @@ bool LogFile::is_ready() {
|
||||
return !f_error(&f);
|
||||
}
|
||||
|
||||
bool LogFile::write_entry(const std::string entry) {
|
||||
rtc::RTC datetime;
|
||||
rtcGetTime(&RTCD1, &datetime);
|
||||
bool LogFile::write_entry(const rtc::RTC& datetime, const std::string entry) {
|
||||
std::string timestamp =
|
||||
to_string_dec_uint(datetime.year(), 4, '0') +
|
||||
to_string_dec_uint(datetime.month(), 2, '0') +
|
||||
|
@ -26,6 +26,9 @@
|
||||
|
||||
#include "ff.h"
|
||||
|
||||
#include "lpc43xx_cpp.hpp"
|
||||
using namespace lpc43xx;
|
||||
|
||||
class LogFile {
|
||||
public:
|
||||
~LogFile();
|
||||
@ -34,7 +37,7 @@ public:
|
||||
bool close();
|
||||
bool is_ready();
|
||||
|
||||
bool write_entry(const std::string entry);
|
||||
bool write_entry(const rtc::RTC& datetime, const std::string entry);
|
||||
|
||||
private:
|
||||
FIL f;
|
||||
|
Loading…
Reference in New Issue
Block a user