diff --git a/src/asyncv/attribute/message.rs b/src/asyncv/attribute/message.rs index 022ac5b..6afeaa5 100644 --- a/src/asyncv/attribute/message.rs +++ b/src/asyncv/attribute/message.rs @@ -12,9 +12,16 @@ pub use super::AttributeBuilder; pub type MessageClient = rumqttc::AsyncClient; +pub type AttributeId = u32; + /// Trait to manage an message attribute (MQTT) /// Sync version #[async_trait] pub trait OnMessageHandler: Send + Sync { async fn on_message(&mut self, data: &Bytes); } + +#[async_trait] +pub trait OnMessageBoolean: Send + Sync { + async fn on_message_boolean(&mut self, id: AttributeId, data: bool); +} diff --git a/src/asyncv/attribute/message/boolean/attribute.rs b/src/asyncv/attribute/message/boolean/attribute.rs index dd92154..3cac60a 100644 --- a/src/asyncv/attribute/message/boolean/attribute.rs +++ b/src/asyncv/attribute/message/boolean/attribute.rs @@ -43,16 +43,16 @@ impl AttributeBoolean { /// Set the value of the attribute /// - // pub async fn set(&self, value: bool) -> Result<(), AttributeError> { - // self.inner.lock().await.set(value).await?; - // // let cv = self.inner.lock().await.set_ensure_lock_clone(); - // // cv.with_lock(|mut done| { - // // while !*done { - // // done.wait(); - // // } - // // }); - // // Ok(()) - // } + pub async fn set(&self, value: bool) -> Result<(), AttributeError> { + self.inner.lock().await.set(value).await?; + // let cv = self.inner.lock().await.set_ensure_lock_clone(); + // cv.with_lock(|mut done| { + // while !*done { + // done.wait(); + // } + // }); + Ok(()) + } /// Get the value of the attribute /// diff --git a/src/asyncv/attribute/message/boolean/attribute/inner.rs b/src/asyncv/attribute/message/boolean/attribute/inner.rs index 79a746f..043a8da 100644 --- a/src/asyncv/attribute/message/boolean/attribute/inner.rs +++ b/src/asyncv/attribute/message/boolean/attribute/inner.rs @@ -25,6 +25,7 @@ use monitor::Monitor; /// Inner implementation of the boolean message attribute /// pub struct InnerBoolean { + id: AttributeId, /// Members at the core of each attribute core: MessageCoreMembers, /// Current value of the attribute