docs(wiki): memo on discovery mechanisms for cameras, printers and the relay (SADP/ONVIF probed on the lab VLAN); park-2 readers switched to HTTP from the wizard
This commit is contained in:
@@ -0,0 +1,179 @@
|
||||
---
|
||||
type: decision
|
||||
tags: [parking, decisions, devices, setup, discovery, cameras, printers, relay, readers]
|
||||
sources: [dingtian-qr-linux-tool, ds-2cd1047g3h-liu]
|
||||
updated: 2026-10-08
|
||||
status: open
|
||||
---
|
||||
|
||||
# Memo: discovery mechanisms for the devices we already know
|
||||
|
||||
**Ask (operator, 2026-10-08):** write down how we will give every known device class — relays,
|
||||
printers, cameras, readers — a **Scan** in the setup wizard, the way the DT-008 reader got one
|
||||
today. This memo is the plan: what exists, the method that worked, what each device can
|
||||
actually answer on the wire (probed on the lab VLAN today where possible), the rules that carry
|
||||
over, and the order to build in. Nothing here is built except the reader.
|
||||
|
||||
## 1. Why discovery is worth building (the park-2 lesson)
|
||||
|
||||
[[first-run-setup]] has the admin **type** what a device is — IP, serial, port. Nothing checked
|
||||
that the typed picture matched the device. park-2 ran a month with two readers whose typed
|
||||
config was perfect and whose *actual* output mode was Wiegand: every card "beeped" and none
|
||||
reached the booth ([[site-device-installation]] §2 trap). Discovery is the reality check that
|
||||
replaces typing with **what the device says about itself**, and — the part that matters more —
|
||||
its companion **identity precondition**: *the serial/MAC you typed is the one the device at
|
||||
that IP reports*. The same mechanism ends the Windows-tool-on-a-laptop site visits (SADP for
|
||||
cameras, the Dingtian tools, printer utilities): one laptop-free wizard on the booth.
|
||||
|
||||
## 2. What already exists (don't rebuild)
|
||||
|
||||
- `DiscoverableDriver.discover() → DiscoveredDevice[]` in `@parking/devices` (`id`, `label`,
|
||||
`config` to auto-fill, free-form `info`), the registry's `isDiscoverable()`, the catalog's
|
||||
`discoverable` list, admin-only `GET /api/setup/discover/:driverId` (health-checks each hit),
|
||||
and the wizard's **Scan** button + **Use** per row, rendering every `info` key
|
||||
([[device-discovery]]).
|
||||
- The write side that discovery feeds: `PreconditionDevice` (check → fixable/unfixable issues,
|
||||
shown on **Test**, fixed on **Save**), `PushConfigurableDevice` (point the device at this
|
||||
booth), `HardenableDevice`. The DT-008 driver is the worked example of all three together.
|
||||
- Already a discovery in all but name: `GET /api/setup/usb-printers` lists `/dev/usb/lpN` with
|
||||
the printer's self-reported make/model from sysfs `ieee1284_id` ([[printer-usb-transport]]).
|
||||
|
||||
## 3. The method that worked for the DT-008 (reuse it verbatim)
|
||||
|
||||
1. **Learn the protocol on the bench, never on a site.** Vendor tool + a lab unit; capture the
|
||||
tool's own datagrams or read the vendor doc. Write it up as `raw/<device>/PROTOCOL.md`
|
||||
(frame, ports, commands, field tables, *verification status per command*).
|
||||
2. **TypeScript module + fake-device tests** (`drivers/<device>-config.ts`, `*.test.ts` with a
|
||||
loopback fake that enforces the protocol's quirks — e.g. the DT-008's two-datagram writes).
|
||||
3. **Driver hooks:** `discover()` (search → per-hit identity read → `config` + `info`),
|
||||
`checkPreconditions()` (identity match + the one or two settings our flow depends on),
|
||||
`fixPreconditions()` / `configureInputPush()` only for settings proven writable.
|
||||
4. **Bench round trip with restore**: change → read back → change back → byte-diff the device's
|
||||
config. Only then touch a site, and there only through the wizard.
|
||||
5. Wiki: entity page, [[device-discovery]], [[first-run-setup]], the install runbook, log.
|
||||
|
||||
## 4. Per device: what answers on the wire
|
||||
|
||||
Status legend: **verified** = we saw it on the lab VLAN today (host `10.0.10.203`);
|
||||
**documented** = vendor doc / wiki says so, not yet seen; **unknown** = needs a capture.
|
||||
|
||||
| device | mechanism | transport | returns | status |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| DT-008 reader | vendor search cmd 2 | UDP bcast 24582 | serial, IP, server:port | **verified, built** |
|
||||
| Hikvision cameras / DVR | **SADP** Probe | UDP mcast `239.255.255.250:37020`, XML | model, **serial**, **MAC**, IPv4, HTTP + command port, (activation state) | **verified**: 9 devices answered |
|
||||
| Hikvision, Dahua, any IP camera | **ONVIF WS-Discovery** Probe | UDP mcast `239.255.255.250:3702`, SOAP | `XAddrs` (device-service URL), scopes: hardware model, name, sometimes MAC | **verified** on 4 Hikvision; the bench Dahua did **not** answer (see 4.2) |
|
||||
| Dahua cameras | ConfigTool search ("DHIP") | UDP bcast 37810 | (per vendor tool: IP, MAC, serial, model) | **unknown** — my guessed frame got no reply; capture the ConfigTool like the DT-008 exe |
|
||||
| Dingtian relay | search | UDP mcast `224.0.2.11:60000`, payload `05 AA` | "devices reply" ([[dingtian-relay]]) — reply content not recorded | **documented**; no relay on the lab VLAN to probe |
|
||||
| Rongta / K200L LAN printers | no vendor discovery known to us | — | — | **unknown** (vendor utilities exist; protocol uncaptured) |
|
||||
| any network ESC/POS printer | **TCP 9100 sweep** of the device subnet + web fingerprint | TCP connect ×254 in parallel, then HTTP GET | IP; model only via the board's web page | **verified**: 2 hits (`.220`, `.234`) in ~1 s — both *office* printers, neither ours → fingerprint is mandatory |
|
||||
| USB printers | `/dev/usb/lpN` + `ieee1284_id` | sysfs | path, MFG/MDL | **built** |
|
||||
|
||||
### 4.1 Cameras — two protocols, run both, merge by MAC/serial
|
||||
|
||||
- **SADP** is the one that finds *everything Hikvision*, including units whose ONVIF is off
|
||||
(5 of today's 9 answered SADP only) and **unactivated** units (factory `192.168.1.64`,
|
||||
`<Activated>false</Activated>`) — i.e. the exact state a new G3H arrives in. Its ProbeMatch
|
||||
carries `DeviceDescription` (model), `DeviceSN`, `MAC`, `IPv4Address`, `HttpPort`,
|
||||
`CommandPort` (8000). Newer firmware (the DVR today) adds `<Encrypt>true</Encrypt><Salt>…`
|
||||
for its *write* side; the inquiry itself stays plaintext. SADP can also **activate** a camera
|
||||
and **set its IP** (password-protected) — the runbook's "activate with SADP or the browser"
|
||||
step ([[site-device-installation]] §3) could become a wizard action later; discovery first.
|
||||
- **WS-Discovery** is the vendor-neutral path and the only standard one Dahua offers. Scopes
|
||||
give the model (`onvif://www.onvif.org/hardware/DS-2CD2T43G0-I5`) and `XAddrs` gives the
|
||||
device-service URL — enough to pick the driver (`DS-…` → `hikvision`, Dahua names → `dahua`)
|
||||
and the IP. **Caveat seen today:** the bench IPC-HFW2549T answered neither WS-Discovery nor
|
||||
my 37810 guess; Dahua ships ONVIF switchable (web UI → Network → *Integration Protocol* /
|
||||
ONVIF) — check that unit's setting before concluding anything. Record the outcome on
|
||||
[[dahua-ipc-hfw2549t]].
|
||||
- **Identity precondition for cameras:** on Use, store `serial` (SADP `DeviceSN` / ONVIF
|
||||
scope) + `mac` next to `host`; on Test/Save compare with what the camera reports over its own
|
||||
API (Hikvision `/ISAPI/System/deviceInfo` → `serialNumber`; Dahua
|
||||
`magicBox.cgi?action=getSerialNo`). A swapped or re-addressed camera then fails loudly instead
|
||||
of silently snapshotting the wrong lane. Further preconditions the same hook can own, all from
|
||||
past incidents: clock drift ([[lpr-camera]] clock sync), ANPR push target = this booth
|
||||
([[lpr-camera]] §Camera PUSH — Alarm Server), vehicle target filter on.
|
||||
- Shape: keep the per-driver API; `hikvisionDriver.discover()` = SADP ∪ ONVIF filtered to
|
||||
Hikvision hardware, `dahuaDriver.discover()` = ONVIF filtered ∪ (37810 once captured). Merge by
|
||||
MAC, then serial; never by IP.
|
||||
|
||||
### 4.2 Dingtian relay — documented, unprobed
|
||||
|
||||
[[dingtian-relay]] records the vendor's search: multicast `224.0.2.11:60000`, payload `05 AA`,
|
||||
devices reply; defaults IP `192.168.1.100`, UDP 60000 binary / 60001 string. Open before
|
||||
building: (a) what the reply contains (MAC? firmware? — needed for identity; our relay config
|
||||
has no serial today, identity is the IP alone); (b) whether a **hardened** board (relay_pw set,
|
||||
string protocol disabled — [[dingtian-relay]] §hardening) still answers an unauthenticated
|
||||
search — if not, discovery only finds *new* boards, which is still the useful case; (c) whether
|
||||
the reply can come back on the host network from a multicast group (needs
|
||||
`IP_ADD_MEMBERSHIP` on the device-VLAN interface, or the board may answer by unicast to the
|
||||
sender — capture to know). Needs a board on the bench; one visit of the vendor tool with the
|
||||
same capture method as the DT-008.
|
||||
|
||||
### 4.3 Printers — sweep + fingerprint, not a vendor protocol
|
||||
|
||||
Neither the Rongta board nor the K200L's "J-Speed" LAN module has a discovery protocol we know;
|
||||
both vendors ship Windows utilities that surely broadcast something, uncaptured. The pragmatic
|
||||
mechanism is already verified: **connect to TCP 9100 on every address of the device subnet in
|
||||
parallel** (254 probes, ~1 s), then **fingerprint each hit over HTTP**: Rongta answers
|
||||
`GET /prn_stat.htm` with its status page ([[rongta-printer]]); the K200L web configurator is a
|
||||
three-frame page titled "Ethernet WebConfig" ([[k200l-printer]]); anything else is listed as
|
||||
"unknown 9100 device" (today's two office printers would be). Identity: the K200L *Information*
|
||||
frame shows its MAC; Rongta's pages carry none we know — fall back to the ARP entry after the
|
||||
connect (`/proc/net/arp` on the host network). No ESC/POS serial exists over 9100, so the
|
||||
precondition is weaker here: "a Rongta/K200L board still answers at this IP" plus the live
|
||||
status page. Preconditions worth owning: USB path still present (already in the USB select),
|
||||
network board reachable, paper/cover state ([[printer-status-monitoring]]).
|
||||
|
||||
### 4.4 DT-008 reader — built; two gaps
|
||||
|
||||
Discovery, identity (serial), output mode and push target are done. Still manual: giving a
|
||||
factory `192.168.1.99` unit its site IP (cmd 32 `set-network` supports it — a "Set IP" action
|
||||
in the discovery row would finish the laptop-free install), and prefixes / card format (cmds
|
||||
12/14/44/8). Both are in `scripts/dingtian_qr.py` today ([[dingtian-qr-linux-tool]]).
|
||||
|
||||
## 5. Rules that carry over to every implementation
|
||||
|
||||
1. **Subnet-directed broadcast per interface**, never `255.255.255.255` (EACCES on some
|
||||
hosts, and not what vendor tools send); **multicast needs `IP_MULTICAST_IF` per interface**
|
||||
and, to *receive* group traffic, `IP_ADD_MEMBERSHIP` — SADP/ONVIF replied by unicast to the
|
||||
sender today, so sending was enough; don't assume that for the relay.
|
||||
2. **Replies arrive from arbitrary source ports** — match on content, not port; collect for a
|
||||
window (~2 s), then stop.
|
||||
3. **Dedupe and identify by a stable identity (serial, MAC) — never by IP**; the IP is the thing
|
||||
most likely to be wrong.
|
||||
4. **Discovery is read-only.** "Use" fills the form; writes happen only on Save, through
|
||||
preconditions/push-config, each proven on the bench with a restore. Discovery must never be
|
||||
periodic/background: it is an admin action in Setup, so the booth operator (our adversary,
|
||||
[[threat-model]]) has no new lever.
|
||||
5. **L2 only.** Works from the booth (host-network server) and the device VLAN; impossible
|
||||
from a bridged dev container and across Netbird — say so in the empty-result message
|
||||
(the wizard's "no devices found" text already does).
|
||||
6. **Replies are untrusted input** from an unauthenticated network: cap sizes, parse XML
|
||||
without entity expansion, never pass a reply string into a shell/URL unescaped, never
|
||||
forward credentials to a discovered address without the identity check.
|
||||
7. **Serials and MACs are site data** — they go in the device row, not in commits/wiki with
|
||||
booth names ([[fleet-deployment-komodo]] pseudonymity rule).
|
||||
|
||||
## 6. Order of work
|
||||
|
||||
1. **Cameras — SADP + WS-Discovery** (protocols verified today; no bench captures needed;
|
||||
biggest field pain = activation/IP of new units; two vendors covered). Half a day plus the
|
||||
identity precondition.
|
||||
2. **Printers — 9100 sweep + fingerprint** (verified mechanism, small code, replaces guessing
|
||||
the printer's IP at park-buzi-type installs).
|
||||
3. **Dingtian relay search** — when a board is on the bench; capture the reply first.
|
||||
4. **Dahua 37810** — capture the ConfigTool; until then Dahua relies on ONVIF being enabled.
|
||||
5. **DT-008 "Set IP" from the discovery row** (set-network is proven).
|
||||
|
||||
## 7. Open questions
|
||||
|
||||
- Does a hardened Dingtian board answer the `05 AA` search? What is in the reply?
|
||||
- Is ONVIF off on the bench Dahua, or did the probe not reach it? (web UI check, then re-probe)
|
||||
- SADP `Encrypt/Salt` on newer firmware: inquiry stays plaintext — confirm on a 2026 unit.
|
||||
- Rongta board MAC/identity: any page or ESC/POS query that returns a stable id?
|
||||
- Should the camera row offer **activate + set IP** (SADP write side), or stay read-only and
|
||||
leave activation to the browser? (Leaning read-only first; writes only after a bench round trip.)
|
||||
|
||||
Related: [[device-discovery]] · [[device-registry]] · [[first-run-setup]] ·
|
||||
[[site-device-installation]] · [[dingtian-dt008-reader]] · [[dingtian-relay]] · [[lpr-camera]] ·
|
||||
[[dahua-ipc-hfw2549t]] · [[rongta-printer]] · [[k200l-printer]] · [[dingtian-qr-linux-tool]]
|
||||
@@ -2,7 +2,7 @@
|
||||
type: decision
|
||||
tags: [parking, decisions, open]
|
||||
sources: [parking-system-architecture]
|
||||
updated: 2026-09-08
|
||||
updated: 2026-10-08
|
||||
status: open
|
||||
---
|
||||
|
||||
@@ -170,3 +170,11 @@ procurement. (See [[parking-system-architecture]] §10.)
|
||||
`8H` is required for 13.56 MHz sites before any card is enrolled against one. (Phones present a
|
||||
random `08…` UID per tap and can never be credentials.) See
|
||||
[[dingtian-dt008-reader]] §"Two RF variants".
|
||||
|
||||
19. **Discovery for every known device class.** _(Raised by the user, 2026-10-08, after the
|
||||
park-2 readers turned out to be in Wiegand mode for a month.)_ The wizard's Scan exists
|
||||
generically and the DT-008 implements it; cameras (SADP + ONVIF, both verified on the lab
|
||||
VLAN), network printers (9100 sweep + fingerprint), the Dingtian relay (multicast search,
|
||||
reply unknown) and Dahua (37810, uncaptured) do not. Plan, rules and order of work:
|
||||
[[device-discovery-roadmap]]. Settles when cameras and printers scan from the wizard and the
|
||||
relay's search reply has been captured on the bench.
|
||||
|
||||
Reference in New Issue
Block a user