Skip to content

Commit f55d3b3

Browse files
committed
updates
Signed-off-by: Jess Frazelle <[email protected]>
1 parent 3572c6c commit f55d3b3

File tree

6 files changed

+174
-71
lines changed

6 files changed

+174
-71
lines changed

bambulabs/src/message.rs

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl Message {
3434
pub fn sequence_id(&self) -> Option<SequenceId> {
3535
match self {
3636
Message::Print(print) => Some(print.sequence_id()),
37-
Message::Info(info) => Some(info.sequence_id.clone()),
37+
Message::Info(info) => Some(info.sequence_id()),
3838
Message::System(system) => Some(system.sequence_id()),
3939
Message::Json(_) | Message::Unknown(_) => None,
4040
}
@@ -205,10 +205,16 @@ pub struct ExtrusionCaliGet {
205205
pub struct PushStatus {
206206
/// The sequence id.
207207
pub sequence_id: SequenceId,
208+
/// The aux part fan.
209+
pub aux_part_fan: Option<bool>,
208210
/// The upload.
209211
pub upload: Option<PrintUpload>,
212+
/// The nozzle diameter.
213+
pub nozzle_diameter: Option<String>,
210214
/// The nozzle temperature.
211215
pub nozzle_temper: Option<f64>,
216+
/// The nozzle type.
217+
pub nozzle_type: Option<NozzleType>,
212218
/// The target nozzle temperature.
213219
pub nozzle_target_temper: Option<f64>,
214220
/// The bed temperature.
@@ -326,6 +332,8 @@ pub struct PrintUpload {
326332
pub progress: i64,
327333
/// The message.
328334
pub message: String,
335+
#[serde(flatten)]
336+
other: BTreeMap<String, Value>,
329337
}
330338

331339
/// The print online.
@@ -337,6 +345,8 @@ pub struct PrintOnline {
337345
pub rfid: Option<bool>,
338346
/// The version.
339347
pub version: i64,
348+
#[serde(flatten)]
349+
other: BTreeMap<String, Value>,
340350
}
341351

342352
/// The print ams.
@@ -366,6 +376,8 @@ pub struct PrintAms {
366376
pub insert_flag: Option<bool>,
367377
/// The power on flag.
368378
pub power_on_flag: Option<bool>,
379+
#[serde(flatten)]
380+
other: BTreeMap<String, Value>,
369381
}
370382

371383
/// The print ams data.
@@ -379,6 +391,8 @@ pub struct PrintAmsData {
379391
pub temp: String,
380392
/// The tray.
381393
pub tray: Vec<PrintTray>,
394+
#[serde(flatten)]
395+
other: BTreeMap<String, Value>,
382396
}
383397

384398
/// The print tray.
@@ -424,6 +438,8 @@ pub struct PrintTray {
424438
pub k: Option<f64>,
425439
/// The tray n.
426440
pub n: Option<i64>,
441+
#[serde(flatten)]
442+
other: BTreeMap<String, Value>,
427443
}
428444

429445
/// The print ipcam.
@@ -437,15 +453,19 @@ pub struct PrintIpcam {
437453
pub timelapse: Option<String>,
438454
/// The mode bits.
439455
pub mode_bits: Option<i64>,
456+
#[serde(flatten)]
457+
other: BTreeMap<String, Value>,
440458
}
441459

442460
/// A print lights report.
443461
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
444462
pub struct PrintLightsReport {
445463
/// The node.
446-
pub node: String,
464+
pub node: LedNode,
447465
/// The mode.
448-
pub mode: String,
466+
pub mode: LedMode,
467+
#[serde(flatten)]
468+
other: BTreeMap<String, Value>,
449469
}
450470

451471
/// A print upgrade state.
@@ -473,34 +493,42 @@ pub struct PrintUpgradeState {
473493
pub new_version_state: Option<i64>,
474494
/// The new version list.
475495
pub new_ver_list: Option<Vec<Value>>,
496+
#[serde(flatten)]
497+
other: BTreeMap<String, Value>,
498+
}
499+
500+
/// An info command.
501+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
502+
#[serde(rename_all = "snake_case", tag = "command")]
503+
pub enum Info {
504+
/// Get the version.
505+
GetVersion(GetVersion),
506+
}
507+
508+
impl Info {
509+
/// Returns the sequence id of the message.
510+
pub fn sequence_id(&self) -> SequenceId {
511+
match self {
512+
Info::GetVersion(get_version) => get_version.sequence_id.clone(),
513+
}
514+
}
476515
}
477516

478-
/// A info message.
517+
/// A get version message.
479518
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
480-
pub struct Info {
519+
pub struct GetVersion {
481520
/// The sequence id.
482521
pub sequence_id: SequenceId,
483-
/// The info command.
484-
pub command: InfoCommand,
485522
/// The info module.
486523
pub module: Vec<InfoModule>,
487524
/// The result of the info command.
488-
pub result: Option<String>,
525+
pub result: Result,
489526
/// The reason of the info command.
490-
pub reason: Option<String>,
527+
pub reason: Option<Reason>,
491528
#[serde(flatten)]
492529
other: BTreeMap<String, Value>,
493530
}
494531

495-
/// An info command.
496-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
497-
#[serde(rename_all = "snake_case")]
498-
#[display(style = "snake_case")]
499-
pub enum InfoCommand {
500-
/// Get the version.
501-
GetVersion,
502-
}
503-
504532
/// An info module.
505533
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
506534
pub struct InfoModule {

openapi/api.json

Lines changed: 86 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -45,59 +45,58 @@
4545
"type": "object"
4646
},
4747
"Info": {
48-
"additionalProperties": true,
49-
"description": "A info message.",
50-
"properties": {
51-
"command": {
52-
"allOf": [
53-
{
54-
"$ref": "#/components/schemas/InfoCommand"
55-
}
56-
],
57-
"description": "The info command."
58-
},
59-
"module": {
60-
"description": "The info module.",
61-
"items": {
62-
"$ref": "#/components/schemas/InfoModule"
63-
},
64-
"type": "array"
65-
},
66-
"reason": {
67-
"description": "The reason of the info command.",
68-
"nullable": true,
69-
"type": "string"
70-
},
71-
"result": {
72-
"description": "The result of the info command.",
73-
"nullable": true,
74-
"type": "string"
75-
},
76-
"sequence_id": {
77-
"allOf": [
78-
{
79-
"$ref": "#/components/schemas/SequenceId"
80-
}
81-
],
82-
"description": "The sequence id."
83-
}
84-
},
85-
"required": [
86-
"command",
87-
"module",
88-
"sequence_id"
89-
],
90-
"type": "object"
91-
},
92-
"InfoCommand": {
9348
"description": "An info command.",
9449
"oneOf": [
9550
{
51+
"additionalProperties": true,
9652
"description": "Get the version.",
97-
"enum": [
98-
"get_version"
53+
"properties": {
54+
"command": {
55+
"enum": [
56+
"get_version"
57+
],
58+
"type": "string"
59+
},
60+
"module": {
61+
"description": "The info module.",
62+
"items": {
63+
"$ref": "#/components/schemas/InfoModule"
64+
},
65+
"type": "array"
66+
},
67+
"reason": {
68+
"allOf": [
69+
{
70+
"$ref": "#/components/schemas/Reason"
71+
}
72+
],
73+
"description": "The reason of the info command.",
74+
"nullable": true
75+
},
76+
"result": {
77+
"allOf": [
78+
{
79+
"$ref": "#/components/schemas/Result"
80+
}
81+
],
82+
"description": "The result of the info command."
83+
},
84+
"sequence_id": {
85+
"allOf": [
86+
{
87+
"$ref": "#/components/schemas/SequenceId"
88+
}
89+
],
90+
"description": "The sequence id."
91+
}
92+
},
93+
"required": [
94+
"command",
95+
"module",
96+
"result",
97+
"sequence_id"
9998
],
100-
"type": "string"
99+
"type": "object"
101100
}
102101
]
103102
},
@@ -490,6 +489,11 @@
490489
"nullable": true,
491490
"type": "integer"
492491
},
492+
"aux_part_fan": {
493+
"description": "The aux part fan.",
494+
"nullable": true,
495+
"type": "boolean"
496+
},
493497
"bed_target_temper": {
494498
"description": "The target bed temperature.",
495499
"format": "double",
@@ -645,6 +649,11 @@
645649
"nullable": true,
646650
"type": "integer"
647651
},
652+
"nozzle_diameter": {
653+
"description": "The nozzle diameter.",
654+
"nullable": true,
655+
"type": "string"
656+
},
648657
"nozzle_target_temper": {
649658
"description": "The target nozzle temperature.",
650659
"format": "double",
@@ -657,6 +666,15 @@
657666
"nullable": true,
658667
"type": "number"
659668
},
669+
"nozzle_type": {
670+
"allOf": [
671+
{
672+
"$ref": "#/components/schemas/NozzleType"
673+
}
674+
],
675+
"description": "The nozzle type.",
676+
"nullable": true
677+
},
660678
"online": {
661679
"allOf": [
662680
{
@@ -1038,6 +1056,7 @@
10381056
]
10391057
},
10401058
"PrintAms": {
1059+
"additionalProperties": true,
10411060
"description": "The print ams.",
10421061
"properties": {
10431062
"ams": {
@@ -1108,6 +1127,7 @@
11081127
"type": "object"
11091128
},
11101129
"PrintAmsData": {
1130+
"additionalProperties": true,
11111131
"description": "The print ams data.",
11121132
"properties": {
11131133
"humidity": {
@@ -1139,6 +1159,7 @@
11391159
"type": "object"
11401160
},
11411161
"PrintIpcam": {
1162+
"additionalProperties": true,
11421163
"description": "The print ipcam.",
11431164
"properties": {
11441165
"ipcam_dev": {
@@ -1188,15 +1209,24 @@
11881209
"type": "object"
11891210
},
11901211
"PrintLightsReport": {
1212+
"additionalProperties": true,
11911213
"description": "A print lights report.",
11921214
"properties": {
11931215
"mode": {
1194-
"description": "The mode.",
1195-
"type": "string"
1216+
"allOf": [
1217+
{
1218+
"$ref": "#/components/schemas/LedMode"
1219+
}
1220+
],
1221+
"description": "The mode."
11961222
},
11971223
"node": {
1198-
"description": "The node.",
1199-
"type": "string"
1224+
"allOf": [
1225+
{
1226+
"$ref": "#/components/schemas/LedNode"
1227+
}
1228+
],
1229+
"description": "The node."
12001230
}
12011231
},
12021232
"required": [
@@ -1206,6 +1236,7 @@
12061236
"type": "object"
12071237
},
12081238
"PrintOnline": {
1239+
"additionalProperties": true,
12091240
"description": "The print online.",
12101241
"properties": {
12111242
"ahb": {
@@ -1248,6 +1279,7 @@
12481279
"type": "object"
12491280
},
12501281
"PrintTray": {
1282+
"additionalProperties": true,
12511283
"description": "The print tray.",
12521284
"properties": {
12531285
"bed_temp": {
@@ -1359,6 +1391,7 @@
13591391
"type": "object"
13601392
},
13611393
"PrintUpgradeState": {
1394+
"additionalProperties": true,
13621395
"description": "A print upgrade state.",
13631396
"properties": {
13641397
"consistency_request": {
@@ -1425,6 +1458,7 @@
14251458
"type": "object"
14261459
},
14271460
"PrintUpload": {
1461+
"additionalProperties": true,
14281462
"description": "The print upload.",
14291463
"properties": {
14301464
"message": {

0 commit comments

Comments
 (0)