diff --git a/matter/src/interaction_model/command.rs b/matter/src/interaction_model/command.rs index f6e298d..4867ac9 100644 --- a/matter/src/interaction_model/command.rs +++ b/matter/src/interaction_model/command.rs @@ -60,7 +60,7 @@ impl InteractionModel { let root = get_root_node_struct(rx_buf)?; let inv_req = InvReq::from_tlv(&root)?; - let timed_tx = trans.exch.get_expiry_ts().map(|_| true); + let timed_tx = trans.get_timeout().map(|_| true); let timed_request = inv_req.timed_request.filter(|a| *a == true); // Either both should be None, or both should be Some(true) if timed_tx != timed_request { diff --git a/matter/src/interaction_model/core.rs b/matter/src/interaction_model/core.rs index bb13588..bc22385 100644 --- a/matter/src/interaction_model/core.rs +++ b/matter/src/interaction_model/core.rs @@ -78,11 +78,15 @@ impl<'a> Transaction<'a> { pub fn set_timeout(&mut self, timeout: u64) { self.exch - .set_expiry_ts(SystemTime::now().checked_add(Duration::from_millis(timeout))); + .set_data_time(SystemTime::now().checked_add(Duration::from_millis(timeout))); + } + + pub fn get_timeout(&mut self) -> Option { + self.exch.get_data_time() } pub fn has_timed_out(&self) -> bool { - if let Some(timeout) = self.exch.get_expiry_ts() { + if let Some(timeout) = self.exch.get_data_time() { if SystemTime::now() > timeout { return true; } diff --git a/matter/src/secure_channel/case.rs b/matter/src/secure_channel/case.rs index 309b414..75d1fc9 100644 --- a/matter/src/secure_channel/case.rs +++ b/matter/src/secure_channel/case.rs @@ -82,7 +82,7 @@ impl Case { let mut case_session = ctx .exch_ctx .exch - .take_exchange_data::() + .take_data_boxed::() .ok_or(Error::InvalidState)?; if case_session.state != State::Sigma1Rx { return Err(Error::Invalid); @@ -171,7 +171,7 @@ impl Case { SCStatusCodes::SessionEstablishmentSuccess, None, )?; - ctx.exch_ctx.exch.clear_exchange_data(); + ctx.exch_ctx.exch.clear_data_boxed(); ctx.exch_ctx.exch.close(); Ok(()) @@ -269,7 +269,7 @@ impl Case { tw.str16(TagType::Context(4), encrypted)?; tw.end_container()?; case_session.tt_hash.update(ctx.tx.as_borrow_slice())?; - ctx.exch_ctx.exch.set_exchange_data(case_session); + ctx.exch_ctx.exch.set_data_boxed(case_session); Ok(()) } diff --git a/matter/src/transport/exchange.rs b/matter/src/transport/exchange.rs index ea8690c..191c3e4 100644 --- a/matter/src/transport/exchange.rs +++ b/matter/src/transport/exchange.rs @@ -129,15 +129,15 @@ impl Exchange { } } - pub fn set_exchange_data(&mut self, data: Box) { + pub fn set_data_boxed(&mut self, data: Box) { self.data = DataOption::Boxed(data); } - pub fn clear_exchange_data(&mut self) { + pub fn clear_data_boxed(&mut self) { self.data = DataOption::None; } - pub fn get_exchange_data(&mut self) -> Option<&mut T> { + pub fn get_data_boxed(&mut self) -> Option<&mut T> { if let DataOption::Boxed(a) = &mut self.data { a.downcast_mut::() } else { @@ -145,7 +145,7 @@ impl Exchange { } } - pub fn take_exchange_data(&mut self) -> Option> { + pub fn take_data_boxed(&mut self) -> Option> { let old = std::mem::replace(&mut self.data, DataOption::None); match old { DataOption::Boxed(d) => d.downcast::().ok(), @@ -156,13 +156,13 @@ impl Exchange { } } - pub fn set_expiry_ts(&mut self, expiry_ts: Option) { + pub fn set_data_time(&mut self, expiry_ts: Option) { if let Some(t) = expiry_ts { self.data = DataOption::Time(t); } } - pub fn get_expiry_ts(&self) -> Option { + pub fn get_data_time(&self) -> Option { match self.data { DataOption::Time(t) => Some(t), _ => None,