id: m17_m17_coder
label: M17 Encoder
category: '[M17]'

parameters:
- id: src_id
  label: Source callsign
  dtype: string
  default: 'N0CALL'
- id: dst_id
  label: Destination callsign
  dtype: string
  default: 'ALL'
- id: mode
  label: Mode
  dtype: int
  default: 1
  options: [1, 0]
  option_labels: ['Stream', 'Packet']
- id: type
  label: Type
  dtype: int
  default: 2
  options: [0, 1, 2, 3]
  option_labels: ['Reserved', 'Data', 'Voice', 'Voice+Data']
- id: encr_type
  label: Encr. type
  dtype: int
  default: 0
  options: [0, 1, 2, 3]
  option_labels: ['None', 'Scrambler', 'AES', 'Other/Reserved']
- id: encr_subtype
  label: Encr. subtype
  dtype: int
  default: 0
  options: [0, 1, 2, 3]
  option_labels: ['Text', 'Geolocation', 'Extended callsign data', 'Reserved']
- id: can
  label: CAN
  dtype: int
  default: 0
- id: meta
  label: Meta
  dtype: string
  default: ''
- id: seed
  label: Scrambler seed
  dtype: string
  default: ''
- id: key
  label: AES Key
  dtype: string
  default: ''
- id: priv_key
  label: Private Key for ECDSA (32 bytes)
  dtype: string
  default: ''
- id: signed_str
  label: SignedStr
  dtype: bool
  default: 'False'
  options: ['True', 'False']
- id: debug
  label: Debug
  dtype: bool
  default: 'False'
  options: ['True', 'False']

asserts:
    - ${ can <= 15 }
    - ${ len(key) <= 32 }
    - ${ len(priv_key) <= 32 }
    - ${ len(dst_id) < 10 }
    - ${ len(src_id) < 10 }
templates:
  imports: from gnuradio import m17
  make: m17.m17_coder(${src_id},${dst_id},${mode},${type},${encr_type},${encr_subtype},${can},${meta},${key},${priv_key},${debug},${signed_str},${seed})
  callbacks:
    - set_meta(${meta})
    - set_src_id(${src_id})
    - set_dst_id(${dst_id})
    - set_mode(${mode})
    - set_type(${type})
    - set_encr_type(${encr_type})
    - set_encr_subtype(${encr_subtype})
    - set_can(${can})
    - set_key(${key})
    - set_priv_key(${priv_key})
    - set_debug(${debug})
    - set_signed(${signed_str})
    - set_seed(${seed})

#  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
- label: end_of_transmission
  domain: message
  optional: 0

outputs:
- label: out
  domain: stream
  dtype: float
  vlen: 1
  optional: 0

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.

#  'file_format' specifies the version of the GRC yml format used in the file
#  and should usually not be changed.
file_format: 1

