@@ -15,10 +15,11 @@ use embassy_time::{Duration, Timer};
1515
1616use log:: info;
1717
18+ use rs_matter:: dm:: clusters:: on_off:: test:: TestOnOffDeviceLogic ;
19+ use rs_matter:: dm:: clusters:: on_off:: OnOffHooks ;
1820use rs_matter_stack:: matter:: dm:: clusters:: desc:: { ClusterHandler as _, DescHandler } ;
1921use rs_matter_stack:: matter:: dm:: clusters:: net_comm:: NetworkType ;
2022use rs_matter_stack:: matter:: dm:: clusters:: on_off;
21- use rs_matter_stack:: matter:: dm:: clusters:: on_off:: { ClusterHandler as _, OnOffHandler } ;
2223use rs_matter_stack:: matter:: dm:: devices:: test:: { TEST_DEV_ATT , TEST_DEV_COMM , TEST_DEV_DET } ;
2324use rs_matter_stack:: matter:: dm:: devices:: DEV_TYPE_ON_OFF_LIGHT ;
2425use rs_matter_stack:: matter:: dm:: networks:: unix:: UnixNetifs ;
@@ -59,15 +60,22 @@ fn main() -> Result<(), Error> {
5960
6061 // Our "light" on-off cluster.
6162 // Can be anything implementing `rs_matter::dm::AsyncHandler`
62- let on_off = on_off:: OnOffHandler :: new ( Dataver :: new_rand ( stack. matter ( ) . rand ( ) ) ) ;
63+ let on_off = on_off:: OnOffHandler :: new_standalone (
64+ Dataver :: new_rand ( stack. matter ( ) . rand ( ) ) ,
65+ 1 ,
66+ TestOnOffDeviceLogic :: new ( ) ,
67+ ) ;
6368
6469 // Chain our endpoint clusters with the
6570 // (root) Endpoint 0 system clusters in the final handler
6671 let handler = EmptyHandler
6772 // Our on-off cluster, on Endpoint 1
6873 . chain (
69- EpClMatcher :: new ( Some ( LIGHT_ENDPOINT_ID ) , Some ( OnOffHandler :: CLUSTER . id ) ) ,
70- Async ( on_off:: HandlerAdaptor ( & on_off) ) ,
74+ EpClMatcher :: new (
75+ Some ( LIGHT_ENDPOINT_ID ) ,
76+ Some ( TestOnOffDeviceLogic :: CLUSTER . id ) ,
77+ ) ,
78+ on_off:: HandlerAsyncAdaptor ( & on_off) ,
7179 )
7280 // Each Endpoint needs a Descriptor cluster too
7381 // Just use the one that `rs-matter` provides out of the box
@@ -111,11 +119,11 @@ fn main() -> Result<(), Error> {
111119 Timer :: after( Duration :: from_secs( 5 ) ) . await ;
112120
113121 // Toggle
114- on_off. set ( !on_off. get ( ) ) ;
122+ on_off. set_on_off ( !on_off. on_off ( ) ) ;
115123
116124 // Let the Matter stack know that we have changed
117125 // the state of our Light device
118- stack. notify_cluster_changed( 1 , on_off :: OnOffHandler :: CLUSTER . id) ;
126+ stack. notify_cluster_changed( 1 , TestOnOffDeviceLogic :: CLUSTER . id) ;
119127
120128 info!( "Light toggled" ) ;
121129 }
@@ -144,7 +152,7 @@ const NODE: Node = Node {
144152 Endpoint {
145153 id : LIGHT_ENDPOINT_ID ,
146154 device_types : devices ! ( DEV_TYPE_ON_OFF_LIGHT ) ,
147- clusters : clusters ! ( DescHandler :: CLUSTER , OnOffHandler :: CLUSTER ) ,
155+ clusters : clusters ! ( DescHandler :: CLUSTER , TestOnOffDeviceLogic :: CLUSTER ) ,
148156 } ,
149157 ] ,
150158} ;
0 commit comments