diff --git a/firmware/application/ui_receiver.cpp b/firmware/application/ui_receiver.cpp index bf33cb25..233b17b4 100644 --- a/firmware/application/ui_receiver.cpp +++ b/firmware/application/ui_receiver.cpp @@ -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(p); + const auto message = static_cast(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(widget_content.get()); diff --git a/firmware/application/ui_receiver.hpp b/firmware/application/ui_receiver.hpp index b3f8ff46..aff5ed5b 100644 --- a/firmware/application/ui_receiver.hpp +++ b/firmware/application/ui_receiver.hpp @@ -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 */ diff --git a/firmware/baseband/Makefile b/firmware/baseband/Makefile index 06cb1f27..1e4acdba 100755 --- a/firmware/baseband/Makefile +++ b/firmware/baseband/Makefile @@ -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 \ diff --git a/firmware/baseband/main.cpp b/firmware/baseband/main.cpp index 3c167110..e3d6e153 100755 --- a/firmware/baseband/main.cpp +++ b/firmware/baseband/main.cpp @@ -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: diff --git a/firmware/baseband/proc_fsk.cpp b/firmware/baseband/proc_ais.cpp similarity index 62% rename from firmware/baseband/proc_fsk.cpp rename to firmware/baseband/proc_ais.cpp index fd1e702e..e3005b93 100644 --- a/firmware/baseband/proc_fsk.cpp +++ b/firmware/baseband/proc_ais.cpp @@ -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(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); diff --git a/firmware/baseband/proc_fsk.hpp b/firmware/baseband/proc_ais.hpp similarity index 87% rename from firmware/baseband/proc_fsk.hpp rename to firmware/baseband/proc_ais.hpp index 01b13ad8..e52983f6 100644 --- a/firmware/baseband/proc_fsk.hpp +++ b/firmware/baseband/proc_ais.hpp @@ -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__*/ diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index 1bf74878..07fdd269 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -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 -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 {