From c01597baf2e83add9b7be1c569b2ba07961bebd2 Mon Sep 17 00:00:00 2001 From: Totoo Date: Tue, 18 Nov 2025 14:05:27 +0100 Subject: [PATCH] Pocsag manual baud option (#2870) * baseband part of manual baud control of pocsag * added manual pocsag baud to ui, to fix #2546 * fix adult toys settings filename --- firmware/application/apps/pocsag_app.cpp | 7 ++++-- firmware/application/apps/pocsag_app.hpp | 11 +++++++++ firmware/application/baseband_api.cpp | 4 ++-- firmware/application/baseband_api.hpp | 2 +- .../ui_adult_toys_controller.hpp | 2 +- firmware/baseband/proc_pocsag2.cpp | 24 +++++++++++++++---- firmware/baseband/proc_pocsag2.hpp | 5 ++-- firmware/common/message.hpp | 5 ++-- 8 files changed, 45 insertions(+), 15 deletions(-) diff --git a/firmware/application/apps/pocsag_app.cpp b/firmware/application/apps/pocsag_app.cpp index c89e37960..f2a122d35 100644 --- a/firmware/application/apps/pocsag_app.cpp +++ b/firmware/application/apps/pocsag_app.cpp @@ -56,6 +56,7 @@ POCSAGSettingsView::POCSAGSettingsView( : settings_{settings} { add_children( {&labels, + &opt_baud_rate, &check_log, &check_log_raw, &check_small_font, @@ -65,6 +66,7 @@ POCSAGSettingsView::POCSAGSettingsView( &field_filter_address, &button_save}); + opt_baud_rate.set_by_value(settings_.baud_rate); check_log.set_value(settings_.enable_logging); check_log_raw.set_value(settings_.enable_raw_log); check_small_font.set_value(settings_.enable_small_font); @@ -81,7 +83,7 @@ POCSAGSettingsView::POCSAGSettingsView( settings_.hide_addr_only = check_hide_addr_only.value(); settings_.filter_mode = opt_filter_mode.selected_index_value(); settings_.filter_address = field_filter_address.to_integer(); - + settings_.baud_rate = opt_baud_rate.selected_index_value(); nav.pop(); }; } @@ -142,7 +144,7 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) audio::output::start(); receiver_model.enable(); - baseband::set_pocsag(); + baseband::set_pocsag((int8_t)settings_.baud_rate); } void POCSAGAppView::focus() { @@ -182,6 +184,7 @@ void POCSAGAppView::refresh_ui() { btn_text = "Filter Last"; break; } + baseband::set_pocsag((int8_t)settings_.baud_rate); button_filter_last.set_text(btn_text); } diff --git a/firmware/application/apps/pocsag_app.hpp b/firmware/application/apps/pocsag_app.hpp index 9b5dd4d92..e5527b1f0 100644 --- a/firmware/application/apps/pocsag_app.hpp +++ b/firmware/application/apps/pocsag_app.hpp @@ -126,6 +126,7 @@ struct POCSAGSettings { bool hide_bad_data = false; bool hide_addr_only = false; uint8_t filter_mode = false; + int32_t baud_rate = -1; uint32_t filter_address = 0; }; @@ -139,7 +140,16 @@ class POCSAGSettingsView : public View { private: POCSAGSettings& settings_; + OptionsField opt_baud_rate{ + {8 * 8, 0 * 16}, + 4, + {{"Auto", -1}, + {" 512", 0}, + {"1200", 1}, + {"2400", 2}}}; + Labels labels{ + {{2 * 8, 0 * 16}, "Baud:", Theme::getInstance()->fg_light->foreground}, {{2 * 8, 12 * 16}, "Filter Mode:", Theme::getInstance()->fg_light->foreground}, {{2 * 8, 13 * 16}, "Filter Addr:", Theme::getInstance()->fg_light->foreground}, }; @@ -221,6 +231,7 @@ class POCSAGAppView : public View { {"filter_address"sv, &settings_.filter_address}, {"hide_bad_data"sv, &settings_.hide_bad_data}, {"hide_addr_only"sv, &settings_.hide_addr_only}, + {"baud_rate"sv, &settings_.baud_rate}, }}; void refresh_ui(); diff --git a/firmware/application/baseband_api.cpp b/firmware/application/baseband_api.cpp index 2655f37f9..49c9c35fc 100644 --- a/firmware/application/baseband_api.cpp +++ b/firmware/application/baseband_api.cpp @@ -288,8 +288,8 @@ void set_fsk_data(const uint32_t stream_length, const uint32_t samples_per_bit, send_message(&message); } -void set_pocsag() { - const POCSAGConfigureMessage message{}; +void set_pocsag(int8_t baud_config) { + const POCSAGConfigureMessage message{baud_config}; send_message(&message); } diff --git a/firmware/application/baseband_api.hpp b/firmware/application/baseband_api.hpp index 84d5f292a..3f2e7d972 100644 --- a/firmware/application/baseband_api.hpp +++ b/firmware/application/baseband_api.hpp @@ -91,7 +91,7 @@ void set_nrf(const uint32_t baudrate, const uint32_t word_length, const uint32_t void set_ook_data(const uint32_t stream_length, const uint32_t samples_per_bit, const uint8_t repeat, const uint32_t pause_symbols, const uint8_t de_bruijn_length = 0); void kill_ook(); void set_fsk_data(const uint32_t stream_length, const uint32_t samples_per_bit, const uint32_t shift, const uint32_t progress_notice); -void set_pocsag(); +void set_pocsag(int8_t baud_config = -1); void set_adsb(); void set_jammer(const bool run, const jammer::JammerType type, const uint32_t speed); void set_rds_data(const uint16_t message_length); diff --git a/firmware/application/external/adult_toys_controller/ui_adult_toys_controller.hpp b/firmware/application/external/adult_toys_controller/ui_adult_toys_controller.hpp index 7a8a087b9..fecb737df 100644 --- a/firmware/application/external/adult_toys_controller/ui_adult_toys_controller.hpp +++ b/firmware/application/external/adult_toys_controller/ui_adult_toys_controller.hpp @@ -104,7 +104,7 @@ class AdultToysView : public ui::View { /*short_ui*/ true}; app_settings::SettingsManager settings_{ - "Adult Toys", app_settings::Mode::TX}; + "tx_adult_toys", app_settings::Mode::TX}; OptionsField options_target{ {UI_POS_X(6), UI_POS_Y(1)}, diff --git a/firmware/baseband/proc_pocsag2.cpp b/firmware/baseband/proc_pocsag2.cpp index 65dd7b096..590a5dda7 100644 --- a/firmware/baseband/proc_pocsag2.cpp +++ b/firmware/baseband/proc_pocsag2.cpp @@ -159,13 +159,27 @@ void BitExtractor::configure(uint32_t sample_rate) { // without needing to know exact transition boundaries. for (auto& rate : known_rates_) rate.sample_interval = sample_rate / (2.0 * rate.baud_rate); + + if (baud_config_ >= 0 && baud_config_ < static_cast(known_rates_.size())) { + current_rate_ = &known_rates_[baud_config_]; + } else { + current_rate_ = nullptr; + } } void BitExtractor::reset() { - current_rate_ = nullptr; - for (auto& rate : known_rates_) rate.reset(); + + if (baud_config_ >= 0 && baud_config_ < static_cast(known_rates_.size())) { + current_rate_ = &known_rates_[baud_config_]; + } else { + current_rate_ = nullptr; + } +} + +void BitExtractor::set_baud_config(int8_t baud_config) { + baud_config_ = baud_config; } uint16_t BitExtractor::baud_rate() const { @@ -352,7 +366,7 @@ void POCSAGProcessor::execute(const buffer_c8_t& buffer) { void POCSAGProcessor::on_message(const Message* const message) { switch (message->id) { case Message::ID::POCSAGConfigure: - configure(); + configure(reinterpret_cast(message)->baud_config); break; case Message::ID::NBFMConfigure: { @@ -370,7 +384,7 @@ void POCSAGProcessor::on_message(const Message* const message) { } } -void POCSAGProcessor::configure() { +void POCSAGProcessor::configure(int8_t baud_config) { constexpr size_t decim_0_output_fs = baseband_fs / decim_0.decimation_factor; constexpr size_t decim_1_output_fs = decim_0_output_fs / decim_1.decimation_factor; constexpr size_t channel_filter_output_fs = decim_1_output_fs / 2; @@ -383,7 +397,7 @@ void POCSAGProcessor::configure() { // Don't process the audio stream. audio_output.configure(false); - + bit_extractor.set_baud_config(baud_config); bit_extractor.configure(demod_input_fs); // Set ready to process data. diff --git a/firmware/baseband/proc_pocsag2.hpp b/firmware/baseband/proc_pocsag2.hpp index 9215e7fd3..23fe536a9 100644 --- a/firmware/baseband/proc_pocsag2.hpp +++ b/firmware/baseband/proc_pocsag2.hpp @@ -84,6 +84,7 @@ class BitExtractor { void extract_bits(const buffer_f32_t& audio); void configure(uint32_t sample_rate); void reset(); + void set_baud_config(int8_t baud_config); uint16_t baud_rate() const; private: @@ -117,7 +118,7 @@ class BitExtractor { RateInfo{2400}}; BitQueue& bits_; - + int8_t baud_config_ = -1; uint32_t sample_rate_ = 0; RateInfo* current_rate_ = nullptr; }; @@ -207,7 +208,7 @@ class POCSAGProcessor : public BasebandProcessor { static constexpr uint32_t stat_update_threshold = baseband_fs / stat_update_interval; - void configure(); + void configure(int8_t baud_config = -1); void flush(); void reset(); void send_stats() const; diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index ae6f33bb7..74692613d 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -1187,9 +1187,10 @@ class FSKRxConfigureMessage : public Message { class POCSAGConfigureMessage : public Message { public: - constexpr POCSAGConfigureMessage() - : Message{ID::POCSAGConfigure} { + constexpr POCSAGConfigureMessage(int8_t baud_config = -1) + : Message{ID::POCSAGConfigure}, baud_config(baud_config) { } + int8_t baud_config; //-1 auto, 0=512,1=1200,2=2400 }; class APRSPacketMessage : public Message {