Skip to content

Commit fabfc4e

Browse files
authored
add bambu status enums (#125)
1 parent f9e685c commit fabfc4e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/bambu/control.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,20 @@ impl ControlTrait for X1Carbon {
7676
}
7777

7878
async fn state(&self) -> Result<MachineState> {
79-
Ok(MachineState::Unknown)
79+
let Some(status) = self.client.get_status()? else {
80+
return Ok(MachineState::Unknown);
81+
};
82+
83+
Ok(match status.gcode_state.unwrap_or("".to_owned()).as_str() {
84+
"RUNNING" => MachineState::Running,
85+
"FINISH" => MachineState::Complete,
86+
"IDLE" => MachineState::Idle,
87+
"FAILED" => MachineState::Failed(None),
88+
v => {
89+
tracing::warn!("unknown state: {}", v);
90+
MachineState::Unknown
91+
}
92+
})
8093
}
8194
}
8295

0 commit comments

Comments
 (0)