4141#![ recursion_limit = "256" ]
4242
4343use core:: future:: Future ;
44- use core:: mem:: { size_of_val, MaybeUninit } ;
44+ use core:: mem:: size_of_val;
45+ #[ cfg( target_os = "none" ) ]
46+ use core:: mem:: MaybeUninit ;
4547
4648// Logging - `defmt` for embedded targets, `log` for others
4749#[ cfg( target_os = "none" ) ]
@@ -69,20 +71,18 @@ use rs_matter::dm::clusters::wifi_diag::{
6971use rs_matter:: dm:: devices:: test:: { DAC_PRIVKEY , TEST_DEV_ATT , TEST_DEV_COMM , TEST_DEV_DET } ;
7072use rs_matter:: dm:: devices:: DEV_TYPE_ON_OFF_LIGHT ;
7173use rs_matter:: dm:: endpoints:: WifiSysHandler ;
72- use rs_matter:: dm:: events:: DEFAULT_MAX_EVENTS_BUF_SIZE ;
7374use rs_matter:: dm:: networks:: wireless:: {
7475 NetCtlState , NetCtlStateMutex , NetCtlWithStatusImpl , WifiNetworks ,
7576} ;
7677use rs_matter:: dm:: networks:: NetChangeNotif ;
77- use rs_matter:: dm:: subscriptions:: DEFAULT_MAX_SUBSCRIPTIONS ;
7878use rs_matter:: dm:: { endpoints, IMBuffer } ;
7979use rs_matter:: dm:: {
8080 Async , DataModel , Dataver , Endpoint , EpClMatcher , Node , WirelessDataModelState ,
8181} ;
8282use rs_matter:: error:: Error ;
8383use rs_matter:: pairing:: qr:: QrTextType ;
8484use rs_matter:: pairing:: DiscoveryCapabilities ;
85- use rs_matter:: persist:: { DummyKvBlobStore , SharedKvBlobStore } ;
85+ use rs_matter:: persist:: { DummyKvBlobStore , SharedKvBlobStore , DEFAULT_KV_BUF_SIZE } ;
8686use rs_matter:: respond:: DefaultResponder ;
8787use rs_matter:: sc:: pase:: MAX_COMM_WINDOW_TIMEOUT_SECS ;
8888use rs_matter:: tlv:: Nullable ;
@@ -162,8 +162,6 @@ struct MatterStack<'a> {
162162 state : WirelessDataModelState < WifiNetworks < 3 > > ,
163163 net_ctl_state : NetCtlStateMutex ,
164164 btp : Btp ,
165- // We don't run a persistence task, but emulate its typical memory consumnption
166- psm_buffer : MaybeUninit < [ u8 ; 4096 ] > ,
167165}
168166
169167impl < ' a > MatterStack < ' a > {
@@ -180,7 +178,6 @@ impl<'a> MatterStack<'a> {
180178 state <- WirelessDataModelState :: init( WifiNetworks :: init( ) ) ,
181179 net_ctl_state <- NetCtlState :: init_with_mutex( ) ,
182180 btp <- Btp :: init( ) ,
183- psm_buffer: MaybeUninit :: zeroed( ) ,
184181 } )
185182 }
186183}
@@ -198,24 +195,20 @@ type AppDmHandler<'a> = handler_chain_type!(
198195type AppCrypto = RustCrypto < ' static , WeakTestOnlyRand > ;
199196type AppDataModel < ' a > = DataModel <
200197 ' a ,
201- DEFAULT_MAX_SUBSCRIPTIONS ,
202- DEFAULT_MAX_EVENTS_BUF_SIZE ,
203198 & ' a AppCrypto ,
204199 PooledBuffers < 10 , IMBuffer > ,
205200 ( Node < ' a > , & ' a AppDmHandler < ' a > ) ,
206- SharedKvBlobStore < DummyKvBlobStore , & ' static mut [ u8 ] > ,
201+ DummyKvBlobStore ,
207202 WifiNetworks < 3 > ,
208203 & ' a AppNetCtl < ' a > ,
209204> ;
210205type AppResponder < ' d , ' a > = DefaultResponder <
211206 ' d ,
212207 ' a ,
213- DEFAULT_MAX_SUBSCRIPTIONS ,
214- DEFAULT_MAX_EVENTS_BUF_SIZE ,
215208 & ' a AppCrypto ,
216209 PooledBuffers < 10 , IMBuffer > ,
217210 ( Node < ' a > , & ' a AppDmHandler < ' a > ) ,
218- SharedKvBlobStore < DummyKvBlobStore , & ' static mut [ u8 ] > ,
211+ DummyKvBlobStore ,
219212 WifiNetworks < 3 > ,
220213 & ' a AppNetCtl < ' a > ,
221214> ;
@@ -289,11 +282,10 @@ fn main() -> ! {
289282 & mut stack_total,
290283 ) ;
291284 report_size ( "BTP" , size_of_val ( & stack. btp ) , & mut stack_total) ;
292- report_size (
293- "Persister buffer" ,
294- size_of_val ( & stack. psm_buffer ) ,
295- & mut stack_total,
296- ) ;
285+ // The KV/persister scratch buffer now lives inside `DataModelState` (behind a
286+ // blocking mutex) rather than in the `SharedKvBlobStore`. It is not visible
287+ // through the per-component accessors above, so account for it explicitly.
288+ report_size ( "KV scratch buffer" , DEFAULT_KV_BUF_SIZE , & mut stack_total) ;
297289
298290 report_subtotal_size ( "TOTAL MATTER STACK " , stack_total) ;
299291
@@ -322,8 +314,9 @@ fn main() -> ! {
322314
323315 let mut rand = unwrap ! ( crypto. weak_rand( ) ) ;
324316
325- let kv_buf = unsafe { stack. psm_buffer . assume_init_mut ( ) } . as_mut_slice ( ) ;
326- let kv = SharedKvBlobStore :: new ( DummyKvBlobStore , kv_buf) ;
317+ // The KV scratch buffer now lives inside `DataModelState` (see the "KV scratch
318+ // buffer" line in the memory report); the store itself is buffer-less.
319+ let kv = SharedKvBlobStore :: new ( DummyKvBlobStore ) ;
327320
328321 // A Wireless handler with a sample app cluster (on-off)
329322 let handler = mk_static ! (
0 commit comments