Skip to content

Commit

Permalink
Clear the retain message once the operation is done
Browse files Browse the repository at this point in the history
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
  • Loading branch information
didier-wenzek committed Aug 8, 2023
1 parent 6f13c4e commit 8add896
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions crates/extensions/c8y_mapper_ext/src/log_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use tedge_api::messages::LogUploadCmdPayload;
use tedge_api::Jsonify;
use tedge_mqtt_ext::Message;
use tedge_mqtt_ext::MqttMessage;
use tedge_mqtt_ext::QoS;
use tedge_mqtt_ext::TopicFilter;
use tedge_utils::file::create_directory_with_defaults;
use tedge_utils::file::create_file_with_defaults;
Expand Down Expand Up @@ -134,15 +135,23 @@ impl CumulocityConverter {
.to_smartrest()?,
};

vec![Message::new(&smartrest_topic, smartrest_operation_status)]
let c8y_notification = Message::new(&smartrest_topic, smartrest_operation_status);
let clean_operation = Message::new(&message.topic, "")
.with_retain()
.with_qos(QoS::AtLeastOnce);
vec![c8y_notification, clean_operation]
}
CommandStatus::Failed => {
let smartrest_operation_status = SmartRestSetOperationToFailed::new(
CumulocitySupportedOperations::C8yLogFileRequest,
response.reason.clone().unwrap_or_default(),
)
.to_smartrest()?;
vec![Message::new(&smartrest_topic, smartrest_operation_status)]
let c8y_notification = Message::new(&smartrest_topic, smartrest_operation_status);
let clean_operation = Message::new(&message.topic, "")
.with_retain()
.with_qos(QoS::AtLeastOnce);
vec![c8y_notification, clean_operation]
}
_ => {
vec![] // Do nothing as other components might handle those states
Expand Down

0 comments on commit 8add896

Please sign in to comment.