Module: PWN::SDR::Decoder::RTL433
- Defined in:
- lib/pwn/sdr/decoder/rtl433.rb
Overview
True-air + detector-fallback decoder for RTL433. 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
-
.authors ⇒ Object
- Author(s)
0day Inc.
-
.decode(opts = {}) ⇒ Object
- Supported Method Parameters
PWN::SDR::Decoder::RTL433.decode( freq_obj: 'required - freq_obj returned from PWN::SDR::GQRX.init_freq' ).
- .help ⇒ Object
- .parse_line(opts = {}) ⇒ Object
Class Method Details
.authors ⇒ Object
- Author(s)
0day Inc. support@0dayinc.com
126 127 128 |
# File 'lib/pwn/sdr/decoder/rtl433.rb', line 126 public_class_method def self. "AUTHOR(S):\n 0day Inc. <support@0dayinc.com>\n" end |
.decode(opts = {}) ⇒ Object
- Supported Method Parameters
PWN::SDR::Decoder::RTL433.decode( freq_obj: 'required - freq_obj returned from PWN::SDR::GQRX.init_freq' )
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 101 102 |
# File 'lib/pwn/sdr/decoder/rtl433.rb', line 76 public_class_method def self.decode(opts = {}) freq_obj = opts[:freq_obj] rate = (opts[:sample_rate] || freq_obj[:iq_rate] || 250_000).to_i proto = 'ISM-433' demod = DemodIQ.new( rate: rate, protocol: proto, modulation: 'OOK/ASK/FSK', extra: { threshold: 10.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: 10.0, note: 'True-air I/Q path characterises OOK/FSK bursts; offline rtl_433 JSON via .parse_line.', describe: proc { |b| { modulation: 'OOK/ASK/FSK', classification: (if b[:duration_ms] < 20 'keyfob/OOK-short' else (b[:duration_ms] < 120 ? 'sensor/OOK-packet' : 'FSK-continuous') end) } } ) end |
.help ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/pwn/sdr/decoder/rtl433.rb', line 130 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
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/pwn/sdr/decoder/rtl433.rb', line 104 public_class_method def self.parse_line(opts = {}) line = opts[:line].to_s h = begin JSON.parse(line, symbolize_names: true) rescue StandardError { unparsed: line } end out = { protocol: 'RTL433' }.merge(h) bits = [] bits << out[:model].to_s if out[:model] bits << "id=#{out[:id]}" if out[:id] bits << "ch=#{out[:channel]}" if out[:channel] bits << "code=#{out[:code]}" if out[:code] bits << "cmd=#{out[:cmd] || out[:button]}" if out[:cmd] || out[:button] bits << "temp=#{out[:temperature_C]}C" if out[:temperature_C] bits << "rssi=#{out[:rssi]}" if out[:rssi] out[:summary] = bits.empty? ? line[0, 120] : bits.join(' ') out end |