From 99c1d038f9855e250d83dbf32aef9b2b5291756b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iwo=20Strzebo=C5=84ski?= Date: Fri, 28 Aug 2026 22:41:42 +0000 Subject: [PATCH] Add InfoCommand as one fully-wired real example in bambulab.v1 The rest of proto/bambulab/ was pure boilerplate/comments with nothing concrete to copy from. This one message (sequence_id + command, matching Bambu's real get_version request) is wired all the way through: real proto, real generated Rust struct, lib.rs actually include!'d instead of commented out. continuum-proxy's bambu_protocol_demo example serializes it and diffs the output against Bambu's actual wire JSON byte for byte. Verified with cargo build (this crate) and cargo run --example bambu_protocol_demo (continuum-proxy) - output matches exactly. --- packages/rust-types/src/lib.rs | 31 +++++++++++++++++-------------- proto/bambulab/v1/request.proto | 18 ++++++++++++++---- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/packages/rust-types/src/lib.rs b/packages/rust-types/src/lib.rs index be2aa71..dd49945 100644 --- a/packages/rust-types/src/lib.rs +++ b/packages/rust-types/src/lib.rs @@ -8,17 +8,20 @@ pub use continuum::v1::{ MaterialProfile, PrintJob, PrintJobStatus, PrintParameters, Template, }; -// bambulab/*.proto currently have no messages (see proto/bambulab/), so -// there's nothing for prost to emit yet — `include!` against a -// nonexistent file would break the build. Once you've added real messages -// to proto/bambulab/{common,v1/*,v2/*}.proto, add: -// -// pub mod bambulab { -// include!(concat!(env!("OUT_DIR"), "/bambulab.rs")); // common.proto's messages -// pub mod v1 { -// include!(concat!(env!("OUT_DIR"), "/bambulab.v1.rs")); // request.proto + report.proto combined — same package -// } -// pub mod v2 { -// include!(concat!(env!("OUT_DIR"), "/bambulab.v2.rs")); -// } -// } +pub mod bambulab { + // common.proto and bambulab/v2/*.proto have no messages yet, so + // there's nothing for prost to emit for them — `include!` against a + // nonexistent file breaks the build. Uncomment each once it has real + // content: + // + // include!(concat!(env!("OUT_DIR"), "/bambulab.rs")); // common.proto's messages + pub mod v1 { + // request.proto + report.proto both declare `package bambulab.v1;`, + // so prost combines them into one output file, regardless of which + // input file each message came from. + include!(concat!(env!("OUT_DIR"), "/bambulab.v1.rs")); + } + // pub mod v2 { + // include!(concat!(env!("OUT_DIR"), "/bambulab.v2.rs")); + // } +} diff --git a/proto/bambulab/v1/request.proto b/proto/bambulab/v1/request.proto index 10439c4..e0a19eb 100644 --- a/proto/bambulab/v1/request.proto +++ b/proto/bambulab/v1/request.proto @@ -2,12 +2,22 @@ syntax = "proto3"; package bambulab.v1; -// import "bambulab/common.proto"; once common.proto has a shared message -// worth embedding (composition, not inheritance — see that file). +// One real, fully-wired example — copy this shape for every other command +// (pushing/pushall, print control, etc.). sequence_id is `string`, not +// int64: Bambu sends it as a JSON string ("0"), and this crosses the wire +// as JSON over MQTT, not binary protobuf — the Rust type needs to match +// what serde_json actually produces, not what "feels more correct" for a +// counter. +message InfoCommand { + string sequence_id = 1; + string command = 2; +} -// Your command messages go here, e.g.: +// Add your next message here, e.g.: // -// message InfoCommand { +// message PushingCommand { // string sequence_id = 1; // string command = 2; +// int32 version = 3; +// int32 push_target = 4; // }