Files
intercept/templates/partials/modes/ook.html
thatsatechnique 18db66bce3 fix(ook): harden for upstream review — tests, cleanup, CSS extraction
- Add kill_all() handler for OOK process cleanup on global reset
- Fix stop_ook() to close pipes and join parser thread (prevents hangs)
- Add ook.css with CSS classes, replace inline styles in ook.html
- Register ook.css in lazy-load style map (INTERCEPT_MODE_STYLE_MAP)
- Fix frontend frequency min=24 to match backend validation
- Add 22 unit tests for decode_ook_frame, ook_parser_thread, and routes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 14:52:32 -08:00

151 lines
7.1 KiB
HTML

<!-- OOK SIGNAL DECODER MODE -->
<div id="ookMode" class="mode-content">
<div class="section">
<h3>OOK Signal Decoder</h3>
<p class="info-text" style="font-size: 11px; color: var(--text-dim); margin-bottom: 12px;">
Decode raw OOK (On-Off Keying) signals via rtl_433 flex decoder.
Captures frames with configurable pulse timing and displays raw bits,
hex, and attempted ASCII — useful for unknown ISM-band protocols.
</p>
</div>
<div class="section">
<h3>Frequency</h3>
<div class="form-group">
<label>Frequency (MHz)</label>
<input type="number" id="ookFrequency" value="433.920" step="0.001" min="24" max="1766">
</div>
<div class="form-group">
<label>Presets <span class="ook-preset-hint">(right-click to remove)</span></label>
<div id="ookPresetButtons" class="ook-presets">
<!-- Populated by OokMode.renderPresets() -->
</div>
<div class="ook-preset-add">
<input type="text" id="ookNewPresetFreq" placeholder="MHz">
<button class="preset-btn" onclick="OokMode.addPreset()" style="background: #2ecc71; color: #000;">Add</button>
<button class="preset-btn" onclick="OokMode.resetPresets()" style="font-size: 10px;">Reset</button>
</div>
</div>
</div>
<div class="section">
<h3>SDR Settings</h3>
<div class="form-group">
<label>Gain (dB)</label>
<input type="number" id="ookGain" value="40" step="1" min="0" max="50">
</div>
<div class="form-group">
<label>PPM Correction</label>
<input type="number" id="ookPPM" value="0" step="1" min="-100" max="100">
</div>
</div>
<div class="section">
<h3>Modulation</h3>
<div class="form-group">
<div class="ook-encoding-btns">
<button class="preset-btn" id="ookEnc_pwm"
onclick="OokMode.setEncoding('pwm')"
style="background: var(--accent); color: #000;">PWM</button>
<button class="preset-btn" id="ookEnc_ppm"
onclick="OokMode.setEncoding('ppm')">PPM</button>
<button class="preset-btn" id="ookEnc_manchester"
onclick="OokMode.setEncoding('manchester')">Manchester</button>
</div>
<input type="hidden" id="ookEncoding" value="pwm">
<p id="ookEncodingHint" class="info-text" style="font-size: 10px; color: var(--text-dim); margin-top: 4px;">
Short pulse = 0, long pulse = 1. Most common for ISM OOK.
</p>
</div>
</div>
<div class="section">
<h3>Pulse Timing</h3>
<p class="info-text" style="font-size: 10px; color: var(--text-dim); margin-bottom: 8px;">
Pulse widths in microseconds for the flex decoder.
</p>
<div class="ook-timing-grid">
<div class="form-group">
<label>Short (&mu;s)</label>
<input type="number" id="ookShortPulse" value="300" step="10" min="50" max="5000">
</div>
<div class="form-group">
<label>Long (&mu;s)</label>
<input type="number" id="ookLongPulse" value="600" step="10" min="100" max="10000">
</div>
<div class="form-group">
<label>Gap/Reset (&mu;s)</label>
<input type="number" id="ookResetLimit" value="8000" step="100" min="500" max="50000">
</div>
<div class="form-group">
<label>Gap limit (&mu;s)</label>
<input type="number" id="ookGapLimit" value="5000" step="100" min="500" max="50000">
</div>
<div class="form-group">
<label>Tolerance (&mu;s)</label>
<input type="number" id="ookTolerance" value="150" step="10" min="10" max="1000">
</div>
<div class="form-group">
<label>Min bits</label>
<input type="number" id="ookMinBits" value="8" step="1" min="1" max="512">
</div>
</div>
<div class="form-group" style="margin-top: 8px;">
<label style="font-size: 10px; color: var(--text-dim);">Quick presets (short/long &mu;s)</label>
<div class="ook-timing-presets">
<button class="preset-btn" onclick="OokMode.setTiming(300,600,8000,5000,150,8)"
title="Generic ISM default">300/600</button>
<button class="preset-btn" onclick="OokMode.setTiming(300,900,8000,5000,150,16)"
title="PWM common variant">300/900</button>
<button class="preset-btn" onclick="OokMode.setTiming(400,800,8000,5000,150,16)"
title="Generic 2:1 ratio">400/800</button>
<button class="preset-btn" onclick="OokMode.setTiming(500,1500,10000,6000,200,16)"
title="Long-range keyfob">500/1500</button>
<button class="preset-btn" onclick="OokMode.setTiming(500,1000,8000,5000,150,8)"
title="Manchester clock period">500 MC</button>
</div>
</div>
</div>
<div class="section">
<h3>Options</h3>
<div class="form-group">
<label class="ook-dedup-label">
<input type="checkbox" id="ookDeduplicate">
<span>Deduplicate frames</span>
</label>
<p class="info-text" style="font-size: 10px; color: var(--text-dim); margin-top: 4px;">
Suppress consecutive frames with identical hex content.
Useful when a transmitter repeats the same packet multiple times.
</p>
</div>
</div>
<!-- Status -->
<div class="section">
<div class="ook-status-row">
<span id="ookStatusIndicator" class="ook-status-dot"></span>
<span id="ookStatusText">Standby</span>
<span style="margin-left: auto;" id="ookFrameCount">0 frames</span>
</div>
</div>
<div class="section">
<p class="info-text ook-warning">
Uses rtl_433 with a custom flex decoder. Requires rtl_433 installed.
Works on any OOK/ASK signal in the SDR's frequency range.
</p>
<div id="ookCommandDisplay" class="ook-command-display">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px;">
<span class="ook-command-label">Active Command</span>
<button class="btn btn-sm btn-ghost" onclick="OokMode.copyCommand()" title="Copy to clipboard"
style="font-size: 9px; padding: 1px 6px;">Copy</button>
</div>
<pre id="ookCommandText" class="ook-command-text"></pre>
</div>
</div>
<button class="run-btn" id="ookStartBtn" onclick="OokMode.start()">Start Decoder</button>
<button class="stop-btn" id="ookStopBtn" onclick="OokMode.stop()" style="display: none;">Stop Decoder</button>
</div>