diff --git a/matter/src/core.rs b/matter/src/core.rs index 0b555cc..24e90cf 100644 --- a/matter/src/core.rs +++ b/matter/src/core.rs @@ -54,6 +54,14 @@ pub struct Matter<'a> { } impl<'a> Matter<'a> { + #[cfg(feature = "std")] + pub fn new_default(dev_det: &'a BasicInfoConfig, mdns: &'a mut dyn Mdns) -> Self { + use crate::utils::epoch::{sys_epoch, sys_utc_calendar}; + use crate::utils::rand::sys_rand; + + Self::new(dev_det, mdns, sys_epoch, sys_rand, sys_utc_calendar) + } + /// Creates a new Matter object /// /// # Parameters diff --git a/matter/src/transport/mgr.rs b/matter/src/transport/mgr.rs index 1d68f34..16925b2 100644 --- a/matter/src/transport/mgr.rs +++ b/matter/src/transport/mgr.rs @@ -191,18 +191,18 @@ impl<'a> TransportMgr<'a> { pub fn new< T: Borrow> + Borrow> + + Borrow>> + Borrow + Borrow + Borrow, >( matter: &'a T, - mdns_mgr: &'a RefCell>, ) -> Self { Self::wrap( SecureChannel::new( matter.borrow(), matter.borrow(), - mdns_mgr, + matter.borrow(), *matter.borrow(), *matter.borrow(), ), diff --git a/matter/src/utils/rand.rs b/matter/src/utils/rand.rs index 3cd698c..59a8972 100644 --- a/matter/src/utils/rand.rs +++ b/matter/src/utils/rand.rs @@ -1,3 +1,10 @@ pub type Rand = fn(&mut [u8]); pub fn dummy_rand(_buf: &mut [u8]) {} + +#[cfg(feature = "std")] +pub fn sys_rand(buf: &mut [u8]) { + use rand::{thread_rng, RngCore}; + + thread_rng().fill_bytes(buf); +}