Added function setting in POCSAG TX

POCSAG TX: Max message length is now 30 (was 16 for no reason)
This commit is contained in:
furrtek 2017-09-23 04:53:42 +01:00
parent a6d2b766f4
commit 9acfdcbd41
7 changed files with 37 additions and 35 deletions

View File

@ -25,12 +25,12 @@
#include "baseband_api.hpp"
#include "portapack_persistent_memory.hpp"
#include "pocsag.hpp"
using namespace portapack;
using namespace pocsag;
#include "pocsag.hpp"
#include "string_format.hpp"
#include "utility.hpp"
void POCSAGLogger::log_raw_data(const pocsag::POCSAGPacket& packet, const uint32_t frequency) {

View File

@ -28,17 +28,13 @@
#include "portapack_persistent_memory.hpp"
#include <cstring>
#include <stdio.h>
#include <math.h>
using namespace portapack;
using namespace pocsag;
namespace ui {
void POCSAGTXView::focus() {
tx_view.focus();
field_address.focus();
}
POCSAGTXView::~POCSAGTXView() {
@ -59,30 +55,24 @@ bool POCSAGTXView::start_tx() {
uint32_t total_frames, i, codeword, bi, address;
pocsag::BitRate bitrate;
std::vector<uint32_t> codewords;
MessageType type;
type = (MessageType)options_type.selected_index_value();
address = field_address.value_dec_u32();
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;
}
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.",
INFO,
nullptr
);
nav_.display_modal("Bad message", "A numeric only message must\nonly contain:\n0123456789SU][- or space.");
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;
@ -124,16 +114,13 @@ void POCSAGTXView::paint(Painter&) {
}
void POCSAGTXView::on_set_text(NavigationView& nav) {
text_prompt(nav, &buffer, 16);
text_prompt(nav, &buffer, 30);
}
POCSAGTXView::POCSAGTXView(
NavigationView& nav
) : nav_ (nav)
{
uint32_t reload_address;
uint32_t c;
baseband::run_image(portapack::spi_flash::image_tag_fsktx);
add_children({
@ -141,6 +128,7 @@ POCSAGTXView::POCSAGTXView(
&options_bitrate,
&field_address,
&options_type,
&options_function,
&text_message,
&button_message,
&progressbar,
@ -151,12 +139,17 @@ POCSAGTXView::POCSAGTXView(
options_type.set_selected_index(0); // Address only
// TODO: set_value for whole symfield
reload_address = persistent_memory::pocsag_last_address();
for (c = 0; c < 7; c++) {
uint32_t reload_address = persistent_memory::pocsag_last_address();
for (uint32_t c = 0; c < 7; c++) {
field_address.set_sym(6 - c, 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&) {
this->on_set_text(nav);
};

View File

@ -70,7 +70,8 @@ private:
{ { 3 * 8, 4 * 8 }, "Bitrate:", Color::light_grey() },
{ { 3 * 8, 6 * 8 }, "Address:", 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 {
@ -99,13 +100,24 @@ private:
}
};
OptionsField options_function {
{ 11 * 8, 10 * 8 },
1,
{
{ "A", 0 },
{ "B", 1 },
{ "C", 2 },
{ "D", 3 }
}
};
Text text_message {
{ 11 * 8, 12 * 8, 16 * 8, 16 },
{ 0 * 8, 16 * 8, 16 * 8, 16 },
""
};
Button button_message {
{ 3 * 8, 14 * 8, 12 * 8, 28 },
{ 0 * 8, 18 * 8, 14 * 8, 32 },
"Set message"
};

View File

@ -102,8 +102,7 @@ uint32_t get_digit_code(char code) {
return code;
}
void pocsag_encode(
const MessageType type, BCHCode& BCH_code, const std::string message, const uint32_t address,
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) {
size_t b, c, address_slot;
@ -122,8 +121,7 @@ void pocsag_encode(
codeword = (address & 0x1FFFF8U) << 10;
address_slot = (address & 7) * 2;
// Function
if (type == MessageType::ALPHANUMERIC)
codeword |= (3 << 11);
codeword |= (function << 11);
insert_BCH(BCH_code, &codeword);

View File

@ -76,7 +76,7 @@ std::string flag_str(PacketFlag packetflag);
void insert_BCH(BCHCode& BCH_code, uint32_t * codeword);
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);
void pocsag_decode_batch(const POCSAGPacket& batch, POCSAGState * const state);

View File

@ -79,8 +79,7 @@ public:
}
void clear() {
for (uint32_t c = 0; c < 16; c++)
codewords[c] = 0;
codewords.fill(0);
bitrate_ = UNKNOWN;
flag_ = NORMAL;
}
@ -88,7 +87,7 @@ public:
private:
BitRate bitrate_ { UNKNOWN };
PacketFlag flag_ { NORMAL };
uint32_t codewords[16];
std::array <uint32_t, 16> codewords;
Timestamp timestamp_ { };
};

Binary file not shown.