Crown Solar Inverter TCP Ingest Platform
A device-facing telemetry ingest platform for solar inverters (Aotai Hybrid, IP20 2K–12K, IP20 3K6/5K): accept a device TCP connection, heartbeat + telemetry cycle, publish to a message bus, fan out to live viewers over WebSocket.
The device-facing side is not a REST API — there is no HTTP surface there. A device (a WiFi/serial-to-Ethernet logger sitting in front of a solar inverter) opens one TCP connection to the server (plain, or TLS where the logger supports it — both on the same port; see Device TLS) and holds it open; every "operation" is a Modbus request/response pair exchanged over that same socket (for the IP20 3K6/5K, a text command and its one-line reply instead: see IP20 3K6/5K). See Protocol messages for the full message catalog, or jump straight to the Sandbox to see the wire format for yourself.
The frontend-facing side (web/mobile) is a live feed — over WebSocket, not REST — documented in WebSocket integration.
Layout
protocols/source/ Vendor protocol documents (xlsx/docx) the register maps were parsed from
server/
cmd/tcpserver/ Device-facing TCP ingest binary
cmd/ws-gateway/ Browser/mobile-facing WebSocket gateway
cmd/persistence-worker/ Durable telemetry consumer -> TimescaleDB — see "What's built" below
cmd/deviceadmin/ Operator CLI: revoke/restore/delete a device (`npm run device -- ...`)
cmd/live-viewer/ Terminal live-viewer (dev/ops tool, not a service)
cmd/probe/ Dials *into* a logger on your LAN to test a Modbus profile (dev tool)
cmd/ws-test-client/ Scriptable stand-in for a browser client, to exercise ws-gateway (dev tool)
internal/natsclient/ Shared NATS subject naming + JetStream stream setup
internal/storage/postgres/ TimescaleDB schema (embedded migrations) and data access
internal/histparams/ Historical Data parameter catalog: per-model register → parameter mapping
cdk/ AWS CDK app (TypeScript) — VPC, ECS-on-EC2, NATS-on-EC2, TimescaleDB-on-EC2
scripts/ Local dev orchestration (`npm run dev`), device admin wrapper, git hook
This documentation site itself lives in a separate sibling repo,
cse-solar-docs — its own Docusaurus
project and CDK app, deployed independently of the backend above.
What's built vs. not yet
Built: TCP accept, Modbus profile detection, heartbeat + batched telemetry
polling, structured JSON logging, NATS/JetStream messaging (telemetry,
presence, watch/unwatch, and single-register Modbus write commands — see
Messaging), a WebSocket gateway for live
frontend/mobile viewers including a device-write path (see
WebSocket integration), a
persistence worker durably consuming telemetry into TimescaleDB
(cmd/persistence-worker, dev_telemetry_db — see
Infrastructure), and AWS CDK deployment for all of it
(a dev-tier pipeline of Graviton t4g.micro hosts at roughly $30/month,
plus fleet-shaped stacks for when traffic justifies them — see
Infrastructure). Per-inverter history is served
through the same gateway: energy Analytics, and
Historical Data (any of ~117 parameters,
Day/Week, for 3 months; Month/Year/Total energy bars). Devices are identified by a
database-backed registration (the logger's own ID plus the inverter serial
it is paired with), and cmd/deviceadmin can revoke, restore or
permanently erase a device — see Server behavior.
Deliberately not built yet (in this repo): a REST API (the HTTP
management API is the separate cse-http-be project, documented in its own
section of this site), device→model provisioning, TLS
on either the device listener or the WebSocket gateway, and full client
authentication on the WebSocket gateway (origin validation exists; the
device-write path has an ownership check against devices.owner_user_id,
not cryptographic per-user auth — see
WebSocket integration for
why this matters before a public launch). Multi-register write targets
aren't supported either — only single-register writes, sent as function
code 6 or as function code 16 with a quantity of 1, whichever the
register's own spec documents. The exception is the Aotai clock
set_rtc_time, a datetime register written as three registers in one
function-16 request.
Where to go next
- Setup — get the server and CDK app running on a new machine.
- Server behavior — what
cmd/tcpserveractually does per connection. - Connection lifecycle — the full accept → detect → poll flow as a diagram.
- Protocol messages — the Modbus request/response message catalog (AsyncAPI-documented).
- Protocol reference — per-model register tables, generated from the parsed vendor specs.
- Messaging — the NATS subjects, streams, and
delivery semantics connecting
tcpservertows-gateway. - WebSocket integration — for frontend/mobile developers: how to connect, the message protocol, and working JS/TS and Flutter code.
- Sandbox — build a real Modbus request frame and see a simulated decoded response, without needing hardware.
- Infrastructure — the CDK stacks and how to deploy.