mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-01-12 23:33:56 +00:00
Move ERT packet type to its rightful place.
No longer mixed up with Message types.
This commit is contained in:
parent
7de187e267
commit
eb1402764e
@ -81,14 +81,14 @@ void ERTView::on_hide() {
|
|||||||
void ERTView::on_packet(const ert::Packet& packet) {
|
void ERTView::on_packet(const ert::Packet& packet) {
|
||||||
std::string msg;
|
std::string msg;
|
||||||
switch(packet.type()) {
|
switch(packet.type()) {
|
||||||
case ERTPacketMessage::Type::SCM:
|
case ert::Packet::Type::SCM:
|
||||||
msg += "SCM ";
|
msg += "SCM ";
|
||||||
msg += to_string_dec_uint(packet.id(), 10);
|
msg += to_string_dec_uint(packet.id(), 10);
|
||||||
msg += " ";
|
msg += " ";
|
||||||
msg += to_string_dec_uint(packet.consumption(), 10);
|
msg += to_string_dec_uint(packet.consumption(), 10);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ERTPacketMessage::Type::IDM:
|
case ert::Packet::Type::IDM:
|
||||||
msg += "IDM ";
|
msg += "IDM ";
|
||||||
msg += to_string_dec_uint(packet.id(), 10);
|
msg += to_string_dec_uint(packet.id(), 10);
|
||||||
msg += " ";
|
msg += " ";
|
||||||
|
@ -98,7 +98,7 @@ void ERTProcessor::scm_handler(
|
|||||||
const baseband::Packet& packet
|
const baseband::Packet& packet
|
||||||
) {
|
) {
|
||||||
ERTPacketMessage message;
|
ERTPacketMessage message;
|
||||||
message.type = ERTPacketMessage::Type::SCM;
|
message.type = ert::Packet::Type::SCM;
|
||||||
message.packet = packet;
|
message.packet = packet;
|
||||||
shared_memory.application_queue.push(message);
|
shared_memory.application_queue.push(message);
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ void ERTProcessor::idm_handler(
|
|||||||
const baseband::Packet& packet
|
const baseband::Packet& packet
|
||||||
) {
|
) {
|
||||||
ERTPacketMessage message;
|
ERTPacketMessage message;
|
||||||
message.type = ERTPacketMessage::Type::IDM;
|
message.type = ert::Packet::Type::IDM;
|
||||||
message.packet = packet;
|
message.packet = packet;
|
||||||
shared_memory.application_queue.push(message);
|
shared_memory.application_queue.push(message);
|
||||||
}
|
}
|
||||||
|
@ -37,27 +37,27 @@ rtc::RTC Packet::received_at() const {
|
|||||||
return received_at_;
|
return received_at_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ERTPacketMessage::Type Packet::type() const {
|
Packet::Type Packet::type() const {
|
||||||
return type_;
|
return type_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID Packet::id() const {
|
ID Packet::id() const {
|
||||||
if( type() == ERTPacketMessage::Type::SCM ) {
|
if( type() == Type::SCM ) {
|
||||||
const auto msb = reader_.read(0, 2);
|
const auto msb = reader_.read(0, 2);
|
||||||
const auto lsb = reader_.read(35, 24);
|
const auto lsb = reader_.read(35, 24);
|
||||||
return (msb << 24) | lsb;
|
return (msb << 24) | lsb;
|
||||||
}
|
}
|
||||||
if( type() == ERTPacketMessage::Type::IDM ) {
|
if( type() == Type::IDM ) {
|
||||||
return reader_.read(5 * 8, 32);
|
return reader_.read(5 * 8, 32);
|
||||||
}
|
}
|
||||||
return invalid_id;
|
return invalid_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Consumption Packet::consumption() const {
|
Consumption Packet::consumption() const {
|
||||||
if( type() == ERTPacketMessage::Type::SCM ) {
|
if( type() == Type::SCM ) {
|
||||||
return reader_.read(11, 24);
|
return reader_.read(11, 24);
|
||||||
}
|
}
|
||||||
if( type() == ERTPacketMessage::Type::IDM ) {
|
if( type() == Type::IDM ) {
|
||||||
return reader_.read(25 * 8, 32);
|
return reader_.read(25 * 8, 32);
|
||||||
}
|
}
|
||||||
return invalid_consumption;
|
return invalid_consumption;
|
||||||
@ -69,9 +69,9 @@ ManchesterFormatted Packet::symbols_formatted() const {
|
|||||||
|
|
||||||
bool Packet::crc_ok() const {
|
bool Packet::crc_ok() const {
|
||||||
switch(type()) {
|
switch(type()) {
|
||||||
case ERTPacketMessage::Type::SCM: return crc_ok_scm();
|
case Type::SCM: return crc_ok_scm();
|
||||||
case ERTPacketMessage::Type::IDM: return crc_ok_idm();
|
case Type::IDM: return crc_ok_idm();
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include "field_reader.hpp"
|
#include "field_reader.hpp"
|
||||||
#include "baseband_packet.hpp"
|
#include "baseband_packet.hpp"
|
||||||
#include "manchester.hpp"
|
#include "manchester.hpp"
|
||||||
#include "message.hpp"
|
|
||||||
|
|
||||||
#include "lpc43xx_cpp.hpp"
|
#include "lpc43xx_cpp.hpp"
|
||||||
using namespace lpc43xx;
|
using namespace lpc43xx;
|
||||||
@ -40,9 +39,15 @@ using Consumption = uint32_t;
|
|||||||
|
|
||||||
class Packet {
|
class Packet {
|
||||||
public:
|
public:
|
||||||
|
enum class Type : uint32_t {
|
||||||
|
Unknown = 0,
|
||||||
|
IDM = 1,
|
||||||
|
SCM = 2,
|
||||||
|
};
|
||||||
|
|
||||||
Packet(
|
Packet(
|
||||||
const rtc::RTC& received_at,
|
const rtc::RTC& received_at,
|
||||||
const ERTPacketMessage::Type type,
|
const Type type,
|
||||||
const baseband::Packet& packet
|
const baseband::Packet& packet
|
||||||
) : packet_ { packet },
|
) : packet_ { packet },
|
||||||
received_at_ { received_at },
|
received_at_ { received_at },
|
||||||
@ -58,7 +63,7 @@ public:
|
|||||||
|
|
||||||
rtc::RTC received_at() const;
|
rtc::RTC received_at() const;
|
||||||
|
|
||||||
ERTPacketMessage::Type type() const;
|
Type type() const;
|
||||||
ID id() const;
|
ID id() const;
|
||||||
Consumption consumption() const;
|
Consumption consumption() const;
|
||||||
|
|
||||||
@ -73,7 +78,7 @@ private:
|
|||||||
const rtc::RTC received_at_;
|
const rtc::RTC received_at_;
|
||||||
const ManchesterDecoder decoder_;
|
const ManchesterDecoder decoder_;
|
||||||
const Reader reader_;
|
const Reader reader_;
|
||||||
const ERTPacketMessage::Type type_;
|
const Type type_;
|
||||||
|
|
||||||
const ID invalid_id = 0;
|
const ID invalid_id = 0;
|
||||||
const Consumption invalid_consumption = 0;
|
const Consumption invalid_consumption = 0;
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "baseband_packet.hpp"
|
#include "baseband_packet.hpp"
|
||||||
|
#include "ert_packet.hpp"
|
||||||
|
|
||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
|
|
||||||
@ -238,13 +239,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class Type : uint32_t {
|
ert::Packet::Type type { ert::Packet::Type::Unknown };
|
||||||
Unknown = 0,
|
|
||||||
IDM = 1,
|
|
||||||
SCM = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
Type type { Type::Unknown };
|
|
||||||
|
|
||||||
baseband::Packet packet;
|
baseband::Packet packet;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user