Move POCSAG Tx to Ext. (#3033)

* Disable POCSAG TX in menu

Comment out POCSAG TX related code in ui_navigation.cpp

* Comment out ui_pocsag_tx.cpp in CMakeLists

Comment out the ui_pocsag_tx.cpp file in CMakeLists.

* Move POCSAG Tx to Ext.

* Update external.cmake

* Delete firmware/application/apps/ui_pocsag_tx.hpp

* Delete firmware/application/apps/ui_pocsag_tx.cpp

* Update main.cpp

* Update main.cpp

* Update external.ld

* fix namespace

* deleted commented out entry

* delete commented entries

* fix: correct baseband for pocsag tx

* run prepared

---------

Co-authored-by: gullradriel <gullradriel@users.noreply.github.com>
This commit is contained in:
Sandbox
2026-02-24 04:37:03 +08:00
committed by GitHub
parent b197a4b1de
commit 065d01b591
7 changed files with 100 additions and 12 deletions
+5
View File
@@ -308,6 +308,10 @@ set(EXTCPPSRC
external/rtty_tx/main.cpp
external/rtty_tx/ui_rtty_tx.cpp
external/rtty_tx/baudot.cpp
#pocsag_tx
external/pocsag_tx/main.cpp
external/pocsag_tx/ui_pocsag_tx.cpp
)
set(EXTAPPLIST
@@ -385,6 +389,7 @@ set(EXTAPPLIST
keeloqtx
rtty_rx
rtty_tx
pocsag_tx
)
# sdusb has type conflicts with PRALINE (HackRF Pro) - add only for non-PRALINE builds
+7
View File
@@ -98,6 +98,7 @@ MEMORY
ram_external_app_rtty_rx (rwx) : org = 0xADF90000, len = 32k
ram_external_app_rtty_tx (rwx) : org = 0xADFA0000, len = 32k
ram_external_app_tpmstx (rwx) : org = 0xADFB0000, len = 32k
ram_external_app_pocsag_tx (rwx) : org = 0xADFC0000, len = 32k
}
SECTIONS
@@ -552,5 +553,11 @@ SECTIONS
KEEP(*(.external_app.app_rtty_tx.application_information));
*(*ui*external_app*rtty_tx*);
} > ram_external_app_rtty_tx
.external_app_pocsag_tx : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_pocsag_tx.application_information));
*(*ui*external_app*pocsag_tx*);
} > ram_external_app_pocsag_tx
}
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2023 Bernd Herzog
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#include "ui.hpp"
#include "ui_pocsag_tx.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::pocsag_tx {
void initialize_app(ui::NavigationView& nav) {
nav.push<POCSAGTXView>();
}
} // namespace ui::external_app::pocsag_tx
extern "C" {
__attribute__((section(".external_app.app_pocsag_tx.application_information"), used)) application_information_t _application_information_pocsag_tx = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::pocsag_tx::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "POCSG TX",
/*.bitmap_data = */ {
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0xFC,
0x3F,
0xFE,
0x7F,
0x02,
0x40,
0xBA,
0x45,
0x02,
0x40,
0xFE,
0x7F,
0xFE,
0x7F,
0x92,
0x7C,
0x92,
0x7C,
0xFC,
0x3F,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
},
/*.icon_color = */ ui::Color::green().v,
/*.menu_location = */ app_location_t::TX,
/*.desired_menu_position = */ -1,
/*.m4_app_tag = portapack::spi_flash::image_tag_fsktx */ {'P', 'F', 'S', 'K'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
+208
View File
@@ -0,0 +1,208 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#include "ui_pocsag_tx.hpp"
#include "baseband_api.hpp"
#include "string_format.hpp"
#include "ui_textentry.hpp"
#include "portapack_persistent_memory.hpp"
using namespace portapack;
using namespace pocsag;
namespace ui::external_app::pocsag_tx {
#define MAX_POCSAG_LENGTH 80
void POCSAGTXView::focus() {
field_address.focus();
}
POCSAGTXView::~POCSAGTXView() {
transmitter_model.disable();
baseband::shutdown();
}
void POCSAGTXView::on_remote(const PocsagTosendMessage data) {
// check if still sending or not
size_t tmp = 0;
if (data.baud == 1200) tmp = 1;
if (data.baud == 2400) tmp = 2;
options_bitrate.set_selected_index(tmp);
tmp = 0;
options_type.set_selected_index(data.type);
if (data.function == 'B') tmp = 1;
if (data.function == 'C') tmp = 2;
if (data.function == 'D') tmp = 3;
options_function.set_selected_index(tmp);
options_phase.set_selected_index(data.phase == 'P' ? 0 : 1);
field_address.set_value(data.addr);
message = (char*)data.msg;
buffer = message;
text_message.set(message);
options_bitrate.dirty();
options_type.dirty();
options_function.dirty();
options_phase.dirty();
field_address.dirty();
text_message.dirty();
tx_view.focus();
start_tx();
}
void POCSAGTXView::on_tx_progress(const uint32_t progress, const bool done) {
if (done) {
transmitter_model.disable();
progressbar.set_value(0);
tx_view.set_transmitting(false);
} else
progressbar.set_value(progress);
}
bool POCSAGTXView::start_tx() {
uint32_t total_frames, i, codeword, bi, address;
pocsag::BitRate bitrate;
std::vector<uint32_t> codewords;
address = field_address.to_integer();
if (address > 0x1FFFFFU) {
nav_.display_modal("Bad address", "Address must be less\nthan 2097152.");
return false;
}
MessageType type = (MessageType)options_type.selected_index_value();
if (type == MessageType::NUMERIC_ONLY) {
// Check for invalid characters
if (message.find_first_not_of("0123456789SU -][") != std::string::npos) {
nav_.display_modal("Bad message", "A numeric only message must\nonly contain:\n0123456789SU][- or space.");
return false;
}
}
MessageType phase = (MessageType)options_phase.selected_index_value();
pocsag_encode(type, BCH_code, options_function.selected_index_value(), message, address, codewords);
total_frames = codewords.size() / 2;
progressbar.set_max(total_frames);
// transmitter_model.set_rf_amp(true);
// transmitter_model.set_tx_gain(40);
// We left exactly same TX LPF settings as previous fw 1.7.4, TX LPF= 1M75 (min). It is fine even in max FM dev. 150khz and 2400 bauds.
transmitter_model.set_baseband_bandwidth(1'750'000); // Min TX LPF . Pocsag is NBFM , using BW channel 25khz or 12khz
transmitter_model.enable();
uint8_t* data_ptr = shared_memory.bb_data.data;
bi = 0;
for (i = 0; i < codewords.size(); i++) {
if (phase == 0)
codeword = ~(codewords[i]);
else
codeword = codewords[i];
data_ptr[bi++] = (codeword >> 24) & 0xFF;
data_ptr[bi++] = (codeword >> 16) & 0xFF;
data_ptr[bi++] = (codeword >> 8) & 0xFF;
data_ptr[bi++] = codeword & 0xFF;
}
bitrate = pocsag_bitrates[options_bitrate.selected_index()];
baseband::set_fsk_data(
codewords.size() * 32,
2280000 / bitrate,
4500,
64);
return true;
}
void POCSAGTXView::paint(Painter&) {
message = buffer;
text_message.set(message); // the whole message, but it may not fit.
if (message.length() > 30 && message.length() <= 60) {
text_message_l2.set(message.substr(29)); // remaining to 2nd line
} else if (message.length() > 60) {
text_message_l2.set(message.substr(29, 27) + "...");
} else {
text_message_l2.set("");
}
}
void POCSAGTXView::on_set_text(NavigationView& nav) {
text_prompt(nav, buffer, MAX_POCSAG_LENGTH, ENTER_KEYBOARD_MODE_ALPHA);
}
POCSAGTXView::POCSAGTXView(
NavigationView& nav)
: nav_(nav) {
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
add_children({&labels,
&options_bitrate,
&field_address,
&options_type,
&options_function,
&options_phase,
&text_message,
&text_message_l2,
&button_message,
&progressbar,
&tx_view});
options_bitrate.set_selected_index(1); // 1200bps
options_type.set_selected_index(0); // Address only
field_address.set_value(persistent_memory::pocsag_last_address());
options_type.on_change = [this](size_t, int32_t i) {
if (i == 2)
options_function.set_selected_index(3);
};
button_message.on_select = [this, &nav](Button&) {
this->on_set_text(nav);
};
tx_view.on_edit_frequency = [this, &nav]() {
auto new_view = nav.push<FrequencyKeypadView>(transmitter_model.target_frequency());
new_view->on_changed = [this](rf::Frequency f) {
transmitter_model.set_target_frequency(f);
};
};
tx_view.on_start = [this]() {
if (start_tx())
tx_view.set_transmitting(true);
};
tx_view.on_stop = [this]() {
tx_view.set_transmitting(false);
transmitter_model.disable();
};
}
} /* namespace ui::external_app::pocsag_tx */
+160
View File
@@ -0,0 +1,160 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef __POCSAG_TX_H__
#define __POCSAG_TX_H__
#include "ui.hpp"
#include "ui_widget.hpp"
#include "ui_navigation.hpp"
#include "ui_receiver.hpp"
#include "ui_transmitter.hpp"
#include "bch_code.hpp"
#include "message.hpp"
#include "transmitter_model.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
#include "pocsag.hpp"
using namespace pocsag;
namespace ui::external_app::pocsag_tx {
class POCSAGTXView : public View {
public:
POCSAGTXView(NavigationView& nav);
~POCSAGTXView();
POCSAGTXView(const POCSAGTXView&) = delete;
POCSAGTXView(POCSAGTXView&&) = delete;
POCSAGTXView& operator=(const POCSAGTXView&) = delete;
POCSAGTXView& operator=(POCSAGTXView&&) = delete;
void focus() override;
void paint(Painter&) override;
std::string title() const override { return "POCSAG TX"; };
private:
std::string buffer{"PORTAPACK"};
std::string message{};
NavigationView& nav_;
TxRadioState radio_state_{
466175000 /* frequency */,
1750000 /* bandwidth */,
2280000 /* sampling rate */
};
app_settings::SettingsManager settings_{
"tx_pocsag", app_settings::Mode::TX};
BCHCode BCH_code{
{1, 0, 1, 0, 0, 1},
5,
31,
21,
2};
void on_set_text(NavigationView& nav);
void on_tx_progress(const uint32_t progress, const bool done);
void on_remote(const PocsagTosendMessage data);
bool start_tx();
Labels labels{
{{3 * 8, 4 * 8}, "Bitrate:", Theme::getInstance()->fg_light->foreground},
{{3 * 8, 6 * 8}, "Address:", Theme::getInstance()->fg_light->foreground},
{{6 * 8, 8 * 8}, "Type:", Theme::getInstance()->fg_light->foreground},
{{2 * 8, 10 * 8}, "Function:", Theme::getInstance()->fg_light->foreground},
{{5 * 8, 12 * 8}, "Phase:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 14 * 8}, "Message:", Theme::getInstance()->fg_light->foreground}};
OptionsField options_bitrate{
{11 * 8, 4 * 8},
8,
{{"512 bps ", 0},
{"1200 bps", 1},
{"2400 bps", 2}}};
SymField field_address{
{11 * 8, 6 * 8},
7};
OptionsField options_type{
{11 * 8, 8 * 8},
12,
{{"Address only", MessageType::ADDRESS_ONLY},
{"Numeric only", MessageType::NUMERIC_ONLY},
{"Alphanumeric", MessageType::ALPHANUMERIC}}};
OptionsField options_function{
{11 * 8, 10 * 8},
1,
{{"A", 0},
{"B", 1},
{"C", 2},
{"D", 3}}};
OptionsField options_phase{
{11 * 8, 12 * 8},
1,
{
{"P", 0},
{"N", 1},
}};
Text text_message{
{UI_POS_X(0), 16 * 8, screen_width, 16},
""};
Text text_message_l2{
{UI_POS_X(0), 18 * 8, screen_width, 16},
""};
Button button_message{
{UI_POS_X(0), 20 * 8, 14 * 8, 32},
"Set message"};
ProgressBar progressbar{
{16, 210, UI_POS_WIDTH_REMAINING(4), 16}};
TransmitterView tx_view{
(int16_t)UI_POS_Y_BOTTOM(4),
10000,
9};
MessageHandlerRegistration message_handler_tx_progress{
Message::ID::TXProgress,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
this->on_tx_progress(message.progress, message.done);
}};
MessageHandlerRegistration message_handler_tx_remote{
Message::ID::PocsagTosend,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const PocsagTosendMessage*>(p);
this->on_remote(message);
}};
};
} /* namespace ui::external_app::pocsag_tx */
#endif /*__POCSAG_TX_H__*/