Module: PWN::SDR::Decoder::P25

Defined in:
lib/pwn/sdr/decoder/p25.rb

Overview

True-air + detector-fallback decoder for P25. Prefers PWN::FFI I/Q (RTL-SDR / ADALM-Pluto / HackRF / capture file) via Base.run_iq; degrades to Base.run_detector with no hardware.

Defined Under Namespace

Classes: DemodIQ

Class Method Summary collapse

Class Method Details

.authorsObject

Author(s)

0day Inc. support@0dayinc.com



115
116
117
# File 'lib/pwn/sdr/decoder/p25.rb', line 115

public_class_method def self.authors
  "AUTHOR(S):\n  0day Inc. <support@0dayinc.com>\n"
end

.decode(opts = {}) ⇒ Object

Supported Method Parameters

PWN::SDR::Decoder::P25.decode( freq_obj: 'required - freq_obj returned from PWN::SDR::GQRX.init_freq' )



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/pwn/sdr/decoder/p25.rb', line 74

public_class_method def self.decode(opts = {})
  freq_obj = opts[:freq_obj]

  rate  = (opts[:sample_rate] || freq_obj[:iq_rate] || 480_000).to_i
  proto = 'P25'
  demod = DemodIQ.new(
    rate: rate, protocol: proto, modulation: 'C4FM',
    extra: { threshold: 6.0 }
  )
  PWN::SDR::Decoder::Base.run_iq(
    freq_obj: freq_obj,
    protocol: proto,
    sample_rate: rate,
    source: opts[:source],
    file: opts[:file],
    demod: demod,
    threshold: 6.0,
    note: 'C4FM 4-FSK + trellis — true-air I/Q path reports key-up bursts; full NAC/TG decode layered on Liquid when available.',
    describe: proc { |b|
      { modulation: 'C4FM', classification: (if b[:duration_ms] > 1500
                                               'voice-superframe'
                                             else
                                               (b[:duration_ms] > 150 ? 'LDU/HDR' : 'TSBK/control')
                                             end) }
    }
  )
end

.helpObject



119
120
121
122
123
124
125
126
127
128
129
# File 'lib/pwn/sdr/decoder/p25.rb', line 119

public_class_method def self.help
  puts "USAGE (true-air I/Q via PWN::FFI + detector fallback):
    #{self}.decode(
      freq_obj: 'required - freq_obj returned from PWN::SDR::GQRX.init_freq',
      source:   'optional - :auto|:rtlsdr|:adalm_pluto|:file',
      file:     'optional - .cu8/.cs16 capture'
    )

    #{self}.authors
  "
end

.parse_line(opts = {}) ⇒ Object



102
103
104
105
106
107
108
109
110
111
# File 'lib/pwn/sdr/decoder/p25.rb', line 102

public_class_method def self.parse_line(opts = {})
  line = opts[:line].to_s
  out  = { protocol: 'P25' }
  out[:nac]  = ::Regexp.last_match(1) if line =~ /NAC[:= ]+([0-9A-Fa-f]+)/
  out[:tg]   = ::Regexp.last_match(1) if line =~ /(?:TG|talkgroup)[:= ]+(\d+)/i
  out[:rid]  = ::Regexp.last_match(1) if line =~ /(?:RID|src|source)[:= ]+(\d+)/i
  out[:sys]  = ::Regexp.last_match(1) if line =~ /sys(?:tem)?[:= ]+(\w+)/i
  out[:summary] = "P25 NAC=#{out[:nac]} TG=#{out[:tg]} RID=#{out[:rid]}"
  out.compact
end