Add get_calibration; fix a real 10KB packet-size ceiling; revert bad correlation-field experiment

Real bug found and fixed live: both rumqttc clients default to a 10KB
max packet size in both directions. A real H2C's get_version reply
(25625 bytes - it reports a lot of modules: dual AMS, AMS HT, six WTM
units, ...) blew straight through that on the v5 client and killed the
whole connection outright (a real MQTT protocol error, not a timeout).
Raised to 1MB on both clients - print.push_status reports can get large
too.

Also tried, and reverted after live-testing disproved it: replacing
request()'s sequence_id correlation with a homemade
continuum_correlation_id field, on the understanding that most replies
echo back arbitrary extra request fields. True in general, false for
get_version specifically - a real H2C's reply had exactly ["command",
"module", "sequence_id"], nothing extra survived, so every get_version
call started timing out. Reverted to sequence_id, which is what's
actually proven (twice now, on both protocol versions) to round-trip for
this command.

Added BambuPrinter::get_calibration(option) - print.calibration gets a
real, correlated reply (confirmed live: it does echo sequence_id) on
both protocol versions, per the schema fixes in continuum-schemas.
`option` is the request's own bitmask, left to the caller rather than
defaulled to "run everything" - this triggers a real physical
calibration sequence on the printer, not a read-only query like
get_version, so it hasn't been live-tested here without explicit
confirmation first.
This commit is contained in:
2026-09-07 14:55:09 +00:00
parent 6ce60542c6
commit 256463e29c
2 changed files with 114 additions and 170 deletions
+36 -3
View File
@@ -384,9 +384,9 @@ impl BambuPrinter {
/// not through the shared trait.
///
/// The first real use of `BambuMqttSession::request` -
/// `info.get_version` is a genuine one-shot, `sequence_id`-correlated
/// reply (unlike `pushing.pushall`, see `request`'s doc comment), so
/// this is exactly the case it's for.
/// `info.get_version` is a genuine one-shot, correlated reply (unlike
/// `pushing.pushall`, see `request`'s doc comment), so this is exactly
/// the case it's for.
pub async fn get_version(&self) -> Result<super::GetVersionResponse, PrinterError> {
let (session, version) =
self.connection.as_ref().ok_or_else(|| PrinterError(format!("{} is not connected", self.base.name)))?;
@@ -403,6 +403,39 @@ impl BambuPrinter {
.map_err(|err| PrinterError(format!("failed to parse get_version response: {err}")))
}
/// Bambu-only, same reasoning as `get_version` above. Sends
/// `print.calibration` and waits for the correlated `print.calibration`
/// *report* it triggers - confirmed live on both protocol versions,
/// which respond identically here (an earlier, incorrect assumption
/// had v1 folding this into `push_status` instead of replying
/// directly; fixed in continuum-schemas). The printer also keeps
/// sending ordinary `push_status` updates reflecting progress while
/// calibration runs, same as any other job - read those via
/// `print_status()` if you want progress, this call just confirms the
/// calibration sequence started and got acknowledged.
///
/// `option` is the bitmask this command's own schema defines:
/// `lidarCalibration = 1`, `bedLevelling = 1 << 1`,
/// `vibrationCompensation = 1 << 2`, `motorCancellation = 1 << 3` (OR
/// together whichever steps you want). Deliberately not defaulted to
/// "everything" here - this starts a real, physical calibration
/// sequence on the printer, so the caller states exactly what they
/// mean to trigger rather than this method guessing.
pub async fn get_calibration(&self, option: i64) -> Result<serde_json::Value, PrinterError> {
let (session, version) =
self.connection.as_ref().ok_or_else(|| PrinterError(format!("{} is not connected", self.base.name)))?;
let mut body = continuum_schema_instance::build_instance_from_file(&get_schema_for_command(
*version,
"print".into(),
"calibration".into(),
))
.map_err(|err| PrinterError(format!("failed to build calibration request: {err}")))?;
body["option"] = serde_json::Value::from(option);
session.request("print", body).await
}
/// Bambu-only, same reasoning as `get_version` above. Publishes
/// `pushing.pushall`, which - unlike `get_version` - doesn't reply
/// under its own category: it triggers/refreshes the ongoing