diff --git a/wiki/concepts/device-discovery.md b/wiki/concepts/device-discovery.md index e48d463..e8d0f79 100644 --- a/wiki/concepts/device-discovery.md +++ b/wiki/concepts/device-discovery.md @@ -38,6 +38,13 @@ with the readers: works from the booth (host-network server) and the device VLAN bridged dev container (`docker-compose.dev.yml`) nor across Netbird — there, use `scripts/dingtian_qr.py get ` on the booth instead. +## Roadmap for the other devices + +Cameras (SADP + ONVIF WS-Discovery, both verified on the lab VLAN 2026-10-08), network printers +(TCP 9100 sweep + web fingerprint), the Dingtian relay's multicast search and Dahua's 37810 tool +protocol — with the method and rules distilled from the DT-008 work — are planned in +[[device-discovery-roadmap]]. + ## UHPPOTE discovery (historical example) The [[uhppote-controller]] supported discovery natively: a **UDP broadcast** (`get-devices` on diff --git a/wiki/decisions/device-discovery-roadmap.md b/wiki/decisions/device-discovery-roadmap.md new file mode 100644 index 0000000..994c223 --- /dev/null +++ b/wiki/decisions/device-discovery-roadmap.md @@ -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//PROTOCOL.md` + (frame, ports, commands, field tables, *verification status per command*). +2. **TypeScript module + fake-device tests** (`drivers/-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`, + `false`) — 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 `true…` + 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]] diff --git a/wiki/decisions/open-questions.md b/wiki/decisions/open-questions.md index b999087..49afecb 100644 --- a/wiki/decisions/open-questions.md +++ b/wiki/decisions/open-questions.md @@ -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. diff --git a/wiki/index.md b/wiki/index.md index dd4e4e3..42bc3cb 100644 --- a/wiki/index.md +++ b/wiki/index.md @@ -71,7 +71,7 @@ Counts: 4 sources · 19 entities · 47 concepts · 8 decision records. - [[first-run-setup]] — admin adds controllers + binds readers/cameras to relays from the catalog at install. - [[site-device-installation]] — FIELD RUNBOOK (2026-09-09): per device — factory address + credentials, the tool needed, what the wizard configures itself vs what is done by hand on the device, known traps; address plan, order of work on site, gaps to fill. Dingtian relay, DT-008 readers, Hikvision camera, radar, K200L / Rongta / Cashino printers. - [[device-input-flow]] — button → device push → backend decides → relay; backend is source of truth. -- [[device-discovery]] — optional driver capability to scan the LAN (no current driver uses it; UHPPOTE was the example). +- [[device-discovery]] — optional driver capability to scan the LAN; implemented by the DT-008 reader (2026-10-08), UHPPOTE was the historical example. - [[barrier-not-a-door]] — never timed-close a barrier; safety lives in barrier firmware. - [[printer-roles-failover]] — ≥2 printers by role; entry ticket falls back outside→booth. - [[printer-status-monitoring]] — live poll of paper/cover/cutter/offline via the device's status page; SSE to the booth UI. @@ -139,6 +139,7 @@ Counts: 4 sources · 19 entities · 47 concepts · 8 decision records. - [[session-model]] — business layer start: session = projection; transient-first; pay-on-foot. New event types. - [[vision-service]] — build a host-side ANPR + vehicle-verification service; replaces edge-LPR; scoped AGPL exception. - [[bodytype-classifier-training]] — phase B (SUV vs sedan): `apps/trainer` trains on the collector host (time split, floor, features/finetune modes, feature cache) → report → publish to the Gitea generic package → `models/bodytype.version` pin bakes it into the vision image → TAG bump; sidecar = the preprocessing contract; CPU-only torch on the Xeon E3-1225 v5, Quadro FX 3800 unusable, cloud GPU rejected. Built 2026-09-07; first run waits for labels. +- [[device-discovery-roadmap]] — memo (open): how each known device class gets a wizard Scan — SADP + ONVIF for cameras (verified on the lab VLAN), 9100 sweep + fingerprint for printers, Dingtian relay multicast search, Dahua 37810; the reusable method and rules from the DT-008 work. - [[vision-service-packaging]] — the vision service lives in this monorepo (apps/vision/), separate process, wired into Turbo via a package.json shim; uv-managed Python. - [[event-streams-split]] — split the signed business ledger (ledger_events) from unsigned device telemetry (device_events). - [[desktop-shell-tauri]] — ✅ Tauri v2 chosen over Electron for the desktop kiosk shell; thin wrapper, server keeps all logic. Best case Ubuntu 26.04 LTS (resolves WebKitGTK); worst case Windows+WSL → kiosk browser, no native shell. Auto-updater mirrors signed releases to public `mca/public_releases` (source repo is private — field appliances have no Gitea creds). diff --git a/wiki/log.md b/wiki/log.md index dff52e8..95473e0 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -3415,3 +3415,21 @@ target 8080→8081→8080, struct byte-identical), 17 adapter + 15 protocol test needs a new image (push → CI) and a stack bump; park-2's readers still await the one-line fix. Pages: [[device-discovery]], [[first-run-setup]], [[dingtian-dt008-reader]], [[site-device-installation]] §2, [[dingtian-qr-linux-tool]]. + +## [2026-10-08] query | park-2 readers switched to HTTP from the wizard + +park-2 deployed `stage-b7efa08`; the operator opened each reader in Setup and saved. Server log: +`10.0.10.7: output type WG26 → HTTP` (13:34:00Z) and the same for `.8` fifteen seconds later; a +read-back from the booth confirms both in HTTP mode at `10.0.10.101:3000`; Test shows no issues. +First real scan after the change still to be observed. Pages: [[site-device-installation]] §2. + +## [2026-10-08] query | Memo: discovery mechanisms for relays, printers, cameras + +Asked for by the operator. Probed the lab VLAN from 10.0.10.203 first: SADP multicast → 9 +Hikvision devices (model, serial, MAC, ports; the DVR adds Encrypt/Salt); ONVIF WS-Discovery → 4 +of them (XAddrs + hardware scopes); the bench Dahua answered neither (ONVIF setting to check) and +a guessed 37810 frame got nothing; a parallel TCP-9100 sweep found two office printers in ~1 s +(neither Rongta nor K200L → fingerprint step mandatory); no relay present for the `05 AA` +search. Memo filed as [[device-discovery-roadmap]] (method, per-device table, rules, order: +cameras → printers → relay → Dahua → DT-008 set-IP); open question #19; [[device-discovery]] and +[[index]] updated.