- GenericPrinter grows upload_project_file, send_gcode_line, and a generic upload_gcode<P> driver that streams a whole gcode file line by line through any vendor's send_gcode_line. - PrusaSerialPrinter's connect/send_gcode_line are real (not stubs): a held-open MarlinSerialConnection (src/printer/marlin_serial.rs) writes each line and waits for Marlin's "ok" before sending the next. Config changed from com_port: i16 to port: String + baud_rate: u32 to hold a real device path. - Bambu: BambuGenericPrinter + BambuV1Printer/BambuV2Printer collapsed into one BambuPrinter, since which MQTT/BambuMQTT version (v3.1.1/v1 vs v5/v2) a printer speaks is discovered at connect() time (or forced), not something config should pick a type for - the same physical printer can change after a firmware update. printers.toml gets a new "bambu" vendor (auto-detect, the default) alongside bambu_v1/bambu_v2 (force a specific one). - Bambu's gcode_line request is now built for real via continuum-schema-instance against continuum-schemas' JSON Schema, picking the v1 or v2 schema directory based on the detected protocol version, instead of a hand-written serde struct. - Added rumqttc as a dependency (not wired up yet - the real MQTT v5-then-v3.1.1 fallback connect and the publish/receive plumbing are still stubs).
34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
//! Run with: cargo run --example auto_connect_bambu
|
|
//!
|
|
//! The "smooth, no manual steps" version of test_bambu_certs +
|
|
//! fetch_bambu_cert combined: for each Bambu printer in printers.toml,
|
|
//! makes sure it has a working certificate, auto-pinning one via
|
|
//! trust-on-first-connect if the bundled CA doesn't verify. Safe to run
|
|
//! repeatedly - a printer that's already pinned (certs/pinned/<serial
|
|
//! number>.pem) just gets re-verified against its pin, no network trust
|
|
//! decision is made again.
|
|
|
|
use continuum_proxy::fleet;
|
|
use continuum_proxy::printer::PrinterHandle;
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
let mut printers = fleet::load(std::path::Path::new("printers.toml"))?;
|
|
let cert_dir = std::path::Path::new("certs/pinned");
|
|
|
|
for printer in &mut printers {
|
|
match printer {
|
|
PrinterHandle::Bambu(bambu) => report(&bambu.ensure_trusted(cert_dir)),
|
|
_ => {}
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
fn report(result: &anyhow::Result<()>) {
|
|
match result {
|
|
Ok(()) => println!("connected"),
|
|
Err(err) => println!("failed: {err}"),
|
|
}
|
|
}
|