summaryrefslogtreecommitdiffstats
path: root/crates/core/tedge_mapper/src/c8y_converter.rs
diff options
context:
space:
mode:
authorLukasz Woznicki <75632179+makr11st@users.noreply.github.com>2021-12-07 21:42:25 +0000
committerGitHub <noreply@github.com>2021-12-07 21:42:25 +0000
commitc2d8195b6a779752ae16628fa0a06d040066bc1c (patch)
treea6001216a3652ae149d0c1ae244712e317a792d1 /crates/core/tedge_mapper/src/c8y_converter.rs
parent13c6cd0195bbcf0ebc917d02d8dea4bf744635a7 (diff)
#596 Declare supported operations (#652)
* Add operations to tedge_mapper * Add operations directory on install, remove supported ops from sm-c8y mapper * Update install command in postinst script to correctly create ops files Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
Diffstat (limited to 'crates/core/tedge_mapper/src/c8y_converter.rs')
-rw-r--r--crates/core/tedge_mapper/src/c8y_converter.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/core/tedge_mapper/src/c8y_converter.rs b/crates/core/tedge_mapper/src/c8y_converter.rs
index f8b9b6c3..a0d7bf6d 100644
--- a/crates/core/tedge_mapper/src/c8y_converter.rs
+++ b/crates/core/tedge_mapper/src/c8y_converter.rs
@@ -1,6 +1,7 @@
-use crate::converter::*;
use crate::error::*;
use crate::size_threshold::SizeThreshold;
+use crate::{converter::*, operations::Operations};
+use c8y_smartrest::smartrest_serializer::{SmartRestSerializer, SmartRestSetSupportedOperations};
use c8y_translator::json;
use mqtt_client::{Message, Topic};
use std::collections::HashSet;
@@ -77,6 +78,20 @@ impl Converter for CumulocityConverter {
}
Ok(vec)
}
+
+ fn try_init_messages(&self) -> Result<Vec<Message>, ConversionError> {
+ let ops = Operations::try_new("/etc/tedge/operations")?;
+ let ops = ops.get_operations_list("c8y");
+
+ if !ops.is_empty() {
+ let ops_msg = SmartRestSetSupportedOperations::new(&ops);
+ let topic = Topic::new_unchecked("c8y/s/us");
+ let msg = Message::new(&topic, ops_msg.to_smartrest()?);
+ Ok(vec![msg])
+ } else {
+ Ok(Vec::new())
+ }
+ }
}
fn get_child_id_from_topic(topic: &str) -> Result<Option<String>, ConversionError> {