Bugfix: two separate failsafe instances were used

This commit is contained in:
ivmarkov 2023-04-25 20:23:17 +00:00
parent 875ac697ad
commit b4f92b0063
2 changed files with 10 additions and 10 deletions

View file

@ -30,7 +30,7 @@ use super::{
pub type RootEndpointHandler<'a> = handler_chain_type!( pub type RootEndpointHandler<'a> = handler_chain_type!(
DescriptorCluster, DescriptorCluster,
BasicInfoCluster<'a>, BasicInfoCluster<'a>,
GenCommCluster, GenCommCluster<'a>,
NwCommCluster, NwCommCluster,
AdminCommCluster<'a>, AdminCommCluster<'a>,
NocCluster<'a>, NocCluster<'a>,
@ -107,7 +107,7 @@ pub fn wrap<'a>(
.chain( .chain(
endpoint_id, endpoint_id,
general_commissioning::ID, general_commissioning::ID,
GenCommCluster::new(rand), GenCommCluster::new(failsafe, rand),
) )
.chain( .chain(
endpoint_id, endpoint_id,

View file

@ -121,17 +121,17 @@ struct FailSafeParams {
bread_crumb: u8, bread_crumb: u8,
} }
pub struct GenCommCluster { pub struct GenCommCluster<'a> {
data_ver: Dataver, data_ver: Dataver,
expiry_len: u16, expiry_len: u16,
failsafe: RefCell<FailSafe>, failsafe: &'a RefCell<FailSafe>,
} }
impl GenCommCluster { impl<'a> GenCommCluster<'a> {
pub fn new(rand: Rand) -> Self { pub fn new(failsafe: &'a RefCell<FailSafe>, rand: Rand) -> Self {
Self { Self {
data_ver: Dataver::new(rand), data_ver: Dataver::new(rand),
failsafe: RefCell::new(FailSafe::new()), failsafe,
// TODO: Arch-Specific // TODO: Arch-Specific
expiry_len: 120, expiry_len: 120,
} }
@ -291,7 +291,7 @@ impl GenCommCluster {
} }
} }
impl Handler for GenCommCluster { impl<'a> Handler for GenCommCluster<'a> {
fn read(&self, attr: &AttrDetails, encoder: AttrDataEncoder) -> Result<(), Error> { fn read(&self, attr: &AttrDetails, encoder: AttrDataEncoder) -> Result<(), Error> {
GenCommCluster::read(self, attr, encoder) GenCommCluster::read(self, attr, encoder)
} }
@ -307,9 +307,9 @@ impl Handler for GenCommCluster {
} }
} }
impl NonBlockingHandler for GenCommCluster {} impl<'a> NonBlockingHandler for GenCommCluster<'a> {}
impl ChangeNotifier<()> for GenCommCluster { impl<'a> ChangeNotifier<()> for GenCommCluster<'a> {
fn consume_change(&mut self) -> Option<()> { fn consume_change(&mut self) -> Option<()> {
self.data_ver.consume_change(()) self.data_ver.consume_change(())
} }