bin/pwn_gqrx_scanner in pwn-0.5.58 vs bin/pwn_gqrx_scanner in pwn-0.5.59

- old
+ new

@@ -240,21 +240,22 @@ ).to_f init_freq_hash = { demod_mode_n_passband: demod_n_passband, frequency: current_freq, + bandwidth: bandwidth, audio_gain_db: audio_gain_db, squelch: current_squelch, rf_gain: rf_gain, if_gain: if_gain, bb_gain: bb_gain, strength: current_strength, strength_trigger_lock_on_freq: strength_lock, lock_freq_duration: lock_freq_duration } - puts JSON.pretty_generate(init_freq_hash) + print '.' sleep lock_freq_duration if current_strength > strength_lock init_freq_hash end @@ -267,10 +268,23 @@ precision = opts[:precision] lock_freq_duration = opts[:lock_freq_duration] strength_lock = opts[:strength_lock] multiplier = 10**(precision - 1) + prev_freq_hash = { + demod_mode_n_passband: demodulator_mode, + frequency: start_freq, + bandwidth: bandwidth, + audio_gain_db: 0.0, + squelch: 0.0, + rf_gain: 0.0, + if_gain: 0.0, + bb_gain: 0.0, + strength: 0.0, + strength_trigger_lock_on_freq: strength_lock, + lock_freq_duration: lock_freq_duration + } if start_freq > target_freq start_freq.downto(target_freq) do |this_freq| next unless (i % multiplier).zero? init_freq_hash = init_freq( @@ -279,10 +293,23 @@ bandwidth: bandwidth, this_freq: this_freq, lock_freq_duration: lock_freq_duration, strength_lock: strength_lock ) + + current_strength = init_freq_hash[:strength] + prev_strength = prev_freq_hash[:strength] + prev_freq = prev_freq_hash[:frequency] + + approaching_detection = true if current_strength > prev_strength + if approaching_detection && current_strength < prev_strength + puts "**** Found a signal at ~ #{prev_freq} Hz ****" + puts JSON.pretty_generate(prev_freq_hash) + approaching_detection = false + end + + prev_freq_hash = init_freq_hash end else this_freq = start_freq while this_freq <= target_freq init_freq_hash = init_freq( @@ -292,10 +319,23 @@ this_freq: this_freq, lock_freq_duration: lock_freq_duration, strength_lock: strength_lock ) + current_strength = init_freq_hash[:strength] + prev_strength = prev_freq_hash[:strength] + prev_freq = prev_freq_hash[:frequency] + + approaching_detection = true if current_strength > prev_strength + if approaching_detection && current_strength < prev_strength + puts "\n**** Discovered a signal at #{prev_freq} Hz ****" + puts JSON.pretty_generate(prev_freq_hash) + approaching_detection = false + end + + prev_freq_hash = init_freq_hash + this_freq += multiplier end end end @@ -321,11 +361,11 @@ demodulator_mode = opts[:demodulator_mode] ||= 'WFM_ST' demodulator_mode.upcase! raise "ERROR: Invalid demodulator mode: #{demodulator_mode}" unless %w[OFF RAW AM FM WFM WFM_ST WFM_ST_OIRT LSB USB CW CWL CWU].include?(demodulator_mode) - bandwidth = opts[:bandwidth] ||= '270.000' + bandwidth = opts[:bandwidth] ||= '200.000' puts "Setting demodulator mode to #{demodulator_mode} and bandwidth to #{bandwidth}..." bandwidth = bandwidth.to_s.delete('.').to_i unless bandwidth.nil? demod_resp = gqrx_cmd( gqrx_sock: gqrx_sock, @@ -339,11 +379,11 @@ gqrx_sock: gqrx_sock, cmd: "L AF #{audio_gain_db}", resp_ok: 'RPRT 0' ) - squelch = opts[:squelch] ||= -50.0 + squelch = opts[:squelch] ||= -63.0 squelch = squelch.to_f squelch_resp = gqrx_cmd( gqrx_sock: gqrx_sock, cmd: "L SQL #{squelch}", resp_ok: 'RPRT 0' @@ -354,22 +394,22 @@ raise "ERROR: Invalid precision: #{precision}" unless (1..12).include?(precision) lock_freq_duration = opts[:lock_freq_duration] ||= 0.5 lock_freq_duration = lock_freq_duration.to_f - strength_lock = opts[:strength_lock] ||= -45.0 + strength_lock = opts[:strength_lock] ||= -60.0 strength_lock = strength_lock.to_f - rf_gain = opts[:rf_gain] ||= 16.0 + rf_gain = opts[:rf_gain] ||= 0.0 rf_gain = rf_gain.to_f squelch_resp = gqrx_cmd( gqrx_sock: gqrx_sock, cmd: "L RF_GAIN #{rf_gain}", resp_ok: 'RPRT 0' ) - intermediate_gain = opts[:intermediate_gain] ||= 40.0 + intermediate_gain = opts[:intermediate_gain] ||= 32.0 intermediate_gain = intermediate_gain.to_f squelch_resp = gqrx_cmd( gqrx_sock: gqrx_sock, cmd: "L IF_GAIN #{intermediate_gain}", resp_ok: 'RPRT 0' @@ -383,14 +423,15 @@ resp_ok: 'RPRT 0' ) s_freq_pretty = start_freq.to_s.chars.insert(-4, '.').insert(-8, '.').join t_freq_pretty = target_freq.to_s.chars.insert(-4, '.').insert(-8, '.').join - puts "*** Scanning from #{s_freq_pretty} to #{t_freq_pretty}" + puts "*** Scanning from #{s_freq_pretty} to #{t_freq_pretty}\n\n\n" scan_range( gqrx_sock: gqrx_sock, demodulator_mode: demodulator_mode, + bandwidth: bandwidth, start_freq: start_freq, target_freq: target_freq, precision: precision, lock_freq_duration: lock_freq_duration, strength_lock: strength_lock,