From 580ab2b63fe6762da65a7a99c42e63f3d598a154 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 19 Mar 2026 12:33:57 -0700 Subject: [PATCH] feat(fw): live streaming sniff with button-toggle pause/resume MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add CMD_HF_SNIFF_STREAM (0x0337) and CMD_HF_SNIFF_STATUS (0x0338) for fire-and-forget trace streaming during sniff. Unified sniff loop uses the same proven decode path for both streaming and legacy modes — streaming replaces LogTrace with ring buffer SNIFF_PUSH/SNIFF_FLUSH. Firmware features: - Idle flush: sends buffered trace entries over USB when RF is quiet for idle_timeout_ms (configurable, default 400ms for 15693) - Button-toggle: pause/resume sniffing without restarting - DMA restart on resume for clean decoder state - BREAK_LOOP support for Python-side session.stop() - Legacy mode (flags=0) preserved unchanged Python constants: SNIFF_FLAG_STREAMING, SNIFF_FLAG_BUTTON_TOGGLE, SNIFF_STATE_STARTED/PAUSED/RESUMED/STOPPED, Cmd.HF_SNIFF_STREAM/STATUS --- firmware | 2 +- pm3py/core/protocol.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/firmware b/firmware index 40475a6..7662552 160000 --- a/firmware +++ b/firmware @@ -1 +1 @@ -Subproject commit 40475a6684d51f38518d61d1f69114f046a6c2d0 +Subproject commit 76625524b437fcca2aa7a0a77d13a544f947b067 diff --git a/pm3py/core/protocol.py b/pm3py/core/protocol.py index a9fd85c..79ba814 100644 --- a/pm3py/core/protocol.py +++ b/pm3py/core/protocol.py @@ -202,6 +202,9 @@ class Cmd(IntEnum): HF_ISO15693_CSETUID = 0x0316 HF_ISO15693_EML_SETMEM = 0x0331 + HF_SNIFF_STREAM = 0x0337 + HF_SNIFF_STATUS = 0x0338 + # Sim table commands (firmware response table) SIM_TABLE_UPLOAD = 0x0900 SIM_TABLE_CLEAR = 0x0901 @@ -265,3 +268,14 @@ class Cmd(IntEnum): FPGAMEM_DOWNLOADED = 0x0803 UNKNOWN = 0xFFFF + + +# Sniff streaming flags +SNIFF_FLAG_STREAMING = 0x01 +SNIFF_FLAG_BUTTON_TOGGLE = 0x02 + +# Sniff states +SNIFF_STATE_STARTED = 0 +SNIFF_STATE_PAUSED = 1 +SNIFF_STATE_RESUMED = 2 +SNIFF_STATE_STOPPED = 3