From 759ed3e44b5be24757e90994588cb64e0f7a934f Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Fri, 17 Nov 2023 18:59:54 +0530 Subject: [PATCH] feat: marker to describe how to respond to action --- uplink/src/base/actions.rs | 3 +++ uplink/src/base/mqtt/mod.rs | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/uplink/src/base/actions.rs b/uplink/src/base/actions.rs index 047950bf..229339e5 100644 --- a/uplink/src/base/actions.rs +++ b/uplink/src/base/actions.rs @@ -22,6 +22,9 @@ pub struct Action { // Instant at which action must be timedout #[serde(skip)] pub deadline: Option, + // Marker that action was received through newer action topic and must be responded to on similarly named topic + #[serde(skip)] + pub new_topic: bool, } #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/uplink/src/base/mqtt/mod.rs b/uplink/src/base/mqtt/mod.rs index 48cda503..4f158659 100644 --- a/uplink/src/base/mqtt/mod.rs +++ b/uplink/src/base/mqtt/mod.rs @@ -150,11 +150,13 @@ impl Mqtt { return Ok(()); } + let mut action: Action = serde_json::from_slice(&publish.payload)?; + if self.config.actions_subscription != publish.topic { // Set a marker in recevied action for later use + action.new_topic = true; } - let action: Action = serde_json::from_slice(&publish.payload)?; info!("Action = {:?}", action); self.native_actions_tx.try_send(action)?;