@@ -54,7 +54,8 @@ mod example {
5454
5555 use esp_idf_matter :: init_async_io;
5656 use esp_idf_matter :: matter :: dm :: clusters :: desc :: {self , ClusterHandler as _, DescHandler };
57- use esp_idf_matter :: matter :: dm :: clusters :: on_off :: {ClusterHandler as _, OnOffHandler };
57+ use esp_idf_matter :: matter :: dm :: clusters :: on_off :: test :: TestOnOffDeviceLogic ;
58+ use esp_idf_matter :: matter :: dm :: clusters :: on_off :: {self , OnOffHandler , OnOffHooks };
5859 use esp_idf_matter :: matter :: dm :: devices :: test :: {TEST_DEV_ATT , TEST_DEV_COMM , TEST_DEV_DET };
5960 use esp_idf_matter :: matter :: dm :: devices :: DEV_TYPE_ON_OFF_LIGHT ;
6061 use esp_idf_matter :: matter :: dm :: {Async , Dataver , EmptyHandler , Endpoint , EpClMatcher , Node };
@@ -140,16 +141,23 @@ mod example {
140141 reduce_bt_memory (unsafe { peripherals . modem. reborrow () })? ;
141142
142143 // Our "light" on-off handler.
143- // Can be anything implementing `Handler` or `AsyncHandler`
144- let on_off = OnOffHandler :: new (Dataver :: new_rand (stack . matter (). rand ())). adapt ();
144+ // Can be anything implementing `rs_matter::dm::AsyncHandler`
145+ let on_off = OnOffHandler :: new_standalone (
146+ Dataver :: new_rand (stack . matter (). rand ()),
147+ 1 ,
148+ TestOnOffDeviceLogic :: new (),
149+ );
145150
146151 // Chain our endpoint clusters with the
147152 // (root) Endpoint 0 system clusters in the final handler
148153 let handler = EmptyHandler
149154 // Our on-off cluster, on Endpoint 1
150155 . chain (
151- EpClMatcher :: new (Some (LIGHT_ENDPOINT_ID ), Some (OnOffHandler :: CLUSTER . id)),
152- Async (& on_off ),
156+ EpClMatcher :: new (
157+ Some (LIGHT_ENDPOINT_ID ),
158+ Some (TestOnOffDeviceLogic :: CLUSTER . id),
159+ ),
160+ on_off :: HandlerAsyncAdaptor (& on_off ),
153161 )
154162 // Each Endpoint needs a Descriptor cluster too
155163 // Just use the one that `rs-matter` provides out of the box
@@ -159,8 +167,7 @@ mod example {
159167 );
160168
161169 // Run the Matter stack with our handler
162- // Using `pin!` is completely optional, but saves some memory due to `rustc`
163- // not being very intelligent w.r.t. stack usage in async functions
170+ // Using `pin!` is completely optional, but reduces the size of the final future
164171 //
165172 // NOTE: When testing initially, use the `DummyKVBlobStore` to make sure device
166173 // commissioning works fine with your controller. Once you confirm, you can enable
@@ -189,11 +196,11 @@ mod example {
189196 Timer :: after (Duration :: from_secs (5 )). await ;
190197
191198 // Toggle
192- on_off . 0. set (! on_off . 0. get ());
199+ on_off . set_on_off (! on_off . on_off ());
193200
194201 // Let the Matter stack know that we have changed
195202 // the state of our Light device
196- stack . notify_changed ( );
203+ stack . notify_cluster_changed ( 1 , TestOnOffDeviceLogic :: CLUSTER . id );
197204
198205 info! (" Light toggled" );
199206 }
@@ -222,7 +229,7 @@ mod example {
222229 Endpoint {
223230 id : LIGHT_ENDPOINT_ID ,
224231 device_types : devices! (DEV_TYPE_ON_OFF_LIGHT ),
225- clusters : clusters! (DescHandler :: CLUSTER , OnOffHandler :: CLUSTER ),
232+ clusters : clusters! (DescHandler :: CLUSTER , TestOnOffDeviceLogic :: CLUSTER ),
226233 },
227234 ],
228235 };
0 commit comments