Skip to content

Commit

Permalink
feat: marker to describe how to respond to action
Browse files Browse the repository at this point in the history
  • Loading branch information
Devdutt Shenoi committed Nov 17, 2023
1 parent 5837d02 commit 759ed3e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions uplink/src/base/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ pub struct Action {
// Instant at which action must be timedout
#[serde(skip)]
pub deadline: Option<Instant>,
// 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)]
Expand Down
4 changes: 3 additions & 1 deletion uplink/src/base/mqtt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;

Expand Down

0 comments on commit 759ed3e

Please sign in to comment.