diff options
Diffstat (limited to 'crates/core/tedge_mapper/src/c8y_converter.rs')
-rw-r--r-- | crates/core/tedge_mapper/src/c8y_converter.rs | 17 |
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> { |