//! Run with: cargo run --example auto_connect_bambu //! //! 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 - the exact same `ensure_trusted` step //! `BambuPrinter::connect()` runs before opening MQTT, isolated here so //! you can check/establish trust without needing a full MQTT handshake to //! succeed too. Safe to run repeatedly - a printer that's already pinned //! (certs/pinned/.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}"), } }