Skip to content

Commit 432a3a7

Browse files
committed
Fix the comments
1 parent 460bccc commit 432a3a7

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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
};

examples/light_eth.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ mod example {
167167
);
168168

169169
// Run the Matter stack with our handler
170-
// Using `pin!` is completely optional, but saves some memory due to `rustc`
171-
// 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
172171
//
173172
// NOTE: When testing initially, use the `DummyKVBlobStore` to make sure device
174173
// commissioning works fine with your controller. Once you confirm, you can enable

examples/light_eth2.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ mod example {
170170
);
171171

172172
// Run the Matter stack with our handler
173-
// Using `pin!` is completely optional, but saves some memory due to `rustc`
174-
// not being very intelligent w.r.t. stack usage in async functions
173+
// Using `pin!` is completely optional, but reduces the size of the final future
175174
//
176175
// NOTE: When testing initially, use the `DummyKVBlobStore` to make sure device
177176
// commissioning works fine with your controller. Once you confirm, you can enable

examples/light_thread.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ mod example {
151151
info!("Handler initialized");
152152

153153
// Run the Matter stack with our handler
154-
// Using `pin!` is completely optional, but saves some memory due to `rustc`
155-
// not being very intelligent w.r.t. stack usage in async functions
154+
// Using `pin!` is completely optional, but reduces the size of the final future
156155
//
157156
// NOTE: When testing initially, use the `DummyKVBlobStore` to make sure device
158157
// commissioning works fine with your controller. Once you confirm, you can enable

examples/light_wifi.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ mod example {
147147
);
148148

149149
// Run the Matter stack with our handler
150-
// Using `pin!` is completely optional, but saves some memory due to `rustc`
151-
// not being very intelligent w.r.t. stack usage in async functions
150+
// Using `pin!` is completely optional, but reduces the size of the final future
152151
//
153152
// NOTE: When testing initially, use the `DummyKVBlobStore` to make sure device
154153
// commissioning works fine with your controller. Once you confirm, you can enable

0 commit comments

Comments
 (0)