fix(devices): Dahua snapshot channel is 1-based; add Dahua clock sync; wiki page for the bench IPC-HFW2549T
Build & push images / images (push) Successful in 3m25s

The dahua driver decremented the wizard's channel on the belief the CGI is
0-based. On real hardware (IPC-HFW2549T-AS-IL, fw V2.880, 2026-09-17)
snapshot.cgi?channel=0 answers HTTP 400 and channel=1 returns the 2880x1620
JPEG — so every Dahua assignment sat at degraded "HTTP 400". The channel is
now sent as entered (clamped >= 1) and the URL is pinned in camera.test.ts.

DahuaCamera.syncClock reads global.cgi getCurrentTime and, past the drift
limit, writes setCurrentTime with the host's naive local wall time (no offset):
the OSD burned into snapshots must match the booth clock; the camera's tz/DST
config is left alone. Verified live: a 2h-off set, set back, 1s drift -> no
write. The device monitor picks it up via isClockSyncable unchanged.

Wiki: new entities/dahua-ipc-hfw2549t.md (endpoint table, verbatim
eventManager attach parts — VideoMotion Start/Stop, VideoMotionInfo,
TimeChange — RealUTC is the camera's belief of UTC, 5-strike login lockout,
unit not factory-fresh); lpr-camera Dahua bullet corrected; runbook §3 Dahua
paragraph; index + log. The server-side attach-stream subscriber is not built.
This commit is contained in:
2026-10-08 08:03:50 +02:00
parent 4d1d245680
commit 4593a397dd
7 changed files with 348 additions and 16 deletions
+12
View File
@@ -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
+143
View File
@@ -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=<host wall 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]]
+7 -3
View File
@@ -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/<id>/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=<n>` (0-based channel; the wizard's
1-based channel is decremented).
- **Dahua** uses CGI: `GET /cgi-bin/snapshot.cgi?channel=<n>`, 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**
+1
View File
@@ -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.
+20
View File
@@ -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]].