b7efa081ec
Build & push images / images (push) Successful in 3m7s
The Dingtian DT-008's Windows-only config tool speaks a small binary UDP protocol (reader :24680 unicast get/set, :24582 broadcast search/set-network), reversed in wiki/raw/dingtian_qr_linux (PROTOCOL.md + dingtian_qr.py, copied to scripts/). Reading park-2's readers with it from the booth found both in WG26 output mode — the "beeps but captures nothing" enrolment failure: they never pushed HTTP at all. The app now speaks the protocol itself (packages/devices dingtian-qr-config.ts, Node dgram, host-network container) and the dingtian-qr-reader driver uses it: - discover(): first driver to implement the wizard's Scan capability; rows show serial, IP, output mode, current server target, card format, firmware. - preconditions: output type must be HTTP (fixable — save switches it); typed serial must equal the reported one and the reader must answer on UDP (both block the save). - configureInputPush(): set-network the reader's server to this booth's IP + listen port, confirmed by polling (the reader applies it without an ack and is silent for seconds). - usesPushAuth=false: the scan GET carries no credentials, so no push secret is stored. - a reader saved without an IP warns instead of failing (legacy vendor-tool setup). Verified on the bench unit: WG26→HTTP, target 8080→8081→8080, struct byte-identical after. 15 protocol tests against a fake reader + 17 adapter tests. Wiki: device-discovery, first-run-setup, dingtian-dt008-reader, site-device-installation §2 (SSH procedure; the "needs a Windows laptop" claim withdrawn), new source page dingtian-qr-linux-tool.
86 lines
4.8 KiB
Markdown
86 lines
4.8 KiB
Markdown
---
|
|
type: concept
|
|
tags: [parking, architecture, devices, setup]
|
|
sources: [parking-system-architecture]
|
|
updated: 2026-10-08
|
|
---
|
|
|
|
# Device Discovery
|
|
|
|
An optional driver capability: **find devices on the LAN** so the admin doesn't have to type
|
|
connection details by hand during [[first-run-setup]]. Modeled generically so any driver can
|
|
opt in.
|
|
|
|
> Implementation-derived (from `@parking/devices` + setup API/UI), not the source doc.
|
|
|
|
## The capability
|
|
|
|
A driver may implement `DiscoverableDriver` — `discover() => DiscoveredDevice[]`. Each found
|
|
device carries an `id`, a `label`, a `config` blob to **auto-fill** the setup form, and `info`
|
|
(firmware, MAC, …). The [[device-registry]]'s `isDiscoverable()` guard lets the system treat it
|
|
as optional; the setup catalog returns a `discoverable` list of driver ids.
|
|
|
|
> **Implemented by one driver (2026-10-08): the [[dingtian-dt008-reader|Dingtian DT-008 QR/RFID
|
|
> reader]]** (`dingtian-qr-reader`), via the vendor tool's UDP protocol reversed in
|
|
> [[dingtian-qr-linux-tool]] (`packages/devices/src/drivers/dingtian-qr-config.ts`). The
|
|
> [[dingtian-relay]] board still uses a fixed IP. The UHPPOTE example below is historical, kept
|
|
> because the **broadcast gotchas are transferable** — the DT-008 driver applies all of them.
|
|
|
|
## DT-008 reader discovery (current)
|
|
|
|
`discover()` sends the search command (2) to the **subnet-directed broadcast of every local
|
|
IPv4 interface** on UDP 24582 and collects the DeviceInfo replies (3) for 2 s, deduped by serial;
|
|
then, per reader, a unicast params read (30) so the wizard row shows what matters **before**
|
|
assigning: `output` mode (HTTP vs WG26/RS232/…), current `server:port` target, push `url`
|
|
extension, `cardFormat`, `firmware`. "Use" fills `serial` + `host`. Verified on the bench unit
|
|
(HC002721 @ 10.0.10.12) and, read-only, on park-2's two readers. Needs an L2 segment shared
|
|
with the readers: works from the booth (host-network server) and the device VLAN; **not** from a
|
|
bridged dev container (`docker-compose.dev.yml`) nor across Netbird — there, use
|
|
`scripts/dingtian_qr.py get <ip>` on the booth instead.
|
|
|
|
## UHPPOTE discovery (historical example)
|
|
|
|
The [[uhppote-controller]] supported discovery natively: a **UDP broadcast** (`get-devices` on
|
|
port `60000`) that **every controller on the LAN answers** with its serial, IP, netmask, gateway,
|
|
MAC, firmware version, and date. The `uhppoted` lib exposed this as `getDevices(ctx)`; the
|
|
(now-removed) `uhppote` driver mapped each result into a `DiscoveredDevice` (serial → id, IP →
|
|
host). **Was verified on real hardware** (serial 225088491).
|
|
|
|
### Broadcast gotchas (learned the hard way — see [[wsl-dev-networking]])
|
|
|
|
These cost real debugging time; the (removed) `uhppote` driver handled all three, and any future
|
|
UDP-discovery driver will need to as well:
|
|
|
|
1. **Broadcast to the *subnet-directed* address, not the global `255.255.255.255`.** The
|
|
`uhppoted` lib only calls `setBroadcast(true)` when the target matches a **local interface's
|
|
subnet broadcast** (e.g. `10.0.10.255`). For the global address it skips it, so the `send`
|
|
fails with **`EACCES`**. The driver computes the subnet broadcast from `os.networkInterfaces()`.
|
|
2. **A host with multiple interfaces must broadcast on *all* subnets.** With several NICs (LAN,
|
|
VPN/Tailscale, docker bridges) the controller is on only one. Picking the first interface
|
|
misses it; the driver broadcasts on every subnet and dedupes by serial.
|
|
3. **For *unicast* ops (status / open), the lib's `Config` broadcast must match the target's
|
|
subnet** — it governs reply routing, so a mismatched broadcast makes `getStatus` time out even
|
|
though `openDoor` "succeeds". The driver sets the broadcast per the target host's subnet. (This
|
|
was the health-check "offline/timeout" bug: a 5 s timeout dropped to 24 ms once fixed.)
|
|
|
|
Also: concurrent `uhppoted` calls collide on the `:60001` reply-listener port (EACCES / dropped
|
|
replies), so the driver **serializes** all controller I/O. Override the broadcast with
|
|
`UHPPOTE_BROADCAST` for unusual setups.
|
|
|
|
## Flow
|
|
|
|
1. The setup catalog flags `uhppote` as discoverable.
|
|
2. Admin clicks **Scan** → `GET /api/setup/discover/:driverId` (admin-only).
|
|
3. The server runs `discover()` and **health-checks each found device** so the admin sees
|
|
reachability before assigning.
|
|
4. Selecting a result **auto-fills serial + host**; the admin then assigns + binds it.
|
|
|
|
## Deployment notes
|
|
|
|
- Discovery is an **L2 broadcast**: the host and controller must share a layer-2 segment. Works
|
|
on the isolated device VLAN ([[network-isolation]]). A routed/NAT'd network (e.g. WSL2 NAT mode
|
|
— see [[wsl-dev-networking]]) blocks it entirely.
|
|
- Discovery shares the same unauthenticated UDP exposure as everything else UHPPOTE — another
|
|
reason the controllers live on an isolated VLAN ([[uhppote-udp-protocol]]).
|
|
- Cameras (Hikvision/Dahua via ONVIF/WS-Discovery) could implement the same interface later.
|