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.
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
---
|
||||
type: concept
|
||||
tags: [parking, hardware, runbook, esp32, dingtian]
|
||||
sources: []
|
||||
updated: 2026-10-22
|
||||
---
|
||||
|
||||
# Runbook — Is this ESP32 board flashable? (Dingtian DT-R0xx lock test)
|
||||
|
||||
A bench test that answers one question in a few minutes: **is the ESP32 on this [[dingtian-relay]]
|
||||
locked (standard SKU) or open (Development Board Version)?** Run it before ordering more units or
|
||||
planning any custom-firmware work (see [[dingtian-relay]] "Can we flash our own firmware?").
|
||||
|
||||
The test is read-only. Nothing is written to the chip, no eFuse is burned, and the stock firmware
|
||||
boots normally afterwards.
|
||||
|
||||
## What "locked" means on an ESP32
|
||||
|
||||
The vendor burns one-time eFuse bits at the factory; they can never be cleared. Any one of these
|
||||
blocks custom firmware:
|
||||
|
||||
| eFuse | Effect | How the test shows it |
|
||||
| --- | --- | --- |
|
||||
| `DISABLE_DL_ENCRYPT` / `DISABLE_DL_DECRYPT` / UART download disabled | ROM bootloader refuses serial flashing | `esptool chip_id` never connects |
|
||||
| `FLASH_CRYPT_CNT` (flash encryption) | flash contents unreadable/unwritable from outside | `espefuse summary` shows it odd/enabled |
|
||||
| `ABS_DONE_0` / `ABS_DONE_1` (secure boot) | ROM only runs a vendor-signed bootloader | `espefuse summary` shows it set |
|
||||
|
||||
The 74HC595 / 74HC165 shift registers on the board are **not** a blocker; community firmware drives
|
||||
them already.
|
||||
|
||||
## Equipment
|
||||
|
||||
- USB-to-UART adapter, **3.3 V logic** (CP2102 / CH340 / FT232). Set its jumper to 3.3 V.
|
||||
- Dupont leads. Do **not** connect the 12 V supply; the adapter's 3.3 V powers the ESP32 for this test.
|
||||
- A PC with Python: `pip install esptool` (gives both `esptool.py` and `espefuse.py`).
|
||||
|
||||
## Wiring (DT-R0xx programming header)
|
||||
|
||||
| Adapter | Board |
|
||||
| --- | --- |
|
||||
| GND | GND |
|
||||
| 3V3 | 3V3 |
|
||||
| TXD | RXD (ESP32 GPIO3) |
|
||||
| RXD | TXD (ESP32 GPIO1) |
|
||||
| DTR | NRST (optional; lets esptool reset the board itself) |
|
||||
|
||||
Header labelling varies by revision; confirm against the silkscreen. GPIO1/3 are also the board's
|
||||
Modbus UART, so expect the stock firmware to chatter on them when it boots.
|
||||
|
||||
## Procedure
|
||||
|
||||
1. Wire as above, adapter unplugged.
|
||||
2. **Hold the board's boot switch** while plugging the adapter into USB. Keep holding ~1 s, release.
|
||||
(Without DTR wired, this is the only way into download mode.)
|
||||
3. Identify the port: `COMx` on Windows, `/dev/ttyUSB0` on Linux. On WSL, pass the device through
|
||||
or run from Windows.
|
||||
4. Run:
|
||||
|
||||
```
|
||||
esptool.py --port COM5 --baud 115200 chip_id
|
||||
```
|
||||
|
||||
5. If it connects, read the eFuses:
|
||||
|
||||
```
|
||||
espefuse.py --port COM5 summary
|
||||
```
|
||||
|
||||
## Reading the result
|
||||
|
||||
**Open (Development SKU):**
|
||||
```
|
||||
Chip is ESP32-D0WD-V3 (revision v3.x)
|
||||
Features: WiFi, BT, Dual Core, 240MHz, ...
|
||||
Chip ID: 0x...
|
||||
```
|
||||
and in the summary `FLASH_CRYPT_CNT = 0`, `ABS_DONE_0 = False`, `ABS_DONE_1 = False`,
|
||||
`DISABLE_DL_* = False`. Custom firmware (ESPHome `dtr0xx_io`, Tasmota, ESP-IDF) is possible.
|
||||
|
||||
**Locked (Standard SKU), either of:**
|
||||
- `A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header`
|
||||
after the boot-switch step was done correctly → UART download is disabled.
|
||||
- It connects but the summary shows flash encryption and/or secure boot enabled → you can reach the
|
||||
ROM but cannot run your own image. Treat as locked.
|
||||
|
||||
**Inconclusive:** garbled output or "Connecting....." forever on the *first* try is usually a wiring
|
||||
or boot-mode slip (TX/RX swapped, 5 V jumper, switch released too early). Retry twice before calling
|
||||
it locked. One forum report of exactly this symptom was never resolved.
|
||||
|
||||
## Record the outcome
|
||||
|
||||
Add a line to the "Status" list on [[dingtian-relay]] with the unit's serial, SKU, firmware version
|
||||
and the verdict, and a `## [date] query` entry in `log.md`. A locked verdict closes the custom-firmware
|
||||
question for that unit; the only route is ordering the Development Board Version
|
||||
([[esp32-custom-controller]] remains deferred, [[open-questions]] #6).
|
||||
|
||||
## Related
|
||||
|
||||
- [[dingtian-relay]] — hardening gaps that custom firmware would close.
|
||||
- [[esp32-custom-controller]] — the prevention-grade device this would approximate.
|
||||
- [[site-device-installation]] — field runbook; this test is a bench task, not a site task.
|
||||
@@ -345,3 +345,18 @@ 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.
|
||||
|
||||
@@ -178,3 +178,12 @@ procurement. (See [[parking-system-architecture]] §10.)
|
||||
reply unknown) and Dahua (37810, uncaptured) do not. Plan, rules and order of work:
|
||||
[[device-discovery-roadmap]]. Settles when cameras and printers scan from the wizard and the
|
||||
relay's search reply has been captured on the bench.
|
||||
|
||||
## Cloud takeover mode vs. the signed ledger (2026-10-22, parked)
|
||||
|
||||
If the cloud commands the barrier while the booth PC is dead ([[relay-proxy-firmware]]), entry/exit
|
||||
events happen that the site's [[atecc608]] signer never saw. Unresolved by design for now: a
|
||||
cloud-authored, separately signed segment the booth ingests and countersigns on return, with the
|
||||
gap recorded rather than hidden. Without it, takeover is a fraud lever (pull the PC's power).
|
||||
Also: exit must still fail open by hardware when the uplink is down too ([[fail-state-safety]]).
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type: entity
|
||||
tags: [parking, hardware, access-control, relay]
|
||||
sources: []
|
||||
updated: 2026-06-14
|
||||
updated: 2026-10-22
|
||||
---
|
||||
|
||||
# Dingtian Relay Controller
|
||||
@@ -170,6 +170,33 @@ On assign the driver runs `harden()` (the [[device-registry|HardenableDevice]] c
|
||||
> drop connections (ECONNRESET), locking out the API the driver depends on — recoverable only by
|
||||
> factory reset. `harden()` deliberately never touches it.
|
||||
|
||||
## Can we flash our own firmware? (2026-10-22)
|
||||
|
||||
The DT-R0xx boards are **ESP32-WROOM-32D** designs (the module is visible in product photos; the
|
||||
community ESPHome/Tasmota configs target ESP32). Relays/inputs are behind **74HC595 / 74HC165
|
||||
shift registers** (SDI GPIO13, CLK GPIO14, RCK GPIO15, PL GPIO32, Q7 GPIO16); Ethernet is a
|
||||
**JL1101 PHY** (MDC 23, MDIO 18, clock out 17, power 0). Community firmware exists: Tasmota
|
||||
templates (Dingtian ships them in its own download centre) and an ESPHome external component
|
||||
`dtr0xx_io`.
|
||||
|
||||
**But the vendor sells two SKUs.** The *Standard Firmware Version* (default shipment) is locked —
|
||||
dtwonder: "The standard finished firmware version is not intended for user firmware flashing";
|
||||
ESPHome devices page: "ask for relay board with test firmware, otherwise the ESP32 will be locked".
|
||||
The *Development Board Version* ships with a bare "GPIO test firmware" and is meant for ESPHome /
|
||||
Tasmota / ESP-IDF. The lock mechanism is not documented publicly (flash encryption, secure boot,
|
||||
or UART-download-disable eFuses are all plausible on an ESP32 — eFuses are irreversible). No
|
||||
forum post reports successfully unlocking a standard unit. Flashing a dev unit is plain ESP32
|
||||
serial flashing (NRST↔DTR, 3.3 V USB-UART, hold the boot switch while powering).
|
||||
|
||||
**Implication for us:** our bench unit (DT-R004, V3.1.5461A, standard SKU) should be assumed
|
||||
**not flashable** until tested — runbook: [[esp32-flashability-test]]; a dev-SKU unit would be. Custom firmware would let us close the open CGI/UDP
|
||||
control plane (the hardening gaps above) by putting [[challenge-response-auth]] on the device —
|
||||
effectively the [[esp32-custom-controller]] path on vendor hardware (no [[atecc608]] footprint,
|
||||
so the key would live in ESP32 eFuse/NVS under flash encryption). That remains **deferred**
|
||||
([[open-questions]] #6); if revisited, order the dev SKU and note the relay-GPIO pull-down
|
||||
"relays blip on at boot" report on Tasmota — a boot-time relay pulse on a barrier is unacceptable
|
||||
([[barrier-not-a-door]]) and must be verified before any field use.
|
||||
|
||||
## `relayPassword` field + the "offline despite ping" gotcha (2026-06-24)
|
||||
|
||||
`relay_pw` is in **every** binary frame — control AND the status read `healthCheck()` uses. With a
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
type: entity
|
||||
tags: [parking, hardware, firmware, esp8266, dingtian, cloud, watchdog, poc]
|
||||
sources: []
|
||||
updated: 2026-10-22
|
||||
status: poc
|
||||
---
|
||||
|
||||
# relay-proxy — Dingtian emulator + cloud proxy/watchdog firmware (PoC)
|
||||
|
||||
Code: `firmware/relay-proxy/` (PlatformIO, Arduino framework; NodeMCU v3 / ESP8266 now, ESP32
|
||||
env planned for the real [[dingtian-relay]]). Throwaway cloud stand-in: `poc/cloud-standin.mjs`.
|
||||
|
||||
## Why
|
||||
|
||||
park-2's booth PC died twice unnoticed ([[appliance-provisioning]] incident 2026-10-17). The
|
||||
idea (2026-10-22): the device that already owns the barrier relay and the button inputs becomes
|
||||
the resilient core — it reports to a multi-tenant cloud independently of the PC, can
|
||||
power-cycle the PC, and keeps taking relay commands from the cloud when the PC is dead. Custom
|
||||
firmware on the Dingtian is the natural home ([[esp32-flashability-test]] gates that); the
|
||||
NodeMCU is the stand-in while no flashable Dingtian is on hand. Ledger implications of a cloud
|
||||
takeover mode are **deliberately parked** (see [[open-questions]]).
|
||||
|
||||
## What it is to the booth: a DT-R004
|
||||
|
||||
The firmware speaks the Dingtian wire contract so the booth's `dingtian` driver is unchanged:
|
||||
binary UDP 60000 (`00` status / `01` write / `03` jog, `relay_pw` checked, wrong password
|
||||
dropped silently), string UDP 60001 (password-less; disabled when `udp2.p=255`),
|
||||
`GET /api/v2/config.cgi`, `POST /api/v2/config_set.cgi` (requires `"command":"setconfig"`,
|
||||
exactly like the hardware gotcha), `GET /userset.cgi` (`&0&` / `&2&`), and Digest-authenticated
|
||||
input push to `on_path`/`off_path`. Config persists in LittleFS; factory state has
|
||||
`input_link_relay` ON so the booth's precondition fix is exercised.
|
||||
|
||||
**Verified 2026-10-22 from the dev PC** (board at 10.0.10.101 on the ArtServis Wi-Fi, which lands
|
||||
on the park-lab device net): status reply `ff aa s 00 <relay> <input>`, jog/write/release, string
|
||||
`00`→`0000:1111:4`, setconfig-only writes, login rotation codes, cloud → relay pulse.
|
||||
|
||||
## What it adds: proxy + watchdog
|
||||
|
||||
Heartbeat to the cloud every 10 s (IP, booth health, relay/input state, config flags); every input
|
||||
change mirrored to the cloud regardless of booth push config; cloud command poll (`pulse`,
|
||||
`watchdog`, `reboot_pc`); watchdog probes the booth `/health` every 5 s and after 6 misses pulses
|
||||
relay 2 for 3 s (NC contact in series with the PC mains + BIOS AC Recovery=On = reboot), 10-min
|
||||
backoff, cloud can disable. This is the detect+remediate layer park-2 lacked.
|
||||
|
||||
## Booth integration — VERIFIED end to end (2026-10-22, park-lab)
|
||||
|
||||
After `ufw allow from 10.0.10.0/24 to any port 80,3000 proto tcp` on park-lab (see
|
||||
[[site-device-installation]] "Booth host firewall"): the admin added the board in park-lab's setup
|
||||
as a Dingtian controller (host 10.0.10.101). The booth's assign flow landed on the board exactly as
|
||||
on hardware — `input_link_relay` cleared, random `relay_pw`, every channel but UDP1 set to 255
|
||||
(udp2 really off: `00` on 60001 times out), web login rotated (`admin/admin` → `&2&`), Digest push
|
||||
to `10.0.10.198:3000/api/devices/dingtian/<id>/input/N/{on,off}`. A FLASH-button press then
|
||||
produced: board → booth `401` challenge → Digest retry → `200`, booth log
|
||||
`[dingtian:<id>] input 1 on (push)` + `off`, and the cloud stand-in received `input_on` /
|
||||
`input_off` with `booth_status=200` — the same event seen by booth and cloud independently. The
|
||||
watchdog flipped to `booth UP` the moment port 80 opened.
|
||||
|
||||
## Open
|
||||
|
||||
- The booth's ufw rule set is root-only and undocumented — belongs in [[appliance-provisioning]].
|
||||
- The booth accepts pushes only from the registered host IP → the board needs a DHCP reservation
|
||||
or `STATIC_IP`.
|
||||
- ESP8266 limits (Wi-Fi only, ~40 KB heap, blocking HTTP) are PoC-only; the target is the ESP32
|
||||
on the Dingtian with Ethernet. Camera traffic is never proxied by the microcontroller.
|
||||
|
||||
## Bench note: NodeMCU v3 clone CH340 vs WCH driver
|
||||
|
||||
The board's USB-serial reports `USB\VID_1A86&PID_7523&REV_0254` and WCH drivers 3.9/4.0 refuse it
|
||||
("A device attached to the system is not functioning" on every open). Fix applied 2026-10-22:
|
||||
WCH driver **3.4.2014.08** (SparkFun mirror, WHQL catalog + Qinheng-signed setup verified),
|
||||
staged with `pnputil /add-driver`, newer package exported to scratch then deleted from the store
|
||||
so the port rebinds. Windows Update may push 4.0 back; repeat if the port fails again.
|
||||
@@ -46,6 +46,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`).
|
||||
- [[relay-proxy-firmware]] — PoC (2026-10-22): NodeMCU firmware that IS a DT-R004 to the booth (binary/string UDP, config CGI, userset, Digest push) + cloud heartbeat/command/watchdog (power-cycles the PC). Verified against the emulator; booth integration blocked on park-lab ufw.
|
||||
- [[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.
|
||||
@@ -70,6 +71,7 @@ Counts: 4 sources · 19 entities · 47 concepts · 8 decision records.
|
||||
- [[device-registry]] — catalog of selectable drivers per category (admin-configurable).
|
||||
- [[first-run-setup]] — admin adds controllers + binds readers/cameras to relays from the catalog at install.
|
||||
- [[site-device-installation]] — FIELD RUNBOOK (2026-09-09): per device — factory address + credentials, the tool needed, what the wizard configures itself vs what is done by hand on the device, known traps; address plan, order of work on site, gaps to fill. Dingtian relay, DT-008 readers, Hikvision camera, radar, K200L / Rongta / Cashino printers.
|
||||
- [[esp32-flashability-test]] — BENCH RUNBOOK (2026-10-22): is this ESP32 board locked? `esptool chip_id` + `espefuse summary` on the Dingtian DT-R0xx programming header; read-only; locked = standard SKU, open = Development Board Version.
|
||||
- [[device-input-flow]] — button → device push → backend decides → relay; backend is source of truth.
|
||||
- [[device-discovery]] — optional driver capability to scan the LAN; implemented by the DT-008 reader (2026-10-08), UHPPOTE was the historical example.
|
||||
- [[barrier-not-a-door]] — never timed-close a barrier; safety lives in barrier firmware.
|
||||
|
||||
+32
@@ -3547,3 +3547,35 @@ set via dell-wmi-sysman; no BIOS admin password on the replacement yet. Ledger c
|
||||
after two unclean stops. [[appliance-provisioning]] §1/§8 + gotchas 7–8.
|
||||
|
||||
## [2026-10-20] ingest | park-lab back on a dedicated 7070 (server = park-lab, all modules entitled); GRUB CLASS line clarified in appliance-provisioning §5
|
||||
|
||||
## [2026-10-22] query | Dingtian DT-R0xx: can we flash our own firmware?
|
||||
|
||||
ESP32-WROOM-32D board; community ESPHome (`dtr0xx_io`) / Tasmota support exists, but the vendor
|
||||
locks the standard SKU — only the "Development Board Version" (GPIO test firmware) is flashable.
|
||||
Our bench DT-R004 is the standard SKU → assume not flashable. Filed under [[dingtian-relay]]
|
||||
"Can we flash our own firmware?"; custom firmware stays deferred ([[esp32-custom-controller]]).
|
||||
|
||||
## [2026-10-22] built | Runbook: ESP32 flashability test for the Dingtian DT-R0xx
|
||||
|
||||
New [[esp32-flashability-test]] (concepts/): wiring, boot-mode entry, `esptool chip_id` +
|
||||
`espefuse summary`, how to read locked vs open vs inconclusive. Linked from [[dingtian-relay]] and index.
|
||||
|
||||
## [2026-10-22] built | relay-proxy PoC firmware (NodeMCU as a Dingtian DT-R004 + cloud proxy/watchdog)
|
||||
|
||||
New [[relay-proxy-firmware]]: flashed, on Wi-Fi at 10.0.10.101, every Dingtian surface verified
|
||||
from the dev PC, cloud→relay command verified. Blocked: park-lab ufw drops 80/3000 from the device
|
||||
net (also blocks a real Dingtian push) — needs root. Bench fix: clone CH340 needs WCH driver 3.4.
|
||||
Parked the ledger question in [[open-questions]].
|
||||
|
||||
## [2026-10-22] query | Booth firewall vs device push: the push targets PORT 3000, not Caddy's 80
|
||||
|
||||
park-lab ufw let the NodeMCU reach /health on 80 after the first rule, and the booth assign flow
|
||||
configured the board (relay_pw, udp2 off, login rotated, Digest push to 10.0.10.198:3000) — but
|
||||
3000 is still dropped from the device net, so pushes would time out. Documented in
|
||||
[[site-device-installation]] "Booth host firewall"; rule set belongs in [[appliance-provisioning]].
|
||||
|
||||
## [2026-10-22] built | relay-proxy: booth integration verified end to end at park-lab
|
||||
|
||||
Board registered through park-lab setup; assign flow applied every step; FLASH press → Digest push
|
||||
accepted by the booth (401→200, "input 1 on (push)") and mirrored to the cloud stand-in with
|
||||
booth_status 200. See [[relay-proxy-firmware]].
|
||||
|
||||
Reference in New Issue
Block a user