52 lines
2.1 KiB
Markdown
52 lines
2.1 KiB
Markdown
# continuum-proxy
|
|
|
|
Edge gateway daemon for the Continuum print farm platform. Runs on a Linux SBC
|
|
on-site, discovers and talks to printers over the LAN, and maintains a
|
|
resilient uplink to the cloud control plane (`continuum-backend`).
|
|
|
|
## Responsibilities
|
|
|
|
- **Uplink** (`src/uplink/`): persistent WebSocket connection to
|
|
`wss://api.domain.com/ws/edge/v1` with exponential-backoff reconnects,
|
|
heartbeat ping/pong, and inbound task dispatch.
|
|
- **Printer adapters** (`src/adapters/`): protocol clients per printer vendor —
|
|
Bambu Lab (MQTT 8883 + FTPS 990), PrusaLink (REST), Klipper (Moonraker WS).
|
|
- **Plate changer** (`src/plate_changer/`): mechanical cycle execution and
|
|
sensor validation over GPIO/serial for automated plate-swap hardware.
|
|
- **Local cache** (`rusqlite`): buffers telemetry and job state through
|
|
connectivity gaps so nothing is lost if the uplink drops.
|
|
- **go2rtc watchdog**: supervises the bundled `go2rtc` process for camera
|
|
restreaming (RTSP/USB → WebRTC).
|
|
|
|
## Getting started
|
|
|
|
```bash
|
|
cp .env.example .env
|
|
cargo run
|
|
```
|
|
|
|
## Structure
|
|
|
|
```
|
|
src/
|
|
main.rs Multi-threaded async engine: uplink, discovery, go2rtc watchdog
|
|
uplink/ Cloud WebSocket client (reconnect, heartbeat, dispatch)
|
|
adapters/ bambu.rs, prusalink.rs, moonraker.rs — wire-protocol clients
|
|
printer/ Domain model: Printer trait + PrinterBase + PrinterHandle enum
|
|
plate_changer/ Mechanical cycle control + sensor validation
|
|
discovery/ LAN printer discovery (SSDP / mDNS / static config)
|
|
```
|
|
|
|
`src/adapters/` talks the raw wire protocols (MQTT, FTPS, HTTP, WS).
|
|
`src/printer/` is the vendor-agnostic domain model layered on top: a
|
|
`Printer` trait plus one struct per vendor (`BambuPrinter`, `PrusaPrinter`,
|
|
`KlipperPrinter`) wrapped in a closed `PrinterHandle` enum. Rust has no class
|
|
inheritance, so this trait+enum combo is what stands in for a
|
|
`GenericPrinter -> BambuPrinter` hierarchy — composition for shared fields,
|
|
a trait for shared/overridable behavior, an enum for the closed set of
|
|
vendors. See `examples/printer_polymorphism.rs`:
|
|
|
|
```bash
|
|
cargo run --example printer_polymorphism
|
|
```
|