Skip to content

Commit

Permalink
feat: register the device profile operation
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Piotrowski <[email protected]>
  • Loading branch information
Ruadhri17 committed Aug 6, 2024
1 parent 9651797 commit a92c04d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/extensions/c8y_mapper_ext/src/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,7 @@ impl CumulocityConverter {
OperationType::FirmwareUpdate => {
self.register_firmware_update_operation(&source)
}
OperationType::DeviceProfile => self.register_device_profile_operation(&source),
OperationType::Custom(c8y_op_name) => {
self.register_custom_operation(&source, c8y_op_name)
}
Expand Down
21 changes: 21 additions & 0 deletions crates/extensions/c8y_mapper_ext/src/operations/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,25 @@ impl CumulocityConverter {
MqttMessage::new(&topic, request.to_json()).with_retain()
])
}

/// Converts a device_profile metadata message to supported operation "c8y_DeviceProfile"
pub fn register_device_profile_operation(
&mut self,
topic_id: &EntityTopicId,
) -> Result<Vec<MqttMessage>, ConversionError> {
if !self.config.capabilities.device_profile {
warn!("Received device_profile metadata, however, device_profile feature is disabled");
return Ok(vec![]);
}

match self.register_operation(topic_id, "c8y_DeviceProfile") {
Err(err) => {
error!(
"Failed to register `device_profile` operation for {topic_id} due to: {err}"
);
Ok(vec![])
}
Ok(messages) => Ok(messages),
}
}
}

0 comments on commit a92c04d

Please sign in to comment.