mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-10 07:30:08 -04:00
Added function setting in POCSAG TX
POCSAG TX: Max message length is now 30 (was 16 for no reason)
This commit is contained in:
parent
a6d2b766f4
commit
9acfdcbd41
7 changed files with 37 additions and 35 deletions
|
@ -25,12 +25,12 @@
|
||||||
#include "baseband_api.hpp"
|
#include "baseband_api.hpp"
|
||||||
#include "portapack_persistent_memory.hpp"
|
#include "portapack_persistent_memory.hpp"
|
||||||
|
|
||||||
|
#include "pocsag.hpp"
|
||||||
|
|
||||||
using namespace portapack;
|
using namespace portapack;
|
||||||
using namespace pocsag;
|
using namespace pocsag;
|
||||||
|
|
||||||
#include "pocsag.hpp"
|
|
||||||
#include "string_format.hpp"
|
#include "string_format.hpp"
|
||||||
|
|
||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
|
|
||||||
void POCSAGLogger::log_raw_data(const pocsag::POCSAGPacket& packet, const uint32_t frequency) {
|
void POCSAGLogger::log_raw_data(const pocsag::POCSAGPacket& packet, const uint32_t frequency) {
|
||||||
|
|
|
@ -28,17 +28,13 @@
|
||||||
|
|
||||||
#include "portapack_persistent_memory.hpp"
|
#include "portapack_persistent_memory.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
using namespace portapack;
|
using namespace portapack;
|
||||||
using namespace pocsag;
|
using namespace pocsag;
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
void POCSAGTXView::focus() {
|
void POCSAGTXView::focus() {
|
||||||
tx_view.focus();
|
field_address.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
POCSAGTXView::~POCSAGTXView() {
|
POCSAGTXView::~POCSAGTXView() {
|
||||||
|
@ -59,30 +55,24 @@ bool POCSAGTXView::start_tx() {
|
||||||
uint32_t total_frames, i, codeword, bi, address;
|
uint32_t total_frames, i, codeword, bi, address;
|
||||||
pocsag::BitRate bitrate;
|
pocsag::BitRate bitrate;
|
||||||
std::vector<uint32_t> codewords;
|
std::vector<uint32_t> codewords;
|
||||||
MessageType type;
|
|
||||||
|
|
||||||
type = (MessageType)options_type.selected_index_value();
|
|
||||||
|
|
||||||
address = field_address.value_dec_u32();
|
address = field_address.value_dec_u32();
|
||||||
if (address > 0x1FFFFFU) {
|
if (address > 0x1FFFFFU) {
|
||||||
nav_.display_modal("Bad address", "Address must be less\nthan 2097152.", INFO, nullptr);
|
nav_.display_modal("Bad address", "Address must be less\nthan 2097152.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageType type = (MessageType)options_type.selected_index_value();
|
||||||
|
|
||||||
if (type == MessageType::NUMERIC_ONLY) {
|
if (type == MessageType::NUMERIC_ONLY) {
|
||||||
// Check for invalid characters
|
// Check for invalid characters
|
||||||
if (message.find_first_not_of("0123456789SU -][") != std::string::npos) {
|
if (message.find_first_not_of("0123456789SU -][") != std::string::npos) {
|
||||||
nav_.display_modal(
|
nav_.display_modal("Bad message", "A numeric only message must\nonly contain:\n0123456789SU][- or space.");
|
||||||
"Bad message",
|
|
||||||
"A numeric only message must\nonly contain:\n0123456789SU][- or space.",
|
|
||||||
INFO,
|
|
||||||
nullptr
|
|
||||||
);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pocsag_encode(type, BCH_code, message, address, codewords);
|
pocsag_encode(type, BCH_code, options_function.selected_index_value(), message, address, codewords);
|
||||||
|
|
||||||
total_frames = codewords.size() / 2;
|
total_frames = codewords.size() / 2;
|
||||||
|
|
||||||
|
@ -124,16 +114,13 @@ void POCSAGTXView::paint(Painter&) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void POCSAGTXView::on_set_text(NavigationView& nav) {
|
void POCSAGTXView::on_set_text(NavigationView& nav) {
|
||||||
text_prompt(nav, &buffer, 16);
|
text_prompt(nav, &buffer, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
POCSAGTXView::POCSAGTXView(
|
POCSAGTXView::POCSAGTXView(
|
||||||
NavigationView& nav
|
NavigationView& nav
|
||||||
) : nav_ (nav)
|
) : nav_ (nav)
|
||||||
{
|
{
|
||||||
uint32_t reload_address;
|
|
||||||
uint32_t c;
|
|
||||||
|
|
||||||
baseband::run_image(portapack::spi_flash::image_tag_fsktx);
|
baseband::run_image(portapack::spi_flash::image_tag_fsktx);
|
||||||
|
|
||||||
add_children({
|
add_children({
|
||||||
|
@ -141,6 +128,7 @@ POCSAGTXView::POCSAGTXView(
|
||||||
&options_bitrate,
|
&options_bitrate,
|
||||||
&field_address,
|
&field_address,
|
||||||
&options_type,
|
&options_type,
|
||||||
|
&options_function,
|
||||||
&text_message,
|
&text_message,
|
||||||
&button_message,
|
&button_message,
|
||||||
&progressbar,
|
&progressbar,
|
||||||
|
@ -151,12 +139,17 @@ POCSAGTXView::POCSAGTXView(
|
||||||
options_type.set_selected_index(0); // Address only
|
options_type.set_selected_index(0); // Address only
|
||||||
|
|
||||||
// TODO: set_value for whole symfield
|
// TODO: set_value for whole symfield
|
||||||
reload_address = persistent_memory::pocsag_last_address();
|
uint32_t reload_address = persistent_memory::pocsag_last_address();
|
||||||
for (c = 0; c < 7; c++) {
|
for (uint32_t c = 0; c < 7; c++) {
|
||||||
field_address.set_sym(6 - c, reload_address % 10);
|
field_address.set_sym(6 - c, reload_address % 10);
|
||||||
reload_address /= 10;
|
reload_address /= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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&) {
|
button_message.on_select = [this, &nav](Button&) {
|
||||||
this->on_set_text(nav);
|
this->on_set_text(nav);
|
||||||
};
|
};
|
||||||
|
|
|
@ -70,7 +70,8 @@ private:
|
||||||
{ { 3 * 8, 4 * 8 }, "Bitrate:", Color::light_grey() },
|
{ { 3 * 8, 4 * 8 }, "Bitrate:", Color::light_grey() },
|
||||||
{ { 3 * 8, 6 * 8 }, "Address:", Color::light_grey() },
|
{ { 3 * 8, 6 * 8 }, "Address:", Color::light_grey() },
|
||||||
{ { 6 * 8, 8 * 8 }, "Type:", Color::light_grey() },
|
{ { 6 * 8, 8 * 8 }, "Type:", Color::light_grey() },
|
||||||
{ { 3 * 8, 12 * 8 }, "Message:", Color::light_grey() }
|
{ { 2 * 8, 10 * 8 }, "Function:", Color::light_grey() },
|
||||||
|
{ { 0 * 8, 14 * 8 }, "Message:", Color::light_grey() }
|
||||||
};
|
};
|
||||||
|
|
||||||
OptionsField options_bitrate {
|
OptionsField options_bitrate {
|
||||||
|
@ -99,13 +100,24 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
OptionsField options_function {
|
||||||
|
{ 11 * 8, 10 * 8 },
|
||||||
|
1,
|
||||||
|
{
|
||||||
|
{ "A", 0 },
|
||||||
|
{ "B", 1 },
|
||||||
|
{ "C", 2 },
|
||||||
|
{ "D", 3 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Text text_message {
|
Text text_message {
|
||||||
{ 11 * 8, 12 * 8, 16 * 8, 16 },
|
{ 0 * 8, 16 * 8, 16 * 8, 16 },
|
||||||
""
|
""
|
||||||
};
|
};
|
||||||
|
|
||||||
Button button_message {
|
Button button_message {
|
||||||
{ 3 * 8, 14 * 8, 12 * 8, 28 },
|
{ 0 * 8, 18 * 8, 14 * 8, 32 },
|
||||||
"Set message"
|
"Set message"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -102,8 +102,7 @@ uint32_t get_digit_code(char code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pocsag_encode(
|
void pocsag_encode(const MessageType type, BCHCode& BCH_code, const uint32_t function, const std::string message, const uint32_t address,
|
||||||
const MessageType type, BCHCode& BCH_code, const std::string message, const uint32_t address,
|
|
||||||
std::vector<uint32_t>& codewords) {
|
std::vector<uint32_t>& codewords) {
|
||||||
|
|
||||||
size_t b, c, address_slot;
|
size_t b, c, address_slot;
|
||||||
|
@ -122,8 +121,7 @@ void pocsag_encode(
|
||||||
codeword = (address & 0x1FFFF8U) << 10;
|
codeword = (address & 0x1FFFF8U) << 10;
|
||||||
address_slot = (address & 7) * 2;
|
address_slot = (address & 7) * 2;
|
||||||
// Function
|
// Function
|
||||||
if (type == MessageType::ALPHANUMERIC)
|
codeword |= (function << 11);
|
||||||
codeword |= (3 << 11);
|
|
||||||
|
|
||||||
insert_BCH(BCH_code, &codeword);
|
insert_BCH(BCH_code, &codeword);
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ std::string flag_str(PacketFlag packetflag);
|
||||||
|
|
||||||
void insert_BCH(BCHCode& BCH_code, uint32_t * codeword);
|
void insert_BCH(BCHCode& BCH_code, uint32_t * codeword);
|
||||||
uint32_t get_digit_code(char code);
|
uint32_t get_digit_code(char code);
|
||||||
void pocsag_encode(const MessageType type, BCHCode& BCH_code, const std::string message,
|
void pocsag_encode(const MessageType type, BCHCode& BCH_code, const uint32_t function, const std::string message,
|
||||||
const uint32_t address, std::vector<uint32_t>& codewords);
|
const uint32_t address, std::vector<uint32_t>& codewords);
|
||||||
void pocsag_decode_batch(const POCSAGPacket& batch, POCSAGState * const state);
|
void pocsag_decode_batch(const POCSAGPacket& batch, POCSAGState * const state);
|
||||||
|
|
||||||
|
|
|
@ -79,8 +79,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
for (uint32_t c = 0; c < 16; c++)
|
codewords.fill(0);
|
||||||
codewords[c] = 0;
|
|
||||||
bitrate_ = UNKNOWN;
|
bitrate_ = UNKNOWN;
|
||||||
flag_ = NORMAL;
|
flag_ = NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +87,7 @@ public:
|
||||||
private:
|
private:
|
||||||
BitRate bitrate_ { UNKNOWN };
|
BitRate bitrate_ { UNKNOWN };
|
||||||
PacketFlag flag_ { NORMAL };
|
PacketFlag flag_ { NORMAL };
|
||||||
uint32_t codewords[16];
|
std::array <uint32_t, 16> codewords;
|
||||||
Timestamp timestamp_ { };
|
Timestamp timestamp_ { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue