Files
parking_solution/wiki/entities/dahua-ipc-hfw2549t.md
T
julian 4593a397dd
Build & push images / images (push) Successful in 3m25s
fix(devices): Dahua snapshot channel is 1-based; add Dahua clock sync; wiki page for the bench IPC-HFW2549T
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.
2026-10-08 08:03:50 +02:00

144 lines
9.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
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]]