feat(readers): same-code debounce at the dispatcher, per-reader window (default 5000 ms)
Build & push images / images (push) Successful in 3m7s

park-2, 2026-10-11: the DT-008 entry reader reported one card twice 560 ms
apart; the permit flow opened two sessions on the same permit and pulsed the
barrier twice (caught by the new relay-pulse log). The 24h before showed
2 entry + 2 exit opens within 2 s of the previous one.

ReadDispatcher now treats the same value from the same reader inside the
reader's debounceMs window as ONE presentation: the first verdict is replayed
(same beep, no second decision, nothing signed twice) and the repeat lands in
device_events as unsigned telemetry. Every lane and every credential kind,
so a ticket re-scanned at exit inside its grace period no longer signs a
noSession refusal for a car that just left. The window slides with repeats;
a repeat arriving while the first read is still deciding gets that decision.

The window is a Setup field on all three reader drivers ("Same-code
debounce (ms)", default 5000, 0 = off); readers configured before the field
existed get the default.
This commit is contained in:
2026-10-11 18:55:29 +02:00
parent c94269379e
commit ec015911e9
5 changed files with 256 additions and 4 deletions
+23 -1
View File
@@ -2,7 +2,7 @@
type: entity
tags: [parking, hardware, readers, qr, dingtian]
sources: [dingtian-dt008, dingtian-qr-linux-tool]
updated: 2026-10-08
updated: 2026-10-11
status: open
---
@@ -168,6 +168,28 @@ not in our DB — re-apply after any factory reset/swap): the two **output prefi
the server's expected `Q:`/`K:`), and **`Card Input format` (currently `6H`)** — it defines the
UID shape we enroll; changing it later silently orphans every enrolled card.
## Same-code debounce at the dispatcher (park-2, 2026-10-11)
The reader can report ONE presentation TWICE. Seen live on park-2 the evening the relay-pulse logging
went in: the entry reader (`HC009E84`) pushed card `3F3AFC` at 16:25:38.119Z and again at 16:25:38.679Z
(560 ms apart); the permit flow opened **two** sessions on the same permit and the barrier was pulsed
**twice**. The 24 h before showed 2 entry + 2 exit opens within 2 s of the previous one, so it is not a
one-off. A card held a beat too long or a QR re-decoded while the hand moves does the same, and at exit
a repeat scan of a ticket inside its grace period would sign a `noSession` refusal for a car that just
left — a red row for nobody (same alarm-fatigue problem as the phantom decodes below).
**Fix (host-side, every reader, every lane, every credential kind):** `ReadDispatcher` keeps the recent
reads keyed `deviceId:kind:value`; the same value from the same reader inside the reader's
**`debounceMs`** window is one presentation — the FIRST verdict is **replayed** (the reader beeps the
same way, no second decision, nothing signed twice) and the repeat is kept as unsigned
`device_events` telemetry (`debounced: true`, `sinceMs`, `replayedAccepted`). The window slides on
each repeat (a card that keeps re-reading stays one presentation). A repeat that arrives while the
first read is still deciding awaits that same decision. The window is a **per-reader Setup field**
(`debounceMs`, "Same-code debounce (ms)", default **5000**, `0` = off) on all three reader drivers
(`packages/devices/src/drivers/reader.ts` `debounceField`); readers configured before the field
existed get the default. Plates are not affected in practice — the ANPR bridge debounces them itself
for longer ([[lane-presence-and-anpr-entry]]). Tests: `read-dispatch-debounce.test.ts`.
## ⚠️ Phantom optical decodes from sunlight patterns (park-buzi, 2026-07-04)
With the site EMPTY (pre-opening, verified live + by snapshot), the **exit reader