Rename ::Packet to baseband::Packet. Remove IPC packet types.

This commit is contained in:
Jared Boone 2015-12-08 15:15:51 -08:00
parent 280acfd227
commit d0d97e92cb
15 changed files with 69 additions and 76 deletions

View File

@ -33,7 +33,7 @@ using namespace portapack;
namespace baseband {
namespace ais {
using CRCFieldReader = ::FieldReader<::Packet, BitRemapNone>;
using CRCFieldReader = ::FieldReader<baseband::Packet, BitRemapNone>;
struct PacketLengthRange {
constexpr PacketLengthRange(
@ -320,7 +320,7 @@ void AISView::on_show() {
const auto message = static_cast<const AISPacketMessage*>(p);
rtc::RTC datetime;
rtcGetTime(&RTCD1, &datetime);
const baseband::ais::Packet packet { datetime, message->packet.packet };
const baseband::ais::Packet packet { datetime, message->packet };
if( this->model.on_packet(packet) ) {
this->on_packet(packet);
}

View File

@ -26,7 +26,7 @@
#include "message.hpp"
#include "log_file.hpp"
#include "field_reader.hpp"
#include "packet.hpp"
#include "baseband_packet.hpp"
#include "lpc43xx_cpp.hpp"
using namespace lpc43xx;
@ -61,7 +61,7 @@ class Packet {
public:
constexpr Packet(
const rtc::RTC& received_at,
const ::Packet& packet
const baseband::Packet& packet
) : packet_ { packet },
received_at_ { received_at },
field_ { packet_ }
@ -90,9 +90,9 @@ public:
bool crc_ok() const;
private:
using Reader = FieldReader<::Packet, BitRemapByteReverse>;
using Reader = FieldReader<baseband::Packet, BitRemapByteReverse>;
const ::Packet packet_;
const baseband::Packet packet_;
const rtc::RTC received_at_;
const Reader field_;

View File

@ -46,27 +46,27 @@ rtc::RTC Packet::received_at() const {
return received_at_;
}
ERTPacket::Type Packet::type() const {
ERTPacketMessage::Type Packet::type() const {
return type_;
}
ID Packet::id() const {
if( type() == ERTPacket::Type::SCM ) {
if( type() == ERTPacketMessage::Type::SCM ) {
const auto msb = reader_.read(0, 2);
const auto lsb = reader_.read(35, 24);
return (msb << 24) | lsb;
}
if( type() == ERTPacket::Type::IDM ) {
if( type() == ERTPacketMessage::Type::IDM ) {
return reader_.read(5 * 8, 32);
}
return invalid_id;
}
Consumption Packet::consumption() const {
if( type() == ERTPacket::Type::SCM ) {
if( type() == ERTPacketMessage::Type::SCM ) {
return reader_.read(11, 24);
}
if( type() == ERTPacket::Type::IDM ) {
if( type() == ERTPacketMessage::Type::IDM ) {
return reader_.read(25 * 8, 32);
}
return invalid_consumption;
@ -78,8 +78,8 @@ ManchesterFormatted Packet::symbols_formatted() const {
bool Packet::crc_ok() const {
switch(type()) {
case ERTPacket::Type::SCM: return crc_ok_scm();
case ERTPacket::Type::IDM: return crc_ok_idm();
case ERTPacketMessage::Type::SCM: return crc_ok_scm();
case ERTPacketMessage::Type::IDM: return crc_ok_idm();
default: return false;
}
}
@ -135,7 +135,7 @@ void ERTView::on_show() {
const auto message = static_cast<const ERTPacketMessage*>(p);
rtc::RTC datetime;
rtcGetTime(&RTCD1, &datetime);
const ert::Packet packet { datetime, message->packet.type, message->packet.packet };
const ert::Packet packet { datetime, message->type, message->packet };
if( this->model.on_packet(packet) ) {
this->on_packet(packet);
}
@ -153,14 +153,14 @@ void ERTView::on_hide() {
void ERTView::on_packet(const ert::Packet& packet) {
std::string msg;
switch(packet.type()) {
case ERTPacket::Type::SCM:
case ERTPacketMessage::Type::SCM:
msg += "SCM ";
msg += to_string_dec_uint(packet.id(), 10);
msg += " ";
msg += to_string_dec_uint(packet.consumption(), 10);
break;
case ERTPacket::Type::IDM:
case ERTPacketMessage::Type::IDM:
msg += "IDM ";
msg += to_string_dec_uint(packet.id(), 10);
msg += " ";

View File

@ -27,7 +27,7 @@
#include "log_file.hpp"
#include "manchester.hpp"
#include "field_reader.hpp"
#include "packet.hpp"
#include "baseband_packet.hpp"
#include "lpc43xx_cpp.hpp"
using namespace lpc43xx;
@ -45,8 +45,8 @@ class Packet {
public:
Packet(
const rtc::RTC& received_at,
const ERTPacket::Type type,
const ::Packet& packet
const ERTPacketMessage::Type type,
const baseband::Packet& packet
) : packet_ { packet },
received_at_ { received_at },
decoder_ { packet_ },
@ -61,7 +61,7 @@ public:
rtc::RTC received_at() const;
ERTPacket::Type type() const;
ERTPacketMessage::Type type() const;
ID id() const;
Consumption consumption() const;
@ -72,11 +72,11 @@ public:
private:
using Reader = FieldReader<ManchesterDecoder, BitRemapNone>;
const ::Packet packet_;
const baseband::Packet packet_;
const rtc::RTC received_at_;
const ManchesterDecoder decoder_;
const Reader reader_;
const ERTPacket::Type type_;
const ERTPacketMessage::Type type_;
const ID invalid_id = 0;
const Consumption invalid_consumption = 0;

View File

@ -44,7 +44,7 @@ ManchesterFormatted TPMSModel::on_packet(const TPMSPacketMessage& message) {
rtc::RTC received_at;
rtcGetTime(&RTCD1, &received_at);
const ManchesterDecoder decoder(message.packet.packet, 1);
const ManchesterDecoder decoder(message.packet, 1);
const auto hex_formatted = format_manchester(decoder);
if( log_file.is_ready() ) {

View File

@ -27,7 +27,7 @@
#include <bitset>
#include <string>
#include "packet.hpp"
#include "baseband_packet.hpp"
class ManchesterDecoder {
public:
@ -37,7 +37,7 @@ public:
};
constexpr ManchesterDecoder(
const ::Packet& packet,
const baseband::Packet& packet,
const size_t sense = 0
) : packet { packet },
sense { sense }
@ -49,7 +49,7 @@ public:
size_t symbols_count() const;
private:
const ::Packet& packet;
const baseband::Packet& packet;
const size_t sense;
};

View File

@ -28,7 +28,7 @@
#include <functional>
#include "bit_pattern.hpp"
#include "packet.hpp"
#include "baseband_packet.hpp"
struct NeverMatch {
bool operator()(const BitHistory&, const size_t) const {
@ -47,7 +47,7 @@ struct FixedLength {
template<typename PreambleMatcher, typename UnstuffMatcher, typename EndMatcher>
class PacketBuilder {
public:
using PayloadHandlerFunc = std::function<void(const ::Packet& packet)>;
using PayloadHandlerFunc = std::function<void(const baseband::Packet& packet)>;
PacketBuilder(
const PreambleMatcher preamble_matcher,
@ -122,7 +122,7 @@ private:
EndMatcher end;
State state { State::Preamble };
::Packet packet;
baseband::Packet packet;
void reset_state() {
packet.clear();

View File

@ -60,9 +60,9 @@ void AISProcessor::consume_symbol(
}
void AISProcessor::payload_handler(
const ::Packet& packet
const baseband::Packet& packet
) {
AISPacketMessage message;
message.packet.packet = packet;
message.packet = packet;
shared_memory.application_queue.push(message);
}

View File

@ -30,7 +30,7 @@
#include "clock_recovery.hpp"
#include "symbol_coding.hpp"
#include "packet_builder.hpp"
#include "packet.hpp"
#include "baseband_packet.hpp"
#include "message.hpp"
@ -57,13 +57,13 @@ private:
{ 0b0101010101111110, 16, 1 },
{ 0b111110, 6 },
{ 0b01111110, 8 },
[this](const ::Packet& packet) {
[this](const baseband::Packet& packet) {
this->payload_handler(packet);
}
};
void consume_symbol(const float symbol);
void payload_handler(const ::Packet& packet);
void payload_handler(const baseband::Packet& packet);
};
#endif/*__PROC_AIS_H__*/

View File

@ -95,19 +95,19 @@ void ERTProcessor::consume_symbol(
}
void ERTProcessor::scm_handler(
const ::Packet& packet
const baseband::Packet& packet
) {
ERTPacketMessage message;
message.packet.type = ERTPacket::Type::SCM;
message.packet.packet = packet;
message.type = ERTPacketMessage::Type::SCM;
message.packet = packet;
shared_memory.application_queue.push(message);
}
void ERTProcessor::idm_handler(
const ::Packet& packet
const baseband::Packet& packet
) {
ERTPacketMessage message;
message.packet.type = ERTPacket::Type::IDM;
message.packet.packet = packet;
message.type = ERTPacketMessage::Type::IDM;
message.packet = packet;
shared_memory.application_queue.push(message);
}

View File

@ -29,7 +29,7 @@
#include "clock_recovery.hpp"
#include "symbol_coding.hpp"
#include "packet_builder.hpp"
#include "packet.hpp"
#include "baseband_packet.hpp"
#include "message.hpp"
@ -72,7 +72,7 @@ private:
{ scm_preamble_and_sync_manchester, scm_preamble_and_sync_length, 1 },
{ },
{ scm_payload_length_max },
[this](const ::Packet& packet) {
[this](const baseband::Packet& packet) {
this->scm_handler(packet);
}
};
@ -81,14 +81,14 @@ private:
{ idm_preamble_and_sync_manchester, idm_preamble_and_sync_length, 1 },
{ },
{ idm_payload_length_max },
[this](const ::Packet& packet) {
[this](const baseband::Packet& packet) {
this->idm_handler(packet);
}
};
void consume_symbol(const float symbol);
void scm_handler(const ::Packet& packet);
void idm_handler(const ::Packet& packet);
void scm_handler(const baseband::Packet& packet);
void idm_handler(const baseband::Packet& packet);
float sum_half_period[2];
float sum_period[3];

View File

@ -58,9 +58,9 @@ void TPMSProcessor::consume_symbol(
}
void TPMSProcessor::payload_handler(
const ::Packet& packet
const baseband::Packet& packet
) {
TPMSPacketMessage message;
message.packet.packet = packet;
message.packet = packet;
shared_memory.application_queue.push(message);
}

View File

@ -30,7 +30,7 @@
#include "clock_recovery.hpp"
#include "symbol_coding.hpp"
#include "packet_builder.hpp"
#include "packet.hpp"
#include "baseband_packet.hpp"
#include "message.hpp"
@ -64,13 +64,13 @@ private:
{ 0b010101010101010101010101010110, 30, 1 },
{ },
{ 256 },
[this](const ::Packet& packet) {
[this](const baseband::Packet& packet) {
this->payload_handler(packet);
}
};
void consume_symbol(const float symbol);
void payload_handler(const ::Packet& packet);
void payload_handler(const baseband::Packet& packet);
};
#endif/*__PROC_TPMS_H__*/

View File

@ -19,12 +19,14 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef __PACKET_H__
#define __PACKET_H__
#ifndef __BASEBAND_PACKET_H__
#define __BASEBAND_PACKET_H__
#include <cstddef>
#include <bitset>
namespace baseband {
class Packet {
public:
void add(const bool symbol) {
@ -54,4 +56,6 @@ private:
size_t count { 0 };
};
#endif/*__PACKET_H__*/
} /* namespace baseband */
#endif/*__BASEBAND_PACKET_H__*/

View File

@ -27,7 +27,7 @@
#include <array>
#include <functional>
#include "packet.hpp"
#include "baseband_packet.hpp"
#include "utility.hpp"
@ -203,10 +203,6 @@ public:
ChannelSpectrum spectrum;
};
struct AISPacket {
::Packet packet;
};
class AISPacketMessage : public Message {
public:
constexpr AISPacketMessage(
@ -214,11 +210,7 @@ public:
{
}
AISPacket packet;
};
struct TPMSPacket {
::Packet packet;
baseband::Packet packet;
};
class TPMSPacketMessage : public Message {
@ -228,7 +220,7 @@ public:
{
}
TPMSPacket packet;
baseband::Packet packet;
};
class ShutdownMessage : public Message {
@ -239,17 +231,6 @@ public:
}
};
struct ERTPacket {
enum class Type : uint32_t {
Unknown = 0,
IDM = 1,
SCM = 2,
};
Type type { Type::Unknown };
::Packet packet;
};
class ERTPacketMessage : public Message {
public:
constexpr ERTPacketMessage(
@ -257,7 +238,15 @@ public:
{
}
ERTPacket packet;
enum class Type : uint32_t {
Unknown = 0,
IDM = 1,
SCM = 2,
};
Type type { Type::Unknown };
baseband::Packet packet;
};
class MessageHandlerMap {