Skip to content

Commit

Permalink
fixup! feat: handle state change for device profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruadhri17 committed Aug 5, 2024
1 parent 46b2649 commit e8d03f2
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ impl OperationContext {
match command.status() {
CommandStatus::Executing => Ok(OperationOutcome::Executing),
CommandStatus::Successful => {
let c8y_target_profile = MqttMessage::new(sm_topic, "121,true".to_string()); // Set the target profile as executed

let smartrest_set_operation =
smartrest::smartrest_serializer::succeed_operation_no_payload(
CumulocitySupportedOperations::C8yDeviceProfile,
);
let c8y_notification = MqttMessage::new(sm_topic, smartrest_set_operation);

Ok(OperationOutcome::Finished {
messages: vec![MqttMessage::new(sm_topic, smartrest_set_operation)],
messages: vec![c8y_target_profile, c8y_notification],
})
}
CommandStatus::Failed { reason } => Err(anyhow::anyhow!(reason).into()),
Expand Down Expand Up @@ -1119,6 +1122,8 @@ mod tests {
.await
.expect("Send failed");

// Expect `121` smartrest message on `c8y/s/us`.
assert_received_contains_str(&mut mqtt, [("c8y/s/us", "121,true")]).await;
// Expect `503` smartrest message on `c8y/s/us`.
assert_received_contains_str(&mut mqtt, [("c8y/s/us", "503,c8y_DeviceProfile")]).await;
}
Expand Down

0 comments on commit e8d03f2

Please sign in to comment.