mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-12-02 18:21:48 +00:00
POCSAG TX: Support for numeric only and address only messages
This commit is contained in:
@@ -585,7 +585,7 @@ void ModalMessageView::paint(Painter& painter) {
|
||||
painter.draw_string(
|
||||
{ 1 * 8, (Coord)(120 + (i * 16)) },
|
||||
style(),
|
||||
message_.substr(start, pos)
|
||||
message_.substr(start, pos - start)
|
||||
);
|
||||
i++;
|
||||
start = pos + 1;
|
||||
|
||||
@@ -296,17 +296,17 @@ private:
|
||||
const std::function<void(bool)> on_choice_;
|
||||
|
||||
Button button_ok {
|
||||
{ 10 * 8, 13 * 16, 10 * 8, 24 },
|
||||
{ 10 * 8, 14 * 16, 10 * 8, 48 },
|
||||
"OK",
|
||||
};
|
||||
|
||||
Button button_yes {
|
||||
{ 5 * 8, 13 * 16, 8 * 8, 48 },
|
||||
{ 5 * 8, 14 * 16, 8 * 8, 48 },
|
||||
"YES",
|
||||
};
|
||||
|
||||
Button button_no {
|
||||
{ 17 * 8, 13 * 16, 8 * 8, 48 },
|
||||
{ 17 * 8, 14 * 16, 8 * 8, 48 },
|
||||
"NO",
|
||||
};
|
||||
};
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "ui_pocsag_tx.hpp"
|
||||
|
||||
#include "pocsag.hpp"
|
||||
#include "baseband_api.hpp"
|
||||
#include "string_format.hpp"
|
||||
|
||||
@@ -55,16 +54,34 @@ void POCSAGTXView::on_tx_progress(const int progress, const bool done) {
|
||||
progressbar.set_value(progress);
|
||||
}
|
||||
|
||||
void POCSAGTXView::start_tx() {
|
||||
bool POCSAGTXView::start_tx() {
|
||||
uint32_t total_frames, i, codeword, bi, address;
|
||||
pocsag::BitRate bitrate;
|
||||
std::vector<uint32_t> codewords;
|
||||
MessageType type;
|
||||
|
||||
address = address_field.value_dec_u32();
|
||||
if (address > 0x1FFFFFU)
|
||||
address = 0; // Todo: Error screen
|
||||
type = (MessageType)options_type.selected_index_value();
|
||||
|
||||
pocsag_encode(BCH_code, message, address, codewords);
|
||||
address = field_address.value_dec_u32();
|
||||
if (address > 0x1FFFFFU) {
|
||||
nav_.display_modal("Bad address", "Address must be less\nthan 2097152.", INFO, nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
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.",
|
||||
INFO,
|
||||
nullptr
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
pocsag_encode(type, BCH_code, message, address, codewords);
|
||||
|
||||
total_frames = codewords.size() / 2;
|
||||
|
||||
@@ -88,7 +105,7 @@ void POCSAGTXView::start_tx() {
|
||||
data_ptr[bi++] = codeword & 0xFF;
|
||||
}
|
||||
|
||||
text_debug_a.set("Codewords: " + to_string_dec_uint(codewords.size()));
|
||||
//text_debug_a.set("Codewords: " + to_string_dec_uint(codewords.size()));
|
||||
|
||||
bitrate = pocsag_bitrates[options_bitrate.selected_index()];
|
||||
|
||||
@@ -98,6 +115,8 @@ void POCSAGTXView::start_tx() {
|
||||
4500,
|
||||
64
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void POCSAGTXView::paint(Painter&) {
|
||||
@@ -109,15 +128,20 @@ void POCSAGTXView::on_set_text(NavigationView& nav) {
|
||||
textentry(nav, buffer, 16);
|
||||
}
|
||||
|
||||
POCSAGTXView::POCSAGTXView(NavigationView& nav) {
|
||||
POCSAGTXView::POCSAGTXView(
|
||||
NavigationView& nav
|
||||
) : nav_ (nav)
|
||||
{
|
||||
|
||||
baseband::run_image(portapack::spi_flash::image_tag_fsktx);
|
||||
|
||||
add_children({
|
||||
&text_debug_a,
|
||||
&text_address,
|
||||
&address_field,
|
||||
&text_bitrate,
|
||||
&options_bitrate,
|
||||
&text_address,
|
||||
&field_address,
|
||||
&text_type,
|
||||
&options_type,
|
||||
&text_message,
|
||||
&button_message,
|
||||
&progressbar,
|
||||
@@ -125,6 +149,7 @@ POCSAGTXView::POCSAGTXView(NavigationView& nav) {
|
||||
});
|
||||
|
||||
options_bitrate.set_selected_index(1); // 1200bps
|
||||
options_type.set_selected_index(2); // Alphanumeric
|
||||
|
||||
button_message.on_select = [this, &nav](Button&) {
|
||||
this->on_set_text(nav);
|
||||
@@ -138,12 +163,13 @@ POCSAGTXView::POCSAGTXView(NavigationView& nav) {
|
||||
};
|
||||
|
||||
tx_view.on_start = [this]() {
|
||||
tx_view.set_transmitting(true);
|
||||
start_tx();
|
||||
if (start_tx())
|
||||
tx_view.set_transmitting(true);
|
||||
};
|
||||
|
||||
tx_view.on_stop = [this]() {
|
||||
tx_view.set_transmitting(false);
|
||||
transmitter_model.disable();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
#include "bch_code.hpp"
|
||||
#include "message.hpp"
|
||||
#include "transmitter_model.hpp"
|
||||
#include "pocsag.hpp"
|
||||
|
||||
using namespace pocsag;
|
||||
|
||||
namespace ui {
|
||||
|
||||
@@ -54,6 +57,7 @@ public:
|
||||
private:
|
||||
char buffer[17] = "PORTAPACK";
|
||||
std::string message { };
|
||||
NavigationView& nav_;
|
||||
|
||||
BCHCode BCH_code {
|
||||
{ 1, 0, 1, 0, 0, 1 },
|
||||
@@ -62,25 +66,14 @@ private:
|
||||
|
||||
void on_set_text(NavigationView& nav);
|
||||
void on_tx_progress(const int progress, const bool done);
|
||||
void start_tx();
|
||||
bool start_tx();
|
||||
|
||||
Text text_debug_a {
|
||||
{ 1 * 8, 4 * 8, 20 * 8, 16 },
|
||||
"-"
|
||||
Text text_bitrate {
|
||||
{ 3 * 8, 4 * 8, 8 * 8, 16 },
|
||||
"Bitrate:"
|
||||
};
|
||||
|
||||
Text text_address {
|
||||
{ 3 * 8, 10 * 8, 20 * 8, 16 },
|
||||
"Address:"
|
||||
};
|
||||
SymField address_field {
|
||||
{ 11 * 8, 10 * 8 },
|
||||
7,
|
||||
SymField::SYMFIELD_DEC
|
||||
};
|
||||
|
||||
OptionsField options_bitrate {
|
||||
{ 11 * 8, 12 * 8 },
|
||||
{ 11 * 8, 4 * 8 },
|
||||
8,
|
||||
{
|
||||
{ "512 bps ", 0 },
|
||||
@@ -89,12 +82,36 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
Text text_address {
|
||||
{ 3 * 8, 6 * 8, 8 * 8, 16 },
|
||||
"Address:"
|
||||
};
|
||||
SymField field_address {
|
||||
{ 11 * 8, 6 * 8 },
|
||||
7,
|
||||
SymField::SYMFIELD_DEC
|
||||
};
|
||||
|
||||
Text text_type {
|
||||
{ 6 * 8, 8 * 8, 5 * 8, 16 },
|
||||
"Type:"
|
||||
};
|
||||
OptionsField options_type {
|
||||
{ 11 * 8, 8 * 8 },
|
||||
12,
|
||||
{
|
||||
{ "Address only", MessageType::ADDRESS_ONLY },
|
||||
{ "Numeric only", MessageType::NUMERIC_ONLY },
|
||||
{ "Alphanumeric", MessageType::ALPHANUMERIC }
|
||||
}
|
||||
};
|
||||
|
||||
Text text_message {
|
||||
{ 3 * 8, 14 * 8, 16 * 8, 16 },
|
||||
{ 3 * 8, 12 * 8, 16 * 8, 16 },
|
||||
""
|
||||
};
|
||||
Button button_message {
|
||||
{ 3 * 8, 16 * 8, 8 * 8, 28 },
|
||||
{ 3 * 8, 14 * 8, 8 * 8, 28 },
|
||||
"Set"
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user