Files
parking_solution/wiki/entities/rongta-printer.md
T
julian bba988c4e8 feat(subscription): QR credentials — operator-choose (QR-only now), auto-generate, multi-month, printed card
Builds out subscription credentials on top of the rename.

- Operator chooses the credential type; only QR is live (RFID shown disabled
  "soon"). Backend/schema keep accepting both — re-enabling RFID is UI-only.
- QR codes are AUTO-GENERATED server-side (SUB-<base32>, crypto-random,
  globally-unique-checked) — the customer/operator never picks the value.
  RF stays operator-entered (the physical card id). Reader output decided =
  TCP/IP full string (Wiegand-numeric fallback noted).
- Multi-month: form takes a `months` count → server sets validTo =
  validFrom + N months (day-clamp); one record/one window; total = N×monthly.
- The QR card is PRINTED so the operator can hand it over: real ESC/POS 2D QR
  (GS ( k) added to the Rongta driver (printSubscriptionCard); auto-print on
  create (best-effort — never fails the create; returns {printed,printError})
  + reprint via POST /api/subscriptions/:id/print and a "Print code" button.

Verified via buildServer+inject incl. a TCP capture of the on-wire QR bytes
(autogen+uniqueness, Jan31+3mo→Apr30, auto-print, GS ( k QR with embedded
code, reprint, no-QR→409). Updated wiki (subscription, rongta-printer). No
migration.

Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
2026-06-18 14:48:38 +02:00

56 lines
2.9 KiB
Markdown

---
type: entity
tags: [parking, hardware, printer, device]
sources: []
updated: 2026-06-14
---
# Rongta 80mm thermal printer
The chosen ticket/receipt printer: a **Rongta RP-series 80mm network thermal printer** (and the
many ESC/POS-compatible OEM clones that share its firmware). Driver `rongta` in
`packages/devices` implements [[device-adapter-pattern|PrinterDevice]].
## Transport & protocol
- **ESC/POS over a raw TCP socket on port 9100** (the JetDirect/RAW convention). The driver
opens the socket, writes the ESC/POS byte stream, waits for flush, closes.
- **No authentication** on the print socket — anyone who can reach port 9100 can print. Like
every other field device it must sit on the **isolated device VLAN** ([[network-isolation]]).
There is no real HTTP/control boundary on the device (same posture as [[dingtian-relay]]).
- **Health check** is a TCP connect probe to 9100. The print socket exposes no status protocol
we rely on; the print itself is the real reachability test (failover attempts the print).
- **Live status** comes from the device's own web page `http://<host>/prn_stat.htm` (port 80),
which decodes Cover Open / Cutter Error / Paper End / Paper Near End / Off-Line into Yes/No.
We scrape that rather than hand-decode `DLE EOT` — this clone's DLE EOT reply bytes do **not**
match the canonical ESC/POS bit layout (verified on hardware), so trusting the device's own
decode avoids a false-healthy. Implemented as `readStatus()`; see [[printer-status-monitoring]].
## Deployment (this site)
- First printer verified reachable at **10.0.10.6:9100** from the host (TCP connect OK,
2026-06-14).
- **At least two printers**, by role — see [[printer-roles-failover]]:
- **entry-dispenser** — outside, at the lane; the driver takes the entry ticket.
- **booth-receipt** — inside the booth; receipts, AND the backup that prints the entry
ticket if the outside dispenser is offline.
## Ticket rendering
`printTicket(TicketData)` builds ESC/POS: `ESC @` init, centered/bold/double-size header,
lane, ticket id, issued-at, feed + partial cut (`GS V B`). CP437/ASCII subset. The entry ticket
encodes the id as a **1D Code128** barcode (`GS k`).
**`printSubscriptionCard(SubscriptionCardData)`** (added 2026-06-18) renders a **2D QR** of the
[[subscription]] code via ESC/POS **`GS ( k`** (model 2, EC level M) — firmware-rendered, no bitmap
dependency — plus the code as text + holder/validity. Used for the auto-printed + reprintable
subscription card. (Verified: the `GS ( k` store/print byte sequences + the embedded code appear on
the wire against a TCP capture.)
## Status
Driver written and compiles; entry-ticket layout is a first pass; live status monitoring is
implemented and verified ([[printer-status-monitoring]]). The receipt/exit layout and the
cash-drawer kick (ESC/POS `ESC p`) are **not yet implemented** — they arrive with the
exit/payment flow. Replaces the generic "Epson TM / Citizen" booth-printer line in [[bom]].