parent
d23626aae5
commit
e093b74696
|
|
@ -6,34 +6,25 @@ templates:
|
|||
imports: from gnuradio import m17
|
||||
make: m17.codec2_decoder()
|
||||
|
||||
# Make one 'inputs' list entry per input and one 'outputs' list entry per output.
|
||||
# Keys include:
|
||||
# * label (an identifier for the GUI)
|
||||
# * domain (optional - stream or message. Default is stream)
|
||||
# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...)
|
||||
# * vlen (optional - data stream vector length. Default is 1)
|
||||
# * optional (optional - set to 1 for optional inputs. Default is 0)
|
||||
inputs:
|
||||
- label: in
|
||||
domain: stream
|
||||
dtype: byte
|
||||
vlen: 1
|
||||
optional: 0
|
||||
optional: False
|
||||
- label: state_reset
|
||||
domain: message
|
||||
optional: 1
|
||||
optional: True
|
||||
|
||||
outputs:
|
||||
- label: out
|
||||
domain: stream
|
||||
dtype: short
|
||||
vlen: 1
|
||||
optional: 0
|
||||
optional: False
|
||||
|
||||
documentation: |-
|
||||
The decoder block reads encoded audio (as bytes, 8 per frame) at 3200 bps and outputs an audio stream (as shorts, in packs of 160).
|
||||
|
||||
# 'file_format' specifies the version of the GRC yml format used in the file
|
||||
# and should usually not be changed.
|
||||
file_format: 1
|
||||
|
||||
|
|
|
|||
|
|
@ -6,34 +6,25 @@ templates:
|
|||
imports: from gnuradio import m17
|
||||
make: m17.codec2_encoder()
|
||||
|
||||
# Make one 'inputs' list entry per input and one 'outputs' list entry per output.
|
||||
# Keys include:
|
||||
# * label (an identifier for the GUI)
|
||||
# * domain (optional - stream or message. Default is stream)
|
||||
# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...)
|
||||
# * vlen (optional - data stream vector length. Default is 1)
|
||||
# * optional (optional - set to 1 for optional inputs. Default is 0)
|
||||
inputs:
|
||||
- label: in
|
||||
domain: stream
|
||||
dtype: short
|
||||
vlen: 1
|
||||
optional: 0
|
||||
optional: False
|
||||
- label: state_reset
|
||||
domain: message
|
||||
optional: 1
|
||||
optional: True
|
||||
|
||||
outputs:
|
||||
- label: out
|
||||
domain: stream
|
||||
dtype: byte
|
||||
vlen: 1
|
||||
optional: 0
|
||||
optional: False
|
||||
|
||||
documentation: |-
|
||||
The encoder block reads an audio stream (as shorts, in packs of 160) and outputs encoded audio (as bytes, 8 per frame) at 3200 bps.
|
||||
|
||||
# 'file_format' specifies the version of the GRC yml format used in the file
|
||||
# and should usually not be changed.
|
||||
file_format: 1
|
||||
|
||||
|
|
|
|||
|
|
@ -204,19 +204,12 @@ templates:
|
|||
- set_seed(bytes.fromhex(${seed} if ${encr_type} == 1 else '').decode('latin-1'))
|
||||
- set_eot_cnt(${eot_cnt})
|
||||
|
||||
# Make one 'inputs' list entry per input and one 'outputs' list entry per output.
|
||||
# Keys include:
|
||||
# * label (an identifier for the GUI)
|
||||
# * domain (optional - stream or message. Default is stream)
|
||||
# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...)
|
||||
# * vlen (optional - data stream vector length. Default is 1)
|
||||
# * optional (optional - set to 1 for optional inputs. Default is 0)
|
||||
inputs:
|
||||
- label: in
|
||||
domain: stream
|
||||
dtype: byte
|
||||
vlen: 1
|
||||
optional: 0
|
||||
optional: False
|
||||
- label: transmission_control
|
||||
domain: message
|
||||
optional: ${ continuous }
|
||||
|
|
@ -226,11 +219,12 @@ outputs:
|
|||
domain: stream
|
||||
dtype: float
|
||||
vlen: 1
|
||||
optional: 0
|
||||
optional: False
|
||||
|
||||
documentation: |-
|
||||
The encoder block reads a datastream (as 16-byte vectors) clocked at 3200 bits/s and outputs a stream of symbols (as floats) at 4800 Hz. The source and destination fields are 9-character callsign strings, the TYPE field is generated based on drop-down menu entries and the META field is a string or a byte array that can be updated at runtime.
|
||||
The encoder reads payload bytes (16 per frame, e.g. two 8-byte Codec2 3200 frames for voice) and outputs a stream of symbols (as floats) at 4800 Hz.
|
||||
Transmission control: in Messages mode, SOT and EOT messages on the transmission_control port start and end a stream, and SMS messages send a text message (up to 821 bytes) as a packet transmission; in Continuous mode, the stream starts with the flowgraph and ends when the input ends.
|
||||
Source and destination are callsigns of up to 9 characters. META (Meta tab) carries text, a GNSS position, extended callsign data or raw bytes; with AES it carries the nonce, generated for every transmission.
|
||||
Keys and seeds are entered as hex: AES key 32/48/64 digits, scrambler seed 2/4/6 digits (8/16/24-bit LFSR), ECDSA private key 64 digits.
|
||||
|
||||
# 'file_format' specifies the version of the GRC yml format used in the file
|
||||
# and should usually not be changed.
|
||||
file_format: 1
|
||||
|
|
@ -80,29 +80,22 @@ templates:
|
|||
- set_vt_threshold(${vt_threshold})
|
||||
- set_undecodable_out(${undecodable_out})
|
||||
|
||||
# Make one 'inputs' list entry per input and one 'outputs' list entry per output.
|
||||
# Keys include:
|
||||
# * label (an identifier for the GUI)
|
||||
# * domain (optional - stream or message. Default is stream)
|
||||
# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...)
|
||||
# * vlen (optional - data stream vector length. Default is 1)
|
||||
# * optional (optional - set to 1 for optional inputs. Default is 0)
|
||||
inputs:
|
||||
- label: in
|
||||
domain: stream
|
||||
dtype: float
|
||||
vlen: 1
|
||||
optional: 0
|
||||
optional: False
|
||||
|
||||
outputs:
|
||||
- label: out
|
||||
domain: stream
|
||||
dtype: byte
|
||||
vlen: 1
|
||||
optional: 0
|
||||
optional: False
|
||||
- id: fields
|
||||
domain: message
|
||||
optional: true
|
||||
optional: True
|
||||
|
||||
documentation: |-
|
||||
The decoder reads a stream of symbols (as floats) at 4800 Hz and outputs the decoded payload (as bytes). Decoded LSF fields are published on the 'fields' message port when a transmission starts and whenever the LSF changes.
|
||||
|
|
@ -112,6 +105,4 @@ documentation: |-
|
|||
Encryption: whether a stream is encrypted, and how (scrambler size, AES key length), is read from its LSF. Enter the AES key (32/48/64 hex digits) and/or the scrambler seed (2/4/6 hex digits) needed to decrypt the streams you expect; the decoder warns when a received stream needs a key that is missing or has the wrong length.
|
||||
Public key: 64-byte secp256r1 public key used to verify signed streams. Whether a stream is signed is read from its LSF.
|
||||
|
||||
# 'file_format' specifies the version of the GRC yml format used in the file
|
||||
# and should usually not be changed.
|
||||
file_format: 1
|
||||
|
|
|
|||
|
|
@ -80,81 +80,12 @@ namespace gr
|
|||
set_debug(debug);
|
||||
set_output_multiple(SYM_PER_FRA);
|
||||
|
||||
|
||||
/*
|
||||
uint16_t ccrc = LSF_CRC (&_lsf);
|
||||
_lsf.crc[0] = ccrc >> 8;
|
||||
_lsf.crc[1] = ccrc & 0xFF;
|
||||
*/
|
||||
init_state();
|
||||
message_port_register_in(pmt::mp("transmission_control"));
|
||||
set_msg_handler(
|
||||
pmt::mp("transmission_control"),
|
||||
boost::bind(&m17_coder_impl::switch_state, this,
|
||||
boost::placeholders::_1));
|
||||
|
||||
if (_debug == true && _got_lsf != 0)
|
||||
{
|
||||
// destination set to "@ALL"
|
||||
encode_callsign_bytes(_lsf.dst, "@ALL");
|
||||
|
||||
// source set to "N0CALL"
|
||||
encode_callsign_bytes(_lsf.src, "N0CALL");
|
||||
|
||||
// no enc or subtype field, normal 3200 voice
|
||||
_type = M17_TYPE_STREAM | M17_TYPE_VOICE | M17_TYPE_CAN(0);
|
||||
|
||||
if (_encr_type == ENCR_AES) // AES ENC, 3200 voice
|
||||
{
|
||||
_type |= M17_TYPE_ENCR_AES;
|
||||
if (_aes_subtype == 0)
|
||||
_type |= M17_TYPE_ENCR_AES128;
|
||||
else if (_aes_subtype == 1)
|
||||
_type |= M17_TYPE_ENCR_AES192;
|
||||
else if (_aes_subtype == 2)
|
||||
_type |= M17_TYPE_ENCR_AES256;
|
||||
}
|
||||
else
|
||||
|
||||
if (_encr_type == ENCR_SCRAM) // Scrambler ENC, 3200 Voice
|
||||
{
|
||||
_type |= M17_TYPE_ENCR_SCRAM;
|
||||
if (_scrambler_subtype == 0)
|
||||
_type |= M17_TYPE_ENCR_SCRAM_8;
|
||||
else if (_scrambler_subtype == 1)
|
||||
_type |= M17_TYPE_ENCR_SCRAM_16;
|
||||
else if (_scrambler_subtype == 2)
|
||||
_type |= M17_TYPE_ENCR_SCRAM_24;
|
||||
}
|
||||
|
||||
// a signature key is loaded, OR this bit
|
||||
if (_priv_key_loaded)
|
||||
{
|
||||
_signed_str = 1;
|
||||
_type |= M17_TYPE_SIGNED;
|
||||
}
|
||||
|
||||
_lsf.type[0] = (uint16_t)_type >> 8;
|
||||
_lsf.type[1] = (uint16_t)_type & 0xFF;
|
||||
|
||||
// calculate LSF CRC (unclear whether or not this is only
|
||||
// needed here for debug, or if this is missing on every initial LSF)
|
||||
update_LSF_CRC(&_lsf);
|
||||
}
|
||||
|
||||
if (_encr_type == ENCR_AES)
|
||||
{
|
||||
memcpy(&(_lsf.meta), _iv, 14);
|
||||
_iv[14] = (_fn >> 8) & 0x7F;
|
||||
_iv[15] = (_fn >> 0) & 0xFF;
|
||||
|
||||
// re-calculate LSF CRC with IV insertion
|
||||
update_LSF_CRC(&_lsf);
|
||||
}
|
||||
|
||||
// srand(time(NULL)); //random number generator (for IV rand() seed value)
|
||||
// memset(_key, 0, 32 * sizeof(uint8_t));
|
||||
// memset(_iv, 0, 16 * sizeof(uint8_t));
|
||||
}
|
||||
|
||||
void m17_coder_impl::switch_state(const pmt::pmt_t &msg)
|
||||
|
|
@ -542,18 +473,7 @@ namespace gr
|
|||
if (encr_type == ENCR_NONE)
|
||||
return;
|
||||
|
||||
_aes_subtype = aes_subtype;
|
||||
|
||||
if (encr_type == ENCR_AES) // AES ENC, 3200 voice
|
||||
{
|
||||
_type |= M17_TYPE_ENCR_AES;
|
||||
if (_aes_subtype == 0)
|
||||
_type |= M17_TYPE_ENCR_AES128;
|
||||
else if (_aes_subtype == 1)
|
||||
_type |= M17_TYPE_ENCR_AES192;
|
||||
else if (_aes_subtype == 2)
|
||||
_type |= M17_TYPE_ENCR_AES256;
|
||||
}
|
||||
_aes_subtype = aes_subtype; // the key size reaches TYPE through the encryption subtype (see set_type())
|
||||
}
|
||||
|
||||
void m17_coder_impl::set_can(int can)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ namespace gr
|
|||
|
||||
char _src_id[10], _dst_id[10]; // 9 character callsign
|
||||
int _mode, _data;
|
||||
uint16_t _type;
|
||||
uint16_t _send_preamble;
|
||||
int _encr_subtype;
|
||||
|
||||
|
|
|
|||
|
|
@ -368,7 +368,6 @@ namespace gr
|
|||
_scrambler_seed &= 0xFFFFFF;
|
||||
|
||||
// debug
|
||||
// fprintf (stderr, "\nScrambler Key: 0x%06X; Seed: 0x%06X; Subtype: %02d; FN: %05d; ", key, lfsr, subtype, fn);
|
||||
|
||||
return lfsr;
|
||||
}
|
||||
|
|
@ -508,7 +507,6 @@ namespace gr
|
|||
|
||||
if (dist < _sw_threshold) // stream frame syncword detected
|
||||
{
|
||||
// fprintf(stderr, "str_sync_symbols dist: %3.5f\n", dist);
|
||||
syncd = 1;
|
||||
pushed = 0;
|
||||
flp = 0;
|
||||
|
|
@ -520,7 +518,6 @@ namespace gr
|
|||
|
||||
if (dist < _sw_threshold) // LSF syncword
|
||||
{
|
||||
// fprintf(stderr, "lsf_sync dist: %3.5f\n", dist);
|
||||
syncd = 1;
|
||||
pushed = 0;
|
||||
flp = 1;
|
||||
|
|
@ -532,7 +529,6 @@ namespace gr
|
|||
|
||||
if (dist < _sw_threshold) // packet frame syncword
|
||||
{
|
||||
// fprintf(stderr, "lsf_sync dist: %3.5f\n", dist);
|
||||
syncd = 1;
|
||||
pushed = 0;
|
||||
flp = 2;
|
||||
|
|
|
|||
Loading…
Reference in New Issue