diff --git a/packages/devices/src/drivers/camera.test.ts b/packages/devices/src/drivers/camera.test.ts index 53f9623..2f544f2 100644 --- a/packages/devices/src/drivers/camera.test.ts +++ b/packages/devices/src/drivers/camera.test.ts @@ -200,12 +200,97 @@ describe("hikvision syncClock — the 1970 power-cut recovery (ISAPI /System/tim await expect(cam().syncClock(HOST_NOW, 60)).rejects.toThrow("clock set failed: HTTP 403"); }); - it("the dahua driver does NOT claim the capability (no ISAPI time endpoint)", async () => { + it("both camera drivers claim the capability (Dahua via global.cgi since 2026-09-17)", async () => { const { dahuaDriver, hikvisionDriver } = await import("./camera.js"); const { isClockSyncable } = await import("../interfaces.js"); const mk = (d: typeof dahuaDriver) => d.create({ host: "10.0.10.12", port: 80, username: "admin", password: "x", channel: 1 }); - expect(isClockSyncable(mk(dahuaDriver))).toBe(false); + expect(isClockSyncable(mk(dahuaDriver))).toBe(true); expect(isClockSyncable(mk(hikvisionDriver))).toBe(true); }); }); + +// Dahua — verified against an IPC-HFW2549T-AS-IL (fw 2.880) on 2026-09-17. The CGI +// numbers snapshot channels from 1 (channel=0 → HTTP 400), ignores any stream +// selector, and speaks NAIVE local wall time on global.cgi. See camera.ts and +// wiki/entities/dahua-ipc-hfw2549t.md. +describe("dahua snapshot URL — channel is 1-BASED, no stream selector", () => { + async function pathFor(config: Record): Promise { + const { dahuaDriver } = await import("./camera.js"); + digestGet.mockReset(); + digestGet.mockResolvedValue(reply(200)); + dahuaDriver.create(config as never).captureSnapshot({ direction: "entry" }); + return String((digestGet.mock.calls[0]![0] as { path: string }).path); + } + + it("channel 1 as entered → channel=1 (the old `ch - 1` sent 0 → HTTP 400 on hardware)", async () => { + expect(await pathFor({ host: "1.2.3.4", channel: 1 })).toBe("/cgi-bin/snapshot.cgi?channel=1"); + }); + + it("defaults to channel 1 when none is configured", async () => { + expect(await pathFor({ host: "1.2.3.4" })).toBe("/cgi-bin/snapshot.cgi?channel=1"); + }); + + it("channel 2 passes through; a stream setting is ignored", async () => { + expect(await pathFor({ host: "1.2.3.4", channel: 2, stream: 2 })).toBe("/cgi-bin/snapshot.cgi?channel=2"); + }); + + it("a zero/negative channel is clamped to 1 rather than sent as-is", async () => { + expect(await pathFor({ host: "1.2.3.4", channel: 0 })).toBe("/cgi-bin/snapshot.cgi?channel=1"); + }); +}); + +describe("dahua syncClock — global.cgi getCurrentTime/setCurrentTime, naive wall time", () => { + const HOST_NOW = "2026-09-17T10:35:49+02:00"; + const timeReply = (naive: string) => reply(200, `result=${naive}\r\n`); + + async function cam() { + const { dahuaDriver } = await import("./camera.js"); + return dahuaDriver.create({ host: "10.0.10.11", port: 80, username: "admin", password: "x", channel: 1 }) as unknown as { + syncClock(localIso: string, maxDriftSec: number): Promise<{ driftSeconds: number | null; synced: boolean }>; + }; + } + + it("in-sync camera: reads, does NOT set", async () => { + digestRequest.mockResolvedValueOnce(timeReply("2026-09-17 10:35:40")); + const r = await (await cam()).syncClock(HOST_NOW, 60); + expect(r).toEqual({ driftSeconds: 9, synced: false }); + expect(digestRequest).toHaveBeenCalledTimes(1); + const get = digestRequest.mock.calls[0]![0] as { method: string; path: string }; + expect(get.method).toBe("GET"); + expect(get.path).toBe("/cgi-bin/global.cgi?action=getCurrentTime"); + }); + + it("an hour behind (the bench unit: DST off, NTP off) → sets the HOST wall time, no offset", async () => { + digestRequest + .mockResolvedValueOnce(timeReply("2026-09-17 09:35:51")) + .mockResolvedValueOnce(reply(200, "OK\r\n")); + const r = await (await cam()).syncClock(HOST_NOW, 60); + expect(r).toEqual({ driftSeconds: 3598, synced: true }); + const set = digestRequest.mock.calls[1]![0] as { method: string; path: string }; + expect(set.method).toBe("GET"); + expect(set.path).toBe("/cgi-bin/global.cgi?action=setCurrentTime&time=2026-09-17%2010%3A35%3A49"); + }); + + it("unparseable camera reply = infinite drift → syncs", async () => { + digestRequest + .mockResolvedValueOnce(reply(200, "Error\r\nBad Request!")) + .mockResolvedValueOnce(reply(200, "OK")); + const r = await (await cam()).syncClock(HOST_NOW, 60); + expect(r).toEqual({ driftSeconds: null, synced: true }); + }); + + it("a 200 whose body is not OK is still a failed set (Dahua's 'Error' convention)", async () => { + digestRequest + .mockResolvedValueOnce(timeReply("1970-01-01 01:00:00")) + .mockResolvedValueOnce(reply(200, "Error\r\nInvalid Argument!")); + await expect((await cam()).syncClock(HOST_NOW, 60)).rejects.toThrow("clock set failed: HTTP 200 Error"); + }); + + it("a non-200 set surfaces as an error", async () => { + digestRequest + .mockResolvedValueOnce(timeReply("1970-01-01 01:00:00")) + .mockResolvedValueOnce(reply(401, "denied")); + await expect((await cam()).syncClock(HOST_NOW, 60)).rejects.toThrow("clock set failed: HTTP 401"); + }); +}); diff --git a/packages/devices/src/drivers/camera.ts b/packages/devices/src/drivers/camera.ts index 12521b6..e7affa2 100644 --- a/packages/devices/src/drivers/camera.ts +++ b/packages/devices/src/drivers/camera.ts @@ -18,8 +18,12 @@ import { digestGet, digestRequest } from "./http-digest.js"; // Camera drivers — entry/exit snapshot-on-event. The host pulls a still over // HTTP when an event fires; the bytes are stored and referenced from the signed // event as an independent fraud-control record (the camera PULLS, it never pushes -// to us). Hikvision (ISAPI) and Dahua (CGI) differ only in the snapshot URL and -// channel encoding. Both use HTTP Digest auth (see ./http-digest.ts). +// to us). Hikvision (ISAPI) and Dahua (CGI) differ in the snapshot URL, the +// channel encoding and the clock endpoint. Both use HTTP Digest auth (see ./http-digest.ts). +// +// VERIFIED on hardware (2026-09-17): a Dahua IPC-HFW2549T-AS-IL (fw 2.880) at +// 10.0.10.11 returns a 2880×1620 JPEG from /cgi-bin/snapshot.cgi?channel=1 — +// and HTTP 400 for channel=0. See wiki/entities/dahua-ipc-hfw2549t.md. // // VERIFIED on hardware (2026-06-15): a Hikvision unit at 10.0.10.121 returns a // 2688×1520 JPEG from /ISAPI/Streaming/channels/101/picture with Digest auth. @@ -162,8 +166,8 @@ class HttpCamera implements CameraDevice { }); } - /** Digest request against an arbitrary device path (ISAPI config reads/writes). */ - protected isapi(method: "GET" | "PUT", path: string, body?: string) { + /** Digest request against an arbitrary device path (ISAPI / CGI config reads+writes). */ + protected deviceRequest(method: "GET" | "PUT", path: string, body?: string) { return digestRequest({ host: this.#host, port: this.#port, @@ -197,7 +201,7 @@ class HikvisionCamera extends HttpCamera { * explicit offset makes the instant unambiguous regardless of that config. */ async syncClock(localIso: string, maxDriftSec: number): Promise { - const read = await this.isapi("GET", "/ISAPI/System/time"); + const read = await this.deviceRequest("GET", "/ISAPI/System/time"); if (read.status !== 200) { throw new Error(`clock read failed: HTTP ${read.status}`); } @@ -221,7 +225,7 @@ class HikvisionCamera extends HttpCamera { ``; - const put = await this.isapi("PUT", "/ISAPI/System/time", body); + const put = await this.deviceRequest("PUT", "/ISAPI/System/time", body); if (put.status !== 200) { throw new Error(`clock set failed: HTTP ${put.status}`); } @@ -230,6 +234,67 @@ class HikvisionCamera extends HttpCamera { } } +// --- Dahua clock sync (CGI global.cgi getCurrentTime / setCurrentTime) -------------- +// Same problem, different surface. The Dahua CGI reads and writes the clock as a +// NAIVE local wall-time string ("2026-09-17 10:35:49", no offset) in whatever time +// zone / DST the camera is configured for. We deliberately write the HOST's local +// wall time verbatim: what must match the booth is the OSD timestamp burned into +// every snapshot and the event times, i.e. the wall clock — not the camera's idea +// of UTC. (The bench unit ran a year-round UTC+1 with DST off and NTP off; after +// this sync its OSD read the booth's time.) VERIFIED on hardware 2026-09-17: +// setCurrentTime answers 200 "OK" and getCurrentTime reads the new value back. +// See wiki/entities/dahua-ipc-hfw2549t.md. + +const DAHUA_TIME_PATH = "/cgi-bin/global.cgi?action=getCurrentTime"; + +/** "2026-09-17T10:35:49+02:00" (host localIso, WITH offset) → "2026-09-17 10:35:49" + * (the naive wall time the Dahua CGI speaks). */ +function naiveWallTime(localIso: string): string { + const m = localIso.match(/^(\d{4}-\d{2}-\d{2})[T ](\d{2}:\d{2}:\d{2})/); + if (!m) throw new Error(`syncClock: unparseable host time ${localIso}`); + return `${m[1]} ${m[2]}`; +} + +/** Parse a naive "YYYY-MM-DD HH:MM:SS" as an instant in the HOST's zone — both sides + * of the drift comparison go through this, so the zone cancels out. */ +function naiveMs(naive: string): number { + return Date.parse(naive.replace(" ", "T")); +} + +class DahuaCamera extends HttpCamera { + async syncClock(localIso: string, maxDriftSec: number): Promise { + const read = await this.deviceRequest("GET", DAHUA_TIME_PATH); + if (read.status !== 200) { + throw new Error(`clock read failed: HTTP ${read.status}`); + } + // Reply body: "result=2026-09-17 09:35:51" + const cameraNaive = + read.body.toString("utf8").match(/result=(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/)?.[1] ?? null; + const hostNaive = naiveWallTime(localIso); + + const cameraMs = cameraNaive ? naiveMs(cameraNaive) : NaN; + const driftSeconds = Number.isFinite(cameraMs) + ? Math.round(Math.abs(naiveMs(hostNaive) - cameraMs) / 1000) + : null; + if (driftSeconds != null && driftSeconds <= maxDriftSec) { + return { driftSeconds, synced: false }; + } + + const set = await this.deviceRequest( + "GET", + `/cgi-bin/global.cgi?action=setCurrentTime&time=${encodeURIComponent(hostNaive)}`, + ); + // Dahua answers 200 with a body of "OK"; a refused write is a non-200 or "Error". + if (set.status !== 200 || !/^OK/.test(set.body.toString("utf8").trim())) { + throw new Error( + `clock set failed: HTTP ${set.status} ${set.body.toString("utf8").trim().slice(0, 40)}`, + ); + } + stubLog(this.driverId, `clock synced (was ${driftSeconds ?? "unparseable"}s off)`); + return { driftSeconds, synced: true }; + } +} + const channelField: ConfigField = { key: "channel", label: "Channel", @@ -329,15 +394,17 @@ export const dahuaDriver: CameraDriver = { id: "dahua", category: "camera", label: "Dahua camera", - description: "Dahua snapshot via CGI (HTTP Digest).", + description: "Dahua snapshot via CGI (HTTP Digest) + clock sync.", transports: ["tcp-ip"], configFields: cameraConfigFields, - // Dahua channels are 0-based on the CGI; the admin enters 1-based. No stream in the - // path (the second arg is ignored — Dahua has no main/sub snapshot distinction here). + // snapshot.cgi channels are 1-BASED, exactly as the admin enters them (only Dahua's + // configManager TABLES are 0-indexed — the earlier `ch - 1` here drew a permanent + // HTTP 400 on real hardware, 2026-09-17). No stream in the path: `subtype` is + // ignored by snapshot.cgi, the still always comes off the main stream. create: (c) => - new HttpCamera( + new DahuaCamera( "dahua", c, - (ch) => `/cgi-bin/snapshot.cgi?channel=${Math.max(0, ch - 1)}`, + (ch) => `/cgi-bin/snapshot.cgi?channel=${Math.max(1, ch)}`, ), }; diff --git a/wiki/concepts/site-device-installation.md b/wiki/concepts/site-device-installation.md index 5b82830..1543dd1 100644 --- a/wiki/concepts/site-device-installation.md +++ b/wiki/concepts/site-device-installation.md @@ -188,6 +188,18 @@ database → **factory reset**, then redo 1–3 (the Vehicle target filter defau Point the Alarm Server at a dumb HTTP sink on the laptop if you need to see the verbatim body ([[lpr-camera]] §"auto-enter but not auto-exit"). +**If the camera is a Dahua** (first unit inspected 2026-09-17, [[dahua-ipc-hfw2549t]]): factory +`192.168.1.108`, `admin` + a password set at first boot, web UI on port 80 (HTTPS off by default +on the bench unit). In the wizard: driver `dahua`, host, `admin` password, **channel 1 as printed** (the +driver sent `channel=0` → HTTP 400 until 2026-09-17; fixed). There is no HTTP Alarm Server to +point at the booth: events would be read by the server holding an `eventManager.cgi?action=attach` +stream (**not built yet** — a Dahua today gives snapshots + clock sync only, no lane busy/free +and no ANPR bridge), so no "assign first, then go back to the camera" step — but SMD must be set +to **Vehicle** on the camera. Set the time zone by hand; the app re-syncs the clock from the +booth like it does for Hikvision (the bench unit ran 1 h behind with DST off; NTP is useless on +the isolated VLAN). Five wrong logins lock `admin` for 5 minutes — check the password with one +`curl --digest` before assigning. + ## 4. Radar (vehicle presence at the entry barrier) A dry-contact sensor into a Dingtian input, nothing on the network. Check with the board's input diff --git a/wiki/entities/dahua-ipc-hfw2549t.md b/wiki/entities/dahua-ipc-hfw2549t.md new file mode 100644 index 0000000..1d15b3b --- /dev/null +++ b/wiki/entities/dahua-ipc-hfw2549t.md @@ -0,0 +1,143 @@ +--- +type: entity +tags: [parking, hardware, camera, dahua, snapshot, events, bench] +sources: [] +updated: 2026-09-17 +--- + +# Dahua IPC-HFW2549T-AS-IL — the lab bench unit (inspected 2026-09-17) + +A 5 MP Dahua WizSense bullet (`IPC-HFW2549T-AS-IL-0360B`, 3.6 mm, "IL" = smart dual illuminators), +firmware **`V2.880.0000000.22.R`, build 2026-05-14**, serial `9J0E4EFPAGECB23`, MAC +`fc:5f:49:48:42:ac`, processor SSC378Q. Sits on the bench at `10.0.10.11`, login `admin` / the lab +password. **It is not an ANPR camera** — plates come from the host-side [[opencv-anpr-service]] +off its snapshot, exactly as with the Hikvision units. Everything below was read off the unit +over its CGI with `curl --digest`; nothing was written to it. + +**It is not factory-fresh.** Hostname `DAHUA_PORTA_KRYESORE` ("main gate"), an Alarm Server already +pointed at `10.7.8.9:8888`, DNS `8.8.8.8`, SMD tuned to vehicles only — this unit was configured +for a gate somewhere before it reached the bench. Treat its settings as inherited, not defaults. + +## What the CGI surface gives us + +| Need | Endpoint (all HTTP Digest, port 80; 443 is **off**) | Result on this unit | +| --- | --- | --- | +| identity | `magicBox.cgi?action=getSystemInfo` / `getSoftwareVersion` / `getSerialNo` / `getVendor` | model, firmware, serial, `vendor=Dahua` | +| snapshot | `snapshot.cgi?channel=1` | 200, `image/jpeg`, **2880×1620**, ~270 KB, ~0.5 s | +| snapshot channel `0` / `2` | same | **400** — the channel index is **1-based**; `subtype=1` is ignored (still 2880×1620) | +| clock read | `global.cgi?action=getCurrentTime` | `result=2026-09-17 09:03:50` | +| clock write | `global.cgi?action=setCurrentTime&time=YYYY-MM-DD%20HH:MM:SS` | 200 `OK`; read-back matches within 1 s (**verified**, now the Dahua clock-sync) | +| events | `eventManager.cgi?action=attach&codes=[All]&heartbeat=5` | 200, `multipart/x-mixed-replace`, a `Heartbeat` part every N s, event parts in between | +| event caps | `eventManager.cgi?action=getCaps` | snapshot/record/mail/alarm-out linkage; no HTTP push cap | +| streams | RTSP 554 `cam/realmonitor?channel=1&subtype=0` / `1` | **H.265** Main 2880×1620 @ 20 fps; sub 704×576 @ 20 fps (probed with ffprobe) | +| ports | 80 (HTTP), 554 (RTSP), 37777 (Dahua SDK/DHIP) open; 443, 37778, 5000, 8000 closed | | + +### Snapshot: the driver decremented the channel — this unit said no (fixed 2026-09-17) + +`dahuaDriver` (`packages/devices/src/drivers/camera.ts`) builds +`/cgi-bin/snapshot.cgi?channel=${ch-1}` on the note "Dahua channels are 0-based". On this firmware +`channel=0` → **HTTP 400**, `channel=1` → the JPEG. Dahua's HTTP API numbers `snapshot.cgi` and +`realmonitor` channels from 1 (only the `configManager` *tables* are 0-indexed — the usual source +of the confusion). So an admin who enters "channel 1" in the wizard gets a permanent **degraded +"HTTP 400"** from `healthCheck()` and no snapshot ever. The Dahua driver was never run against +hardware before today ([[lpr-camera]] §Verified only covers Hikvision). **Fixed the same day**: the +driver now sends the channel as entered (clamped to ≥1) and `camera.test.ts` pins the URL. The +fixed driver was then run against this unit: `healthCheck` → ready (≈256 KB), `captureSnapshot` → +`image/jpeg`, 273 KB, JPEG magic. + +The snapshot always comes off the **main** stream at full resolution — there is no per-stream +snapshot as on Hikvision, and `subtype` on `snapshot.cgi` is ignored. Fine for us: the app +re-encodes to 1280 px on capture ([[snapshot-storage-optimization]]) and the recognizer keeps the +full frame. + +### Events: Dahua PULLS-with-a-held-socket, it does not HTTP-POST + +Dahua has an "Alarm Server" too (`configManager.cgi?action=getConfig&name=AlarmServer`), but its +protocol is **`DAHUA`** (proprietary, port 8888) — not the Hikvision-style HTTP POST that +`routes/hikvision-alarm.ts` consumes. The HTTP way to get events is the **subscription stream**: +the host opens `eventManager.cgi?action=attach&codes=[SmartMotionVehicle,CrossLineDetection,…]&heartbeat=5` +and keeps it open; the camera writes one multipart part per event (`Code=…;action=Start|Stop;index=…`) +and a `Heartbeat` part every 5 s. Verified on the bench: the stream stays up, heartbeats arrive, +Digest auth applies to the attach. This inverts the Hikvision model: + +- the camera never needs to know the booth's address — no `pushesToBackend`, no "assign first, + then go back to the camera" step, no source-IP guard, and the WSL mirrored-mode source-IP + problem does not exist; +- the **server** owns the connection: reconnect with backoff, treat a missing heartbeat as + camera-offline, one long-lived socket per Dahua camera; +- vehicle events come from **SMD** (`SmartMotionDetect`: `Enable=true`, `ObjectTypes.Vehicle=true`, + `Human=false` on this unit — inherited, and exactly the "Detection Target = Vehicle" the Hikvision + runbook step asks for) → code `SmartMotionVehicle`; tripwire/intrusion (`CrossLineDetection`, + `CrossRegionDetection`) with `ObjectTypes=Vehicle` are the IVS equivalents, **none configured** + on this unit (only disabled FaceDetection and HeatMap rules exist). + +**Verbatim event parts captured** on a 25-minute `codes=[All]` listen (bench motion + the clock +write below). Each part is `Content-Type: text/plain` with a `Code=…;action=…;index=…;data={JSON}` +body: + +``` +Code=VideoMotion;action=Start;index=0;data={ + "EventID" : 31927, + "Id" : [ 0 ], + "RealUTC" : 1789634136, + "RegionName" : [ "Region1" ], + "SmartMotionEnable" : true, + "WithSnap" : true +} +Code=VideoMotion;action=Stop;index=0;data={ …same EventID… } +Code=VideoMotionInfo;action=State;index=0;data={ "RealUTC" : 1789634137, "WithSnap" : false } +Code=TimeChange;action=Pulse;index=0;data={ + "BeforeModifyTime" : "17-09-2026 09:35:51", + "ModifiedTime" : "17-09-2026 10:35:49", + "RealUTC" : 1789637749, + "WithSnap" : false +} +``` + +- `action=Start` / `Stop` with a shared `EventID` is the busy/free edge (the Hikvision + `active`/`inactive` equivalent); `VideoMotionInfo State` is a per-second chatter part to ignore. +- The motion arrived as plain `VideoMotion` with `SmartMotionEnable: true`, **not** as + `SmartMotionVehicle` — whether the SMD filter suppresses `VideoMotion` for non-vehicles, or only + adds the `SmartMotion*` codes on top, is **unconfirmed** (nobody drove a car past the bench). + Subscribe to both and log which fires before gating anything on it. +- **`RealUTC` is the camera's *belief* of UTC, i.e. its wall time minus its configured offset.** + After the clock write it read 09:35:49 for a real 08:35:49 UTC (UTC+1, DST off). Never use it + as an absolute time — stamp events on receipt from the booth clock, as the Hikvision route does. +- `TimeChange` is emitted for our own clock sync; harmless, but filter it from any "activity" view. + +### Clock: one hour behind, NTP off — clock-sync built the same day + +`getCurrentTime` returned 09:03 while the bench wall clock read 10:03 CEST: `NTP.Enable=false` +(address `time.windows.com`, unreachable on an isolated VLAN anyway), `NTP.TimeZone=1` (Belgrade) +and **`Locales.DSTEnable=false`**, so the unit runs at UTC+1 year-round. The Hikvision units get +their clock from the booth at every offline→ready edge ([[clock-integrity]]); until today the +Dahua driver did not claim `isClockSyncable`. Now `DahuaCamera.syncClock` (camera.ts) reads +`global.cgi?action=getCurrentTime` (`result=YYYY-MM-DD HH:MM:SS`) and, past the drift limit, writes +`setCurrentTime&time=` — the **host's naive local wall time, no offset**, because +what has to match the booth is the OSD burned into every snapshot, not the camera's notion of UTC +(its tz/DST config is left alone, as on Hikvision). Verified on the bench with the real driver: +a 2 h-off host time set (drift 7200 → synced), set back, then read as 1 s drift → no write. The +device monitor picks it up unchanged (it gates on `isClockSyncable`, not on the driver id). A wrong +DST setting on the camera therefore no longer matters for the evidence trail — only `RealUTC` in +event bodies stays skewed (above). + +### Login lockout — the device monitor must never poll with a wrong password + +`General.LockLoginEnable=true`, `LockLoginTimes=5`, `LoginFailLockTime=300`: five bad Digest +logins lock `admin` out for 5 minutes. A wizard assignment with a mistyped password, polled every +few seconds by the device monitor, locks the camera and then **every** login (including the +browser) fails until the poll stops. Verify the password with one `curl` before assigning; on a +mysterious "401 then nothing works" wait five minutes. + +## Bench notes + +- `10.0.10.11` is the runbook's address for the lab [[k200l-printer]] ([[site-device-installation]] + §address plan) — the camera has taken it on the bench; keep the two off the wire together or + move one. +- The other HTTP APIs newer Dahua firmware carries (`RPC2` JSON, `/onvif/device_service`) were not + exercised — the CGI above covers everything the app needs. +- `devVideoInput.cgi?action=getCaps` and `magicBox.cgi?action=getProductDefinition` answer + "Bad Request" / "Not Implemented" on this firmware. + +Related: [[lpr-camera]] · [[opencv-anpr-service]] · [[lane-presence-and-anpr-entry]] · +[[clock-integrity]] · [[site-device-installation]] · [[device-registry]] diff --git a/wiki/entities/lpr-camera.md b/wiki/entities/lpr-camera.md index 1e962fe..aa25c4a 100644 --- a/wiki/entities/lpr-camera.md +++ b/wiki/entities/lpr-camera.md @@ -2,7 +2,7 @@ type: entity tags: [parking, hardware, readers, offline-first] sources: [parking-system-architecture, DS-2CD1047G3H-LIU] -updated: 2026-08-23 +updated: 2026-09-17 --- # LPR Camera @@ -38,8 +38,12 @@ the "Backend push IP" field for it (gated on the driver's `pushesToBackend` flag - **Hikvision** uses **ISAPI**: `GET /ISAPI/Streaming/channels//picture` (`101` = ch1 main stream) with **HTTP Digest** auth. The "Enable Hikvision-CGI" toggle (Network → Advanced → Integration Protocol) is a *different* legacy CGI surface — **not** needed for ISAPI. -- **Dahua** uses CGI: `GET /cgi-bin/snapshot.cgi?channel=` (0-based channel; the wizard's - 1-based channel is decremented). +- **Dahua** uses CGI: `GET /cgi-bin/snapshot.cgi?channel=`, channel **as entered (1-based)**. + Until 2026-09-17 the driver decremented it on the belief the CGI is 0-based — the bench + IPC-HFW2549T (fw 2.880) answers `channel=0` with **400** and `channel=1` with the JPEG; fixed and + verified with the real driver the same day. Clock sync exists for Dahua too (`global.cgi`, + naive wall time). Full inspection: [[dahua-ipc-hfw2549t]] (events = held `eventManager attach` + socket, not an HTTP push — the subscriber is not built yet). **Driver / storage boundary:** the driver FETCHES the image bytes (client-side HTTP Digest in `drivers/http-digest.ts`) and returns them on `Snapshot.bytes`; **storage is the caller's job** diff --git a/wiki/index.md b/wiki/index.md index 5d10784..594de46 100644 --- a/wiki/index.md +++ b/wiki/index.md @@ -45,6 +45,7 @@ Counts: 4 sources · 19 entities · 47 concepts · 8 decision records. - [[dingtian-dt008-reader]] — Dingtian DT-008 QR/RFID reader on hand; HTTP-GET push, server replies the verdict; ⚠️ our two units read disjoint card sets (125 kHz vs 13.56 MHz) — unresolved, see open question #18. - [[zkteco-controller]] — ❌ rejected/historical; aux-input path was a contender, not pursued. - [[dingtian-relay]] — ✅ CHOSEN access controller; decoupled inputs solve the button blocker (driver verified on hardware); spare relays drive aux outputs (`setAux`). +- [[dahua-ipc-hfw2549t]] — first Dahua on the bench (IPC-HFW2549T-AS-IL, fw 2.880, 2026-09-17): the driver's channel decrement gave HTTP 400 (channels are 1-based — fixed + verified live); Dahua clock-sync built (`global.cgi`, naive wall time); events = held `eventManager attach` multipart stream, verbatim `VideoMotion Start/Stop` + `TimeChange` parts captured, subscriber not built; `RealUTC` is the camera's belief of UTC; 5-strike login lockout. - [[hikvision-radar]] — vehicle-presence radar on a Dingtian input; the entry presence gate (per-input active-level caveat). - [[rongta-printer]] — ✅ CHOSEN 80mm thermal printer; ESC/POS over raw TCP 9100 (or local USB, see [[printer-usb-transport]]); driver written, one unit reachable at 10.0.10.6. - [[k200l-printer]] — the park-buzi printer identified (2026-09-09): Xprinter/ICS K200L, USB id 1fc9:2016 "POS-80", J-Speed LAN board at 192.168.123.100 (DHCP off, web config on :80); status page `/prt_status.htm` (Rongta's rows, headerless HTTP) → own `k200l` driver with raw-socket fetch; over USB reachability only, so cover-open never showed at park-buzi. diff --git a/wiki/log.md b/wiki/log.md index f87daa9..56790de 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -3351,3 +3351,23 @@ Pages: [[dingtian-dt008-reader]], [[site-device-installation]] §2, [[open-quest Stdlib Python HTTP server answering the reader's GET with the SDK verdict + `Connection: close`, one log line per read (serial, dir, channel, cardid). Page: [[dingtian-dt008-reader]] §Bench sink. + +## 2026-09-17 — first Dahua on the bench: IPC-HFW2549T-AS-IL inspected over CGI + +Snapshot, identity, config, RTSP and the `eventManager attach` stream all answered. Two things the +app got wrong by assumption: the Dahua driver's channel decrement (`channel=0` → HTTP 400 on this +firmware; channels are 1-based), and "Dahua would push like Hikvision" — it holds a multipart +subscription socket instead. Clock 1 h off (DST off, NTP off); `global.cgi setCurrentTime` is the +unbuilt clock-sync. Unit is not factory-fresh (hostname "main gate", SMD = vehicle). Pages: +[[dahua-ipc-hfw2549t]], [[lpr-camera]] §Snapshot driver, [[site-device-installation]] §3, [[index]]. + +## 2026-09-17 — Dahua driver: channel fix + clock sync, verified on the bench unit + +`dahuaDriver` now sends the channel as entered (`camera.test.ts` pins the URL) and `DahuaCamera` +implements `syncClock` over `global.cgi` get/setCurrentTime with the host's naive wall time. Both +run against the real IPC-HFW2549T: snapshot 273 KB, a 2 h-off sync set and read back. A 25-min +`eventManager attach` listen captured the verbatim `VideoMotion Start/Stop`, `VideoMotionInfo` and +`TimeChange` parts; `RealUTC` proved to be the camera's belief of UTC (1 h skewed), so events get +stamped on receipt. Still open: the server-side attach subscriber, and whether SMD emits +`SmartMotionVehicle` in addition to / instead of `VideoMotion`. Pages: [[dahua-ipc-hfw2549t]], +[[lpr-camera]], [[site-device-installation]] §3, [[index]].