mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-18 19:28:02 -04:00
POCSAG TX (with fixed message for testing)
This commit is contained in:
parent
b430b1e427
commit
dc7fcbc6c3
22 changed files with 562 additions and 91 deletions
|
@ -84,6 +84,7 @@ public:
|
|||
ADSBConfigure = 40,
|
||||
JammerConfigure = 41,
|
||||
WidebandSpectrumConfig = 42,
|
||||
FSKConfigure = 43,
|
||||
|
||||
POCSAGPacket = 50,
|
||||
|
||||
|
@ -695,6 +696,27 @@ public:
|
|||
const uint32_t pause_symbols;
|
||||
};
|
||||
|
||||
class FSKConfigureMessage : public Message {
|
||||
public:
|
||||
constexpr FSKConfigureMessage(
|
||||
const uint32_t stream_length,
|
||||
const uint32_t samples_per_bit,
|
||||
const uint32_t shift,
|
||||
const uint32_t progress_notice
|
||||
) : Message { ID::FSKConfigure },
|
||||
stream_length(stream_length),
|
||||
samples_per_bit(samples_per_bit),
|
||||
shift(shift),
|
||||
progress_notice(progress_notice)
|
||||
{
|
||||
}
|
||||
|
||||
const uint32_t stream_length;
|
||||
const uint32_t samples_per_bit;
|
||||
const uint32_t shift;
|
||||
const uint32_t progress_notice;
|
||||
};
|
||||
|
||||
class POCSAGConfigureMessage : public Message {
|
||||
public:
|
||||
constexpr POCSAGConfigureMessage(
|
||||
|
|
|
@ -94,19 +94,20 @@ void pocsag_encode(
|
|||
}
|
||||
|
||||
// Address
|
||||
codeword = (address & 0x1FFFF8U) << 13;
|
||||
codeword = (address & 0x1FFFF8U) << 10;
|
||||
address_slot = (address & 7) * 2;
|
||||
// Function
|
||||
codeword = 3 << 11;
|
||||
codeword |= (3 << 11);
|
||||
|
||||
insert_BCH(BCH_code, &codeword);
|
||||
|
||||
// Address batch
|
||||
codewords.push_back(POCSAG_SYNCWORD);
|
||||
for (c = 0; c < 16; c++) {
|
||||
if (c == address_slot)
|
||||
if (c == address_slot) {
|
||||
codewords.push_back(codeword);
|
||||
else
|
||||
break;
|
||||
} else
|
||||
codewords.push_back(POCSAG_IDLEWORD);
|
||||
}
|
||||
|
||||
|
@ -115,44 +116,52 @@ void pocsag_encode(
|
|||
|
||||
// Messages batch(es)
|
||||
do {
|
||||
codewords.push_back(POCSAG_SYNCWORD);
|
||||
if (c == 0) codewords.push_back(POCSAG_SYNCWORD);
|
||||
|
||||
for (c = 0; c < 16; c++) {
|
||||
// Fill up 20 bits
|
||||
do {
|
||||
bit_idx -= 7;
|
||||
|
||||
if (char_idx < text_size)
|
||||
ascii_char = text[char_idx] & 0x7F;
|
||||
else
|
||||
ascii_char = 0; // Padding
|
||||
|
||||
// Bottom's up
|
||||
ascii_char = (ascii_char & 0xF0) >> 4 | (ascii_char & 0x0F) << 4; // *6543210 -> 3210*654
|
||||
ascii_char = (ascii_char & 0xCC) >> 2 | (ascii_char & 0x33) << 2; // 3210*654 -> 103254*6
|
||||
ascii_char = (ascii_char & 0xAA) >> 2 | (ascii_char & 0x55); // 103254*6 -> *0123456
|
||||
|
||||
codeword |= (ascii_char << bit_idx);
|
||||
|
||||
char_idx++;
|
||||
|
||||
} while (bit_idx > 11);
|
||||
for ( ; c < 16; c++) {
|
||||
|
||||
codeword &= 0x7FFFF800; // Trim data
|
||||
codeword |= 0x80000000; // Message type
|
||||
insert_BCH(BCH_code, &codeword);
|
||||
|
||||
codewords.push_back(codeword);
|
||||
|
||||
if (bit_idx != 11) {
|
||||
bit_idx = 20 + bit_idx;
|
||||
codeword = ascii_char << bit_idx;
|
||||
if (char_idx < text_size) {
|
||||
|
||||
// Fill up 20 bits
|
||||
do {
|
||||
bit_idx -= 7;
|
||||
|
||||
if (char_idx < text_size)
|
||||
ascii_char = text[char_idx] & 0x7F;
|
||||
else
|
||||
ascii_char = 0; // Codeword padding
|
||||
|
||||
// Bottom's up
|
||||
ascii_char = (ascii_char & 0xF0) >> 4 | (ascii_char & 0x0F) << 4; // *6543210 -> 3210*654
|
||||
ascii_char = (ascii_char & 0xCC) >> 2 | (ascii_char & 0x33) << 2; // 3210*654 -> 103254*6
|
||||
ascii_char = (ascii_char & 0xAA) >> 2 | (ascii_char & 0x55); // 103254*6 -> *0123456
|
||||
|
||||
codeword |= (ascii_char << bit_idx);
|
||||
|
||||
char_idx++;
|
||||
|
||||
} while (bit_idx > 11);
|
||||
|
||||
codeword &= 0x7FFFF800; // Trim data
|
||||
codeword |= 0x80000000; // Message type
|
||||
insert_BCH(BCH_code, &codeword);
|
||||
|
||||
codewords.push_back(codeword);
|
||||
|
||||
if (bit_idx != 11) {
|
||||
bit_idx = 20 + bit_idx;
|
||||
codeword = ascii_char << bit_idx;
|
||||
} else {
|
||||
bit_idx = 20 + 11;
|
||||
codeword = 0;
|
||||
}
|
||||
} else {
|
||||
bit_idx = 20 + 11;
|
||||
codeword = 0;
|
||||
codewords.push_back(POCSAG_IDLEWORD); // Batch padding
|
||||
}
|
||||
}
|
||||
|
||||
c = 0;
|
||||
|
||||
} while (char_idx < text_size);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ constexpr image_tag_t image_tag_rds { 'P', 'R', 'D', 'S' };
|
|||
constexpr image_tag_t image_tag_ook { 'P', 'O', 'O', 'K' };
|
||||
constexpr image_tag_t image_tag_adsb_tx { 'P', 'A', 'D', 'S' };
|
||||
constexpr image_tag_t image_tag_replay { 'P', 'R', 'E', 'P' };
|
||||
constexpr image_tag_t image_tag_fsktx { 'P', 'F', 'S', 'K' };
|
||||
|
||||
constexpr image_tag_t image_tag_hackrf { 'H', 'R', 'F', '1' };
|
||||
|
||||
|
|
|
@ -1185,6 +1185,20 @@ SymField::SymField(
|
|||
set_focusable(true);
|
||||
}
|
||||
|
||||
uint32_t SymField::value_dec_u32() {
|
||||
uint32_t c, mul = 1;
|
||||
uint32_t v = 0;
|
||||
|
||||
if (type_ == SYMFIELD_DEC) {
|
||||
for (c = 0; c < length_; c++) {
|
||||
v += values_[(length_ - 1 - c)] * mul;
|
||||
mul *= 10;
|
||||
}
|
||||
return v;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t SymField::value_hex_u64() {
|
||||
uint32_t c;
|
||||
uint64_t v = 0;
|
||||
|
|
|
@ -491,6 +491,7 @@ public:
|
|||
void set_value(const uint32_t index, const uint32_t new_value);
|
||||
void set_length(const uint32_t new_length);
|
||||
void set_symbol_list(const uint32_t index, const std::string symbol_list);
|
||||
uint32_t value_dec_u32();
|
||||
uint64_t value_hex_u64();
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue