Files
parking_solution/wiki/entities/relay-proxy-firmware.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

4.3 KiB

type, tags, sources, updated, status
type tags sources updated status
entity
parking
hardware
firmware
esp8266
dingtian
cloud
watchdog
poc
2026-10-22 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.