Complete FSKProcessor's trip to being AISProcessor.

This commit is contained in:
Jared Boone 2015-11-10 14:07:07 -08:00
parent 111a5f10c0
commit 981c2fbfbd
7 changed files with 25 additions and 61 deletions

View File

@ -497,9 +497,9 @@ ReceiverView::~ReceiverView() {
void ReceiverView::on_show() {
auto& message_map = context().message_map();
message_map.register_handler(Message::ID::FSKPacket,
message_map.register_handler(Message::ID::AISPacket,
[this](Message* const p) {
const auto message = static_cast<const FSKPacketMessage*>(p);
const auto message = static_cast<const AISPacketMessage*>(p);
this->on_packet_ais(*message);
}
);
@ -507,10 +507,10 @@ void ReceiverView::on_show() {
void ReceiverView::on_hide() {
auto& message_map = context().message_map();
message_map.unregister_handler(Message::ID::FSKPacket);
message_map.unregister_handler(Message::ID::AISPacket);
}
void ReceiverView::on_packet_ais(const FSKPacketMessage& message) {
void ReceiverView::on_packet_ais(const AISPacketMessage& message) {
const auto result = baseband::ais::packet_decode(message.packet.payload, message.packet.bits_received);
auto console = reinterpret_cast<Console*>(widget_content.get());

View File

@ -472,7 +472,7 @@ private:
// void on_baseband_oversampling_changed(int32_t v);
void on_edit_frequency();
void on_packet_ais(const FSKPacketMessage& message);
void on_packet_ais(const AISPacketMessage& message);
};
} /* namespace ui */

View File

@ -137,7 +137,7 @@ CPPSRC = main.cpp \
proc_am_audio.cpp \
proc_nfm_audio.cpp \
proc_wfm_audio.cpp \
proc_fsk.cpp \
proc_ais.cpp \
proc_wideband_spectrum.cpp \
dsp_squelch.cpp \
clock_recovery.cpp \

View File

@ -55,7 +55,7 @@
#include "proc_am_audio.hpp"
#include "proc_nfm_audio.hpp"
#include "proc_wfm_audio.hpp"
#include "proc_fsk.hpp"
#include "proc_ais.hpp"
#include "proc_wideband_spectrum.hpp"
#include "clock_recovery.hpp"
@ -312,7 +312,7 @@ int main(void) {
break;
case 3:
baseband_processor = new FSKProcessor(message_handlers);
baseband_processor = new AISProcessor();
break;
case 4:

View File

@ -19,49 +19,21 @@
* Boston, MA 02110-1301, USA.
*/
#include "proc_fsk.hpp"
#include "ais_baseband.hpp"
#include "proc_ais.hpp"
#include "portapack_shared_memory.hpp"
#include "i2s.hpp"
using namespace lpc43xx;
FSKProcessor::FSKProcessor(
MessageHandlerMap& message_handlers
) : message_handlers(message_handlers)
{
message_handlers.register_handler(Message::ID::FSKConfiguration,
[this](const Message* const p) {
auto m = reinterpret_cast<const FSKConfigurationMessage*>(p);
this->configure(m->configuration);
}
);
}
FSKProcessor::~FSKProcessor() {
message_handlers.unregister_handler(Message::ID::FSKConfiguration);
}
void FSKProcessor::configure(const FSKConfiguration new_configuration) {
decimator.set_decimation_factor(ChannelDecimator::DecimationFactor::By32);
mf.configure(baseband::ais::rrc_taps_76k8_4t_p, 4);
clock_recovery.configure(new_configuration.symbol_rate * 2, new_configuration.symbol_rate, { 0.0555f });
packet_builder.configure(
{ new_configuration.access_code, new_configuration.access_code_length, new_configuration.access_code_tolerance },
{ new_configuration.unstuffing_pattern, new_configuration.unstuffing_length }
);
}
void FSKProcessor::execute(buffer_c8_t buffer) {
void AISProcessor::execute(buffer_c8_t buffer) {
/* 2.4576MHz, 2048 samples */
auto decimator_out = decimator.execute(buffer);
/* 76.8kHz, 64 samples */
feed_channel_stats(decimator_out);
/* No spectrum display while FSK decoding.
/* No spectrum display while AIS decoding.
feed_channel_spectrum(
channel,
decimator_out.sampling_rate * channel_filter_taps.pass_frequency_normalized,
@ -83,7 +55,7 @@ void FSKProcessor::execute(buffer_c8_t buffer) {
i2s::i2s0::tx_mute();
}
void FSKProcessor::consume_symbol(
void AISProcessor::consume_symbol(
const float raw_symbol
) {
const uint_fast8_t sliced_symbol = (raw_symbol >= 0.0f) ? 1 : 0;
@ -92,11 +64,11 @@ void FSKProcessor::consume_symbol(
packet_builder.execute(decoded_symbol);
}
void FSKProcessor::payload_handler(
void AISProcessor::payload_handler(
const std::bitset<1024>& payload,
const size_t bits_received
) {
FSKPacketMessage message;
AISPacketMessage message;
message.packet.payload = payload;
message.packet.bits_received = bits_received;
shared_memory.application_queue.push(message);

View File

@ -19,8 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef __PROC_FSK_H__
#define __PROC_FSK_H__
#ifndef __PROC_AIS_H__
#define __PROC_AIS_H__
#include "baseband_processor.hpp"
@ -39,15 +39,10 @@
#include "ais_baseband.hpp"
class FSKProcessor : public BasebandProcessor {
class AISProcessor : public BasebandProcessor {
public:
using payload_t = std::bitset<1024>;
FSKProcessor(MessageHandlerMap& message_handlers);
~FSKProcessor();
void configure(const FSKConfiguration new_configuration);
void execute(buffer_c8_t buffer) override;
private:
@ -68,10 +63,8 @@ private:
}
};
MessageHandlerMap& message_handlers;
void consume_symbol(const float symbol);
void payload_handler(const payload_t& payload, const size_t bits_received);
};
#endif/*__PROC_FSK_H__*/
#endif/*__PROC_AIS_H__*/

View File

@ -44,8 +44,8 @@ public:
AudioStatistics = 4,
BasebandConfiguration = 5,
FSKConfiguration = 6,
FSKPacket = 7,
Shutdown = 8,
AISPacket = 7,
MAX
};
@ -207,7 +207,6 @@ struct FSKConfiguration {
static_assert(sizeof(FSKConfiguration) == (6 * 4), "sizeof(FSKConfiguration) is wild");
class FSKConfigurationMessage : public Message {
public:
constexpr FSKConfigurationMessage(
FSKConfiguration configuration
) : Message { ID::FSKConfiguration },
@ -220,24 +219,24 @@ public:
#include <bitset>
struct FSKPacket {
struct AISPacket {
std::bitset<1024> payload;
size_t bits_received;
FSKPacket(
AISPacket(
) : bits_received { 0 }
{
}
};
class FSKPacketMessage : public Message {
class AISPacketMessage : public Message {
public:
FSKPacketMessage(
) : Message { ID::FSKPacket }
AISPacketMessage(
) : Message { ID::AISPacket }
{
}
FSKPacket packet;
AISPacket packet;
};
class ShutdownMessage : public Message {