Files
parking_solution/wiki/concepts/site-device-installation.md
T
julian c08e232339 feat(firmware): relay-proxy PoC — NodeMCU as a Dingtian DT-R004 + cloud proxy/watchdog
A NodeMCU v3 (ESP8266) that speaks the Dingtian wire contract (binary UDP 60000 with
relay_pw, string UDP 60001, config CGI incl. the setconfig gotcha, userset.cgi, Digest
input push) so the booth's existing driver needs no change, plus a heartbeat/command/
watchdog path to an ephemeral cloud stand-in (poc/cloud-standin.mjs). Verified at park-lab:
the booth's assign flow configured it like real hardware and a button press reached the
booth (401→Digest→200) and the cloud with the booth's status. Watchdog probes /health and
power-cycles the PC via a spare relay with backoff. IO behind one interface for the ESP32/
Dingtian port.

wiki: relay-proxy-firmware page; esp32-flashability-test runbook (esptool lock test);
dingtian-relay "can we flash our own firmware" (vendor locks the standard SKU);
site-device-installation: booth ufw must allow device-net → 3000 (push targets PORT, not
Caddy's 80); open-questions: cloud takeover vs signed ledger (parked).

.gitignore: firmware venv/.pio/secrets.h.
2026-10-22 12:08:20 +02:00

24 KiB
Raw Blame History

type, tags, sources, updated
type tags sources updated
reference
parking
runbook
installation
devices
network
field
2026-10-08

Site device installation — know it BEFORE you are standing in the booth

A field runbook: for every device we deploy, its factory address and credentials, the tool you need, what the app configures by itself at assign time versus what must be done by hand on the device, and the traps already paid for on park-buzi and the lab. The appliance-provisioning runbook covers the booth PC (OS, disk, Docker, Periphery); this page covers everything plugged into it. Written 2026-09-09 after an evening lost to a printer whose factory address nobody had written down (k200l-printer).

Rule of thumb that explains most of this page: every field device ships on its own private subnet with DHCP off, and none of them announce themselves. You bring a laptop that can take a second static address, you put it on the device's factory subnet, you move the device to the site plan, and only then does anything else see it.

Before leaving the office

Bring

  • A laptop with an Ethernet port and the right to add a second static IPv4 address to it (Windows: adapter → IPv4 → Advanced → add). Under WSL, remember the source-address bug (wsl-dev-networking): after adding a temporary address, ping may work while HTTP times out.
  • The Dingtian reader tool QRCode_v1_6_5.exe (Windows) or scripts/dingtian_qr.py (Python 3, runs on the booth itself — see dingtian-qr-linux-tool) for a DT-008's IP, server target, output type, prefixes and card format. Symbologies are set in neither (no known path). A browser is enough for everything else.
  • Patch cables, a USB A–B cable (printers), the site's address plan (below) filled in, the app admin password, and a fresh Komodo onboarding key if the booth PC is new (appliance-provisioning §7a).
  • The serials if already known: DT-008 cjihao (on the reader's label / in the tool), camera MAC/serial, printer model (label on the bottom — the K200L's own web UI calls it "POS-80").

Address plan — the device VLAN (network-isolation) is 10.0.10.0/24 on both sites so far, every device static, DHCP off everywhere. The convention from park-buzi / park-lab:

Address Device Factory address it came from
10.0.10.1 VLAN gateway (switch/router) —
10.0.10.5 dingtian-relay board (barriers + inputs) 192.168.1.100
10.0.10.7 / .8 dingtian-dt008-reader entry / exit (unique IP each) 192.168.1.99
10.0.10.9 entry-dispenser printer (park-buzi: Cashino KP-300H) not recorded — fill in
10.0.10.10 booth-receipt printer (park-buzi: rongta-printer) not recorded — fill in
10.0.10.11 / .7 (lab) k200l-printer 192.168.123.100
10.0.10.12 / .13 lpr-camera entry / exit (Hikvision DS-2CD1047G3H-LIU) 192.168.1.64 (Hikvision default; needs activation)
10.0.10.203 the booth PC on the device VLAN (the backendIp every device pushes to) —

Fill the real numbers into the site record before you drive; the wizard asks for the booth's push address once and writes it into the Dingtian and the cameras.

1. Dingtian relay board (DT-R004 family) — barriers, button, radar

Factory: IP 192.168.1.100, web UI on port 80, login admin / admin, UDP 60000 (binary) / 60001 (string), multicast discovery 224.0.2.11:60000. See dingtian-relay.

By hand, on the device (browser at its factory address): set the site IP / mask / gateway in the Network page and reboot. That is the only thing you must do by hand. Optional but recommended: in the web UI disable the UDP2 "string" protocol (a password-less relay-fire path); the app's harden step tries to disable it and warns if the device refused — then do it here.

Wiring: button on I1 (NO contact to GND, idles HIGH, pulls LOW on press); radar dry contact on I2; barrier operator's open input on relay 1 (entry) and relay 2 (exit); a spare relay for the entry button lamp (button-light-indicator). One board can carry both barriers; two distant barriers = two boards (entry-exit-points).

What the wizard does on assign (first-run-setup, device-input-flow): finds the board by multicast ("Scan for controllers" — laptop/booth must share the L2 segment), checks and clears input_link_relay (factory default auto-fires a relay from its input — the app must decide, not the board), sets a random relay password (UDP binary), disables every other control channel, rotates the web login, and writes the input push URL + per-device Digest credentials so button/radar edges reach the booth PC. You enter the relay map (which relay is entry/exit/both) and the inputs (button → its relay; radar → presence, activeLow if it idles opposite the button — hikvision-radar).

Traps

  • The HTTP CGI API is unauthenticated on this firmware; admin/admin gates only the web page. Never enable session_en — it bricks the config API and only a factory reset recovers. The VLAN is the boundary, not the login (dingtian-relay §Hardening).
  • A relay password mismatch shows as "offline despite ping": the status query is answered only with the right password. Re-assign / re-enter the relay password in the device form.
  • "Relay test" in Setup pulses real hardware and signs a ledger event — use it to prove wiring, once per relay.

2. Dingtian DT-008 QR + RFID readers

Factory: IP 192.168.1.99; no web UI — everything is set over the network with QRCode_v1_6_5.exe (Windows) or scripts/dingtian_qr.py (any OS; same UDP protocol, reversed 2026-10 — dingtian-qr-linux-tool). See dingtian-dt008-reader.

From the wizard (app builds after 2026-10-08): add a reader → Skano LAN-in / Scan the LAN lists every DT-008 on the device VLAN with its mode and current server; Use fills serial + IP; Test says whether it is in HTTP mode and whether the serial matches; Save switches it to HTTP and points its server at this booth (items 2 and 6 below, done for you). Items 1, 3, 4, 5 are still manual (IP via set-network, prefixes/card format via set, both in scripts/dingtian_qr.py; symbologies only in the exe). Needs the reader's IP in the form — with it blank the save warns and configures nothing.

By hand (vendor tool, or scripts/dingtian_qr.py from the booth), per reader:

  1. Unique device IP (.7 entry, .8 exit). Two readers on one IP was the 2026-06-18 "wrong barrier" incident — scans land on the wrong device row.
  2. Output type = HTTP (the tool also offers RS232 / WG26 / WG34 / RS485 / USB keyboard / USB serial — in any of those the reader beeps locally and never contacts the booth), Server IP = THIS site's booth (park-2 is 10.0.10.101; 10.0.10.203 is the lab — never copy it), server port = the booth's HTTP port (80 behind the prod proxy); "server language" can stay whatever it is (php/jsp/asp/aspx/cgi are all served — the reader GETs /qa/mcardsea.<ext>).
  3. Output prefixes: QRCode Output Prefix = Q:, Card Output Prefix = K: (channel tagging — a printed clone of a card cannot pass as the card).
  4. Card Input format = 6H (defines the UID shape enrolled; changing it later orphans every card).
  5. Symbologies: QR + Code128 only, minimum decode length ≥ 10, checksums on — otherwise low sun through the striped arm produces phantom 6-digit reads (park-buzi, July).
  6. Note the serial (cjihao) — the wizard binds the reader by serial, not by IP.

In the wizard: add the reader with its serial, bind it to the controller relay it sits at (direction is inherited from the relay). Verify: scan a card — the server log shows READ serial=… → device=… verdict=… dir=…; the reader beeps twice on accept, once on refuse, and only after the server's reply (no reply = no beep, the scan still happened).

From the booth, no Windows (2026-10-08): get / set are unicast UDP, so they run on the booth host over SSH (Python 3 is on every booth; the server container has none):

scp scripts/dingtian_qr.py <booth>:/tmp/ && ssh <booth> python3 -I /tmp/dingtian_qr.py get 10.0.10.7
ssh <booth> python3 -I /tmp/dingtian_qr.py set 10.0.10.7 --output-type 3   # item 2: HTTP mode

get prints every field above by name (output_type, server, server_port, card_input_format, qr_prefix, card_prefix…). set changes only the fields given and re-sends the rest as read. Only discover / set-network need the L2 broadcast (run them on the booth, not across Netbird).

Trap: a factory reset or a swapped unit silently loses items 3–5. Re-apply all of them.

Trap (park-2, 2026-10-08): "it beeps, so it works" is false. Enrolling a card failed on both readers although each beeped. The booth log held zero /qa/mcardsea requests over 21 h and the capture window saw only the form's own polls: the readers never contact the booth at all. A beep without a READ line in the log means the reader is not in HTTP mode or points at another server — fix it on the reader (item 2), nothing in the app or the wizard can. Diagnose in one command on the booth: docker logs <server> --since 1h 2>&1 | grep -c mcardsea while a card is presented — 0 = reader-side; then read the reader itself with dingtian_qr.py get (above). park-2's answer: both readers output_type = WG26 (server 10.0.10.101:3000, JSP, 6H, no prefixes) — they were left in Wiegand mode at install, so every scan went to a Wiegand line nobody is listening on. (Port 3000 is fine: the host-net server listens there directly; 80 via Caddy works too.) Fix = set <ip> --output-type 3 per reader, then re-run the enrolment.

Trap (2026-09-17): two DT-008 units read disjoint card sets. park-buzi's units (H05M…) read the site's 125 kHz cards and the fresh lab unit (HC002721) reads only 13.56 MHz cards, although the box leaflet claims both. Batch variant, a dead 125 kHz front end, or a non-EM 125 kHz card format — unresolved. Rule until it is: test a replacement reader against the site's actual cards before it ships, and record the site's card technology. Quick sort of a card: an NFC phone detects 13.56 MHz, cannot see 125 kHz. Details: dingtian-dt008-reader §"Two units, two card sets".

Identify what a reader can read — before it ships (2026-09-17). Keep a reference kit in the lab: one known EM4100 125 kHz fob, one known Mifare Classic (M1) card, and a phone with NFC. Tap all three on the unit with the tool's log pane open (or dingtian-dt008-reader §Bench sink): a line per tap = that technology decodes. The phone always beeps on a 13.56 MHz unit with a random 08… id (never a credential, but proves the 13.56 MHz radio). Then tap the site's own cards. Write the result on the site record next to the serial (reads: EM4100 | M1 | both). Serial families are only a hint (H05M… read park-buzi's 125 kHz cards, HC… did not); the vendor can confirm from a serial. A unit that fails the site's cards does not leave the lab.

Parameters per card technology — identical except one field:

125 kHz site (park-buzi today) 13.56 MHz site
Card Input format 6H (what park-buzi's cards are enrolled with — never change on a live site) 8H preferred: the native UID is 4 bytes, 6H drops one and two cards can collide — confirm 8H on the lab unit before the first enrolment (open-questions #18)
Output prefixes Q: / K: Q: / K:
Output type / server HTTP, booth IP, booth HTTP port same
Buzzer On (the operator hears accept/refuse) On
Symbologies QR + Code128 only same
Card stock EM4100 (or whatever the reference test showed) — do not mix Mifare Classic UID-based; note that a phone is never a card

A site is one technology: once cards are enrolled the reader batch, the input format and the card stock are frozen together. Migrating means re-enrolling every credential.

The tool's Setting tab (v1.6.5, seen 2026-09-17): Search device lists units by serial; Get parameter loads one. Network parameter: IP / Netmask / Gateway / DNS1 / DNS2, DHCP (Static IP), Server address / Server Port / HTTP Server Language, its own Set button. Format parameter: Output type HTTP, Card Input format (6H), QRCode Output format/prefix/suffix, Card Output format/prefix/suffix (prefix fields are where Q: / K: go), serial baud/bits greyed out under HTTP, Low/High Pulse, its own Set. External parameter: Restart interval (12 h), Work mode (Normal), Buzzer On/Off, Scan code fill light, its own Set. Each group is written by its own Set button — setting the network and forgetting the format Set is easy. The log pane at the bottom echoes every card read by the tool (… A238BC), which is the quickest "did the radio see it" check. The Test device tab is the read monitor. Symbology selection was not found on this tab — locate it on the Test device tab or in a newer tool before relying on item 5.

3. Hikvision camera (DS-2CD1047G3H-LIU, AcuSense) — ANPR + snapshots

Factory: 192.168.1.64, inactive until a password is set on first boot (browser at that address or the SADP tool); after activation the login is admin / the password you chose. Site convention so far: admin / admin123 on the first units (change per site and record it). See lpr-camera.

By hand, on the camera:

  1. Activate, set the site IP, disable DHCP. Time: NTP off-site is unavailable — the app re-syncs the camera clock from the booth at every offline→ready edge (clock-integrity).
  2. Streams: the snapshot the app pulls MUST come from the sub stream (102) — the main stream's ISAPI snapshot returns 503 instantly, always, on this model. Set the sub stream to the highest resolution the camera allows.
  3. Event push: Event → Motion Detection with the AcuSense Detection Target = Vehicle filter ON, "Notify Surveillance Center" on, then Alarm Settings → Alarm Server → http://10.0.10.203/api/devices/hikvision/<deviceId>/event. The deviceId exists only after the wizard assign, so: assign first, then come back to the camera. Digest user/password if the firmware allows it (the wizard shows them).
  4. "Enable Hikvision-CGI" is a different legacy surface — not needed for ISAPI.
  5. Close the web UI / live view when done. The camera has few connection slots; a browser left open makes every snapshot pull 503 "Device Busy" (lpr-camera §503).

In the wizard: driver hikvision, host, admin password, channel 1, stream = Sub, ANPR on, bind to the relay at that barrier, alarmPushEnabled on.

Verify, do not assume: drive a car through and look at GET /api/events (or the log) for an alarm with targetType=vehicle. A camera configured for push that has sent zero alarms is broken on its side: pull its Diagnose Information; Main Db is broken means a corrupt config database → factory reset, then redo 1–3 (the Vehicle target filter defaults OFF after a reset). 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 status (00 query → relays:inputs) whether it idles HIGH or LOW; if it idles opposite the button, set activeLow on that input in the wizard, or the gate inverts (tickets only when the lane is empty). It is advisory: it gates the button, it never opens anything (hikvision-radar, entry-double-press).

5. Printers — three models, one byte stream, different status

All print the same ESC/POS bytes over raw TCP 9100 or USB (/dev/usb/lpN); what differs is whether the app can see paper/cover state (printer-status-monitoring, printer-usb-transport). Roles: entry-dispenser outside at the lane, booth-receipt inside (receipts, subscription cards, Z-reports, and the backup for entry tickets), wash-desk if the site has a Car Wash (printer-roles-failover). Higher failoverRank = tried first.

Model Factory network Config UI App driver Live status
k200l-printer (Xprinter/ICS K200L, "POS-80" board; the park-buzi unit) 192.168.123.100/24, DHCP off browser, port 80, no login: Configuration → fixed IP → Save → Restart k200l over LAN: cover / paper / cutter / off-line from /prt_status.htm; over USB: reachability only
rongta-printer (RP-series) not recorded — fill in status page /prn_stat.htm on port 80 rongta over LAN: full; USB: reachability
Cashino KP-300H not recorded — fill in not recorded escpos (generic) reachability only, by design — no trustworthy status source

Prefer LAN over USB wherever a cable can reach: the booth sees a real amber "cover open, paper out" while a roll is changed, and the usblp path (udev rule, node renumbering, the park-buzi "offline after reload" mystery) drops out of the picture. USB needs the appliance's usblp + udev rule (printer-usb-transport §Provisioning) and the printer shows up as /dev/usb/lpN, numbered by plug order.

Verify: the wizard's "Test" only probes (opens the port / the device node) — it prints nothing. Print something real: a subscription with a QR credential auto-prints its card and has a Reprint card button; a payment prints a receipt; a wash till prints slips. Check the Cashino's barcode with a real ticket (the KP-300H garbled overflowing barcodes until the geometry fix).

6. Order of work on site

  1. Address plan on paper; VLAN ports patched; booth PC up with its device-VLAN address.
  2. Dingtian: factory address → site address (browser) → wire button, radar, barriers.
  3. Wizard: controllers first (the relay map + inputs); "Relay test" each barrier.
  4. Readers: tool (IP, server, prefixes, format, symbologies) → wizard (serial, bind) → scan test.
  5. Cameras: activate → IP → sub stream → wizard assign → Alarm Server + Vehicle target → drive-through test → close the browser.
  6. Printers: site address → wizard (role, rank) → print a card.
  7. Walk-through: button + radar → ticket; QR entry then exit; RFID; a subscriber's plate at the camera; pay at the booth → receipt → exit; paper reload on each printer while watching the footer.
  8. Record in the site record: every IP, serial, camera password, printer model, which relay is which, photos of the labels. Remove the temporary laptop addresses. Log out of every device UI.

7. Reaching the cameras remotely — port forward through the booth host (park-2, 2026-10-08)

park-buzi exposed its two Hikvision web UIs on the site router (park-buzi.msai.al:8081 / :8082, see lpr-camera). park-2 does the same through the booth host, because its router only knows the 192.168.1.0/24 side while the cameras live on the device VLAN:

address
router / internet side eno1 192.168.1.101, gateway 192.168.1.1, public 91.230.255.154
device VLAN side eno1 10.0.10.101 (same NIC, second address)
Netbird wt0 100.75.7.237 = park-2.nb.infra
entry camera 10.0.10.9:80 → published as 8081
exit camera 10.0.10.10:80 → published as 8082

Done with iptables on the host (needs root; the admin account has no passwordless sudo). ip_forward is already 1 because Docker set it. Docker also sets the FORWARD policy to DROP, so the explicit ACCEPTs are mandatory, and the SNAT is what brings the camera's replies back through the host (the cameras' gateway is not the booth):

iptables -t nat -A PREROUTING -p tcp --dport 8081 -j DNAT --to-destination 10.0.10.9:80
iptables -t nat -A PREROUTING -p tcp --dport 8082 -j DNAT --to-destination 10.0.10.10:80
iptables -t nat -A POSTROUTING -p tcp -d 10.0.10.9  --dport 80 -j SNAT --to-source 10.0.10.101
iptables -t nat -A POSTROUTING -p tcp -d 10.0.10.10 --dport 80 -j SNAT --to-source 10.0.10.101
iptables -I FORWARD -p tcp -d 10.0.10.9  --dport 80 -j ACCEPT
iptables -I FORWARD -p tcp -d 10.0.10.10 --dport 80 -j ACCEPT
iptables -I FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
apt install -y iptables-persistent && netfilter-persistent save   # survive reboots
  • Reach: from any Netbird peer with a policy to park-2, http://park-2.nb.infra:8081/ (no router change needed). From the internet only once the router forwards 8081/8082 to 192.168.1.101. PREROUTING does not apply to the host's own traffic — test from another machine.
  • Netbird-only variant: add -d 100.75.7.237 to the two PREROUTING rules; then the public forward can never reach the cameras even if someone adds it on the router.
  • Undo: the same lines with -D. ufw, if ever enabled there, also needs ufw route allow proto tcp to 10.0.10.9 port 80 (and .10).
  • Why not Docker: docker run -p 100.75.7.237:8081:80 alpine/socat … would do the same without sudo, bound to the overlay only; the user chose the iptables route.
  • This is a deliberate hole in network-isolation (camera web UI reachable off the VLAN); the camera's own digest auth is the only gate behind it. Keep the public side off unless needed; prefer the Netbird path.

Gaps to fill next time you hold the hardware

  • Factory address and configuration tool of the Cashino KP-300H and the Rongta RP units (both still unknown here).
  • Where in QRCode_v1_6_5.exe the symbologies are selected (the Setting tab has no such field; the IP / server / prefix fields are now described in §2).
  • The card technology each site uses and which reader batch reads it, on the site record next to the serial; and the result of the EM4100 test on the lab unit.
  • Whether the camera activation was done with SADP or the browser at park-buzi, and the per-site camera password location.
  • Where the site record lives (a page per site under wiki/entities/? — park-buzi and park-2 have none yet; the Komodo stack env is the closest thing).

Related: appliance-provisioning · first-run-setup · device-registry · network-isolation · entry-exit-points · dingtian-relay · dingtian-dt008-reader · lpr-camera · hikvision-radar · k200l-printer · rongta-printer · printer-usb-transport · wsl-dev-networking

Booth host firewall: what the device net must reach (2026-10-22)

Found at park-lab (ufw active, rules root-only): the device VLAN could reach ssh but not the app. Devices need, from the device subnet to the booth:

Port Who Why
3000/tcp (PORT) dingtian-relay input push, any device push backendPort() advertises the server's own port, not Caddy's 80 — the push bypasses the proxy.
80/tcp admins on the LAN Caddy → operator UI (and /health).

sudo ufw allow from 10.0.10.0/24 to any port 3000 proto tcp (and 80). Without 3000 the booth's assign flow succeeds (it configures the device outbound) but every button push then dies with a timeout — a silent failure. The booth's ufw rule set is not yet captured in appliance-provisioning; it should be.