@@ -64,9 +64,6 @@ The [`esp-idf-matter`](https://github.com/ivmarkov/esp-idf-matter) crate provide
6464
6565use core :: pin :: pin;
6666
67- use embassy_futures :: select :: select;
68- use embassy_time :: {Duration , Timer };
69-
7067use env_logger :: Target ;
7168use log :: info;
7269
@@ -83,7 +80,6 @@ use rs_matter_stack::matter::dm::{Async, Dataver, Endpoint, Node};
8380use rs_matter_stack :: matter :: dm :: {EmptyHandler , EpClMatcher };
8481use rs_matter_stack :: matter :: error :: Error ;
8582use rs_matter_stack :: matter :: utils :: init :: InitMaybeUninit ;
86- use rs_matter_stack :: matter :: utils :: select :: Coalesce ;
8783use rs_matter_stack :: matter :: {clusters, devices};
8884use rs_matter_stack :: mdns :: ZeroconfMdns ;
8985use rs_matter_stack :: persist :: DirKvBlobStore ;
@@ -112,11 +108,11 @@ fn main() -> Result<(), Error> {
112108 ));
113109
114110 // Our "light" on-off cluster.
115- // Can be anything implementing `rs_matter::dm::AsyncHandler`
111+ // It will toggle the light state every 5 seconds
116112 let on_off = on_off :: OnOffHandler :: new_standalone (
117113 Dataver :: new_rand (stack . matter (). rand ()),
118114 LIGHT_ENDPOINT_ID ,
119- TestOnOffDeviceLogic :: new (),
115+ TestOnOffDeviceLogic :: new (true ),
120116 );
121117
122118 // Chain our endpoint clusters with the
@@ -139,7 +135,7 @@ fn main() -> Result<(), Error> {
139135 // Run the Matter stack with our handler
140136 // Using `pin!` is completely optional, but reduces the size of the final future
141137 let store = stack . create_shared_store (DirKvBlobStore :: new_default ());
142- let mut matter = pin! (stack . run_preex (
138+ let matter = pin! (stack . run_preex (
143139 // The Matter stack needs UDP sockets to communicate with other Matter devices
144140 edge_nal_std :: Stack :: new (),
145141 // Will try to find a default network interface
@@ -154,29 +150,8 @@ fn main() -> Result<(), Error> {
154150 (),
155151 ));
156152
157- // Just for demoing purposes:
158- //
159- // Run a sample loop that simulates state changes triggered by the HAL
160- // Changes will be properly communicated to the Matter controllers
161- // (i.e. Google Home, Alexa) and other Matter devices thanks to subscriptions
162- let mut device = pin! (async {
163- loop {
164- // Simulate user toggling the light with a physical switch every 5 seconds
165- Timer :: after (Duration :: from_secs (5 )). await ;
166-
167- // Toggle
168- on_off . set_on_off (! on_off . on_off ());
169-
170- // Let the Matter stack know that we have changed
171- // the state of our Light device
172- stack . notify_cluster_changed (1 , TestOnOffDeviceLogic :: CLUSTER . id);
173-
174- info! (" Light toggled" );
175- }
176- });
177-
178- // Schedule the Matter run & the device loop together
179- futures_lite :: future :: block_on (select (& mut matter , & mut device ). coalesce ())
153+ // Schedule the Matter run
154+ futures_lite :: future :: block_on (matter )
180155}
181156
182157/// The Matter stack is allocated statically to avoid
0 commit comments