Module: PWN::SDR::Decoder::GPS

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

Overview

GPS L1 C/A (1575.42 MHz) true-air acquisition.

Parallel-code-phase search: 1 ms of I/Q resampled to 2.046 Msps (2 samp/chip), FFT-correlated (via PWN::FFI::FFTW.cfft) against each PRN 1..32 Gold code across ±5 kHz Doppler in 500 Hz steps. Emits doppler_hz:, code_phase_chips:, cn0_db_hz: for every satellite whose peak/next-peak ratio clears threshold — the same cold-start acquisition every GNSS receiver runs, no gnss-sdr binary.

Defined Under Namespace

Classes: DemodIQ

Constant Summary collapse

CHIP_RATE =
1_023_000
ACQ_RATE =

2 samp/chip → 2046-point FFT

2_046_000
DOPP_RANGE =
5000
DOPP_STEP =
500
ACQ_THRESH =

peak / mean ratio

2.5

Class Method Summary collapse

Class Method Details

.authorsObject

Author(s)

0day Inc. support@0dayinc.com



138
139
140
# File 'lib/pwn/sdr/decoder/gps.rb', line 138

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::GPS.decode( freq_obj: 'required - freq_obj returned from PWN::SDR::GQRX.init_freq' )



108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/pwn/sdr/decoder/gps.rb', line 108

public_class_method def self.decode(opts = {})
  freq_obj = opts[:freq_obj]
  rate = (opts[:sample_rate] || freq_obj[:iq_rate] || 2_048_000).to_i
  PWN::SDR::Decoder::Base.run_iq(
    freq_obj: freq_obj,
    protocol: 'GPS-L1CA',
    sample_rate: rate,
    source: opts[:source],
    file: opts[:file],
    demod: DemodIQ.new(rate: rate),
    note: 'BPSK/DSSS 1.023 Mcps — I/Q→FFT parallel-code-phase acquisition (PWN::FFI::FFTW) → PRN/Doppler/C-N0.',
    describe: proc { |_b| { modulation: 'BPSK/DSSS', chip_rate: CHIP_RATE } }
  )
end

.helpObject



142
143
144
145
146
147
148
149
150
151
152
# File 'lib/pwn/sdr/decoder/gps.rb', line 142

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 (≥2.048 Msps)'
    )

    #{self}.authors
  "
end

.parse_line(opts = {}) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/pwn/sdr/decoder/gps.rb', line 123

public_class_method def self.parse_line(opts = {})
  line = opts[:line].to_s
  out  = { protocol: 'GPS' }
  out[:prn]  = ::Regexp.last_match(1) if line =~ /PRN[ =]?(\d{1,2})/
  out[:cn0]  = ::Regexp.last_match(1) if line =~ /CN0[ =]?([\d.]+)/i
  out[:lat]  = ::Regexp.last_match(1) if line =~ /Lat(?:itude)?\s*=\s*(-?[\d.]+)/i
  out[:lon]  = ::Regexp.last_match(1) if line =~ /Long(?:itude)?\s*=\s*(-?[\d.]+)/i
  out[:alt]  = ::Regexp.last_match(1) if line =~ /Height\s*=\s*(-?[\d.]+)/i
  out[:nmea] = line if line.start_with?('$G')
  out[:summary] = out[:lat] ? "GPS FIX #{out[:lat]},#{out[:lon]}" : "GPS PRN#{out[:prn]} CN0=#{out[:cn0]}"
  out.compact
end