@@ -32,7 +32,8 @@ mod example {
3232 use esp_idf_matter:: init_async_io;
3333 use esp_idf_matter:: matter:: dm:: clusters:: desc:: { ClusterHandler as _, DescHandler } ;
3434 use esp_idf_matter:: matter:: dm:: clusters:: gen_diag:: InterfaceTypeEnum ;
35- use esp_idf_matter:: matter:: dm:: clusters:: on_off:: { ClusterHandler as _, OnOffHandler } ;
35+ use esp_idf_matter:: matter:: dm:: clusters:: on_off:: test:: TestOnOffDeviceLogic ;
36+ use esp_idf_matter:: matter:: dm:: clusters:: on_off:: { self , OnOffHandler , OnOffHooks } ;
3637 use esp_idf_matter:: matter:: dm:: devices:: test:: { TEST_DEV_ATT , TEST_DEV_COMM , TEST_DEV_DET } ;
3738 use esp_idf_matter:: matter:: dm:: devices:: DEV_TYPE_ON_OFF_LIGHT ;
3839 use esp_idf_matter:: matter:: dm:: { Async , Dataver , EmptyHandler , Endpoint , EpClMatcher , Node } ;
@@ -140,16 +141,23 @@ mod example {
140141 wifi. wait_netif_up ( ) . await ?;
141142
142143 // Our "light" on-off cluster.
143- // Can be anything implementing `rs_matter::data_model::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
@@ -195,11 +203,11 @@ mod example {
195203 Timer :: after( Duration :: from_secs( 5 ) ) . await ;
196204
197205 // Toggle
198- on_off. 0 . set ( !on_off. 0 . get ( ) ) ;
206+ on_off. set_on_off ( !on_off. on_off ( ) ) ;
199207
200208 // Let the Matter stack know that we have changed
201209 // the state of our Light device
202- stack. notify_changed ( ) ;
210+ stack. notify_cluster_changed ( 1 , TestOnOffDeviceLogic :: CLUSTER . id ) ;
203211
204212 info!( "Light toggled" ) ;
205213 }
@@ -227,7 +235,7 @@ mod example {
227235 Endpoint {
228236 id : LIGHT_ENDPOINT_ID ,
229237 device_types : devices ! ( DEV_TYPE_ON_OFF_LIGHT ) ,
230- clusters : clusters ! ( DescHandler :: CLUSTER , OnOffHandler :: CLUSTER ) ,
238+ clusters : clusters ! ( DescHandler :: CLUSTER , TestOnOffDeviceLogic :: CLUSTER ) ,
231239 } ,
232240 ] ,
233241 } ;
0 commit comments