Skip to content

Commit ae92331

Browse files
authored
Enable the bump allocator (#19)
1 parent 281d30a commit ae92331

File tree

5 files changed

+65
-32
lines changed

5 files changed

+65
-32
lines changed

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ build-std = ["std", "panic_abort"]
3030
[env]
3131
ESP_IDF_SDKCONFIG_DEFAULTS = ".github/configs/sdkconfig.defaults"
3232
ESP_IDF_VERSION = "v5.5.1"
33+
#MCU = "esp32c6"

examples/light_eth.rs

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

examples/light_eth2.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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};
@@ -143,16 +144,23 @@ mod example {
143144
info!("Thread started");
144145

145146
// Our "light" on-off cluster.
146-
// Can be anything implementing `rs_matter::data_model::AsyncHandler`
147-
let on_off = OnOffHandler::new(Dataver::new_rand(stack.matter().rand())).adapt();
147+
// Can be anything implementing `rs_matter::dm::AsyncHandler`
148+
let on_off = OnOffHandler::new_standalone(
149+
Dataver::new_rand(stack.matter().rand()),
150+
1,
151+
TestOnOffDeviceLogic::new(),
152+
);
148153

149154
// Chain our endpoint clusters with the
150155
// (root) Endpoint 0 system clusters in the final handler
151156
let handler = EmptyHandler
152157
// Our on-off cluster, on Endpoint 1
153158
.chain(
154-
EpClMatcher::new(Some(LIGHT_ENDPOINT_ID), Some(OnOffHandler::CLUSTER.id)),
155-
Async(&on_off),
159+
EpClMatcher::new(
160+
Some(LIGHT_ENDPOINT_ID),
161+
Some(TestOnOffDeviceLogic::CLUSTER.id),
162+
),
163+
on_off::HandlerAsyncAdaptor(&on_off),
156164
)
157165
// Each Endpoint needs a Descriptor cluster too
158166
// Just use the one that `rs-matter` provides out of the box
@@ -198,11 +206,11 @@ mod example {
198206
Timer::after(Duration::from_secs(5)).await;
199207

200208
// Toggle
201-
on_off.0.set(!on_off.0.get());
209+
on_off.set_on_off(!on_off.on_off());
202210

203211
// Let the Matter stack know that we have changed
204212
// the state of our Light device
205-
stack.notify_changed();
213+
stack.notify_cluster_changed(1, TestOnOffDeviceLogic::CLUSTER.id);
206214

207215
info!("Light toggled");
208216
}
@@ -230,7 +238,7 @@ mod example {
230238
Endpoint {
231239
id: LIGHT_ENDPOINT_ID,
232240
device_types: devices!(DEV_TYPE_ON_OFF_LIGHT),
233-
clusters: clusters!(DescHandler::CLUSTER, OnOffHandler::CLUSTER),
241+
clusters: clusters!(DescHandler::CLUSTER, TestOnOffDeviceLogic::CLUSTER),
234242
},
235243
],
236244
};

examples/light_thread.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ mod example {
3434

3535
use esp_idf_matter::init_async_io;
3636
use esp_idf_matter::matter::dm::clusters::desc::{self, ClusterHandler as _, DescHandler};
37-
use esp_idf_matter::matter::dm::clusters::on_off::{ClusterHandler as _, OnOffHandler};
37+
use esp_idf_matter::matter::dm::clusters::on_off::test::TestOnOffDeviceLogic;
38+
use esp_idf_matter::matter::dm::clusters::on_off::{self, OnOffHandler, OnOffHooks};
3839
use esp_idf_matter::matter::dm::devices::test::{TEST_DEV_ATT, TEST_DEV_COMM, TEST_DEV_DET};
3940
use esp_idf_matter::matter::dm::devices::DEV_TYPE_ON_OFF_LIGHT;
4041
use esp_idf_matter::matter::dm::{Async, Dataver, EmptyHandler, Endpoint, EpClMatcher, Node};
@@ -122,16 +123,23 @@ mod example {
122123
info!("Basics initialized");
123124

124125
// Our "light" on-off handler.
125-
// Can be anything implementing `Handler` or `AsyncHandler`
126-
let on_off = OnOffHandler::new(Dataver::new_rand(stack.matter().rand())).adapt();
126+
// Can be anything implementing `rs_matter::dm::AsyncHandler`
127+
let on_off = OnOffHandler::new_standalone(
128+
Dataver::new_rand(stack.matter().rand()),
129+
1,
130+
TestOnOffDeviceLogic::new(),
131+
);
127132

128133
// Chain our endpoint clusters with the
129134
// (root) Endpoint 0 system clusters in the final handler
130135
let handler = EmptyHandler
131136
// Our on-off cluster, on Endpoint 1
132137
.chain(
133-
EpClMatcher::new(Some(LIGHT_ENDPOINT_ID), Some(OnOffHandler::CLUSTER.id)),
134-
Async(&on_off),
138+
EpClMatcher::new(
139+
Some(LIGHT_ENDPOINT_ID),
140+
Some(TestOnOffDeviceLogic::CLUSTER.id),
141+
),
142+
on_off::HandlerAsyncAdaptor(&on_off),
135143
)
136144
// Each Endpoint needs a Descriptor cluster too
137145
// Just use the one that `rs-matter` provides out of the box
@@ -175,11 +183,11 @@ mod example {
175183
Timer::after(Duration::from_secs(5)).await;
176184

177185
// Toggle
178-
on_off.0.set(!on_off.0.get());
186+
on_off.set_on_off(!on_off.on_off());
179187

180188
// Let the Matter stack know that we have changed
181189
// the state of our Light device
182-
stack.notify_changed();
190+
stack.notify_cluster_changed(1, TestOnOffDeviceLogic::CLUSTER.id);
183191

184192
info!("Light toggled");
185193
}
@@ -210,7 +218,7 @@ mod example {
210218
Endpoint {
211219
id: LIGHT_ENDPOINT_ID,
212220
device_types: devices!(DEV_TYPE_ON_OFF_LIGHT),
213-
clusters: clusters!(DescHandler::CLUSTER, OnOffHandler::CLUSTER),
221+
clusters: clusters!(DescHandler::CLUSTER, TestOnOffDeviceLogic::CLUSTER),
214222
},
215223
],
216224
};

examples/light_wifi.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ mod example {
3434

3535
use esp_idf_matter::init_async_io;
3636
use esp_idf_matter::matter::dm::clusters::desc::{self, ClusterHandler as _, DescHandler};
37-
use esp_idf_matter::matter::dm::clusters::on_off::{ClusterHandler as _, OnOffHandler};
37+
use esp_idf_matter::matter::dm::clusters::on_off::test::TestOnOffDeviceLogic;
38+
use esp_idf_matter::matter::dm::clusters::on_off::{self, OnOffHandler, OnOffHooks};
3839
use esp_idf_matter::matter::dm::devices::test::{TEST_DEV_ATT, TEST_DEV_COMM, TEST_DEV_DET};
3940
use esp_idf_matter::matter::dm::devices::DEV_TYPE_ON_OFF_LIGHT;
4041
use esp_idf_matter::matter::dm::{Async, Dataver, EmptyHandler, Endpoint, EpClMatcher, Node};
@@ -120,16 +121,23 @@ mod example {
120121
reduce_bt_memory(unsafe { peripherals.modem.reborrow() })?;
121122

122123
// Our "light" on-off handler.
123-
// Can be anything implementing `Handler` or `AsyncHandler`
124-
let on_off = OnOffHandler::new(Dataver::new_rand(stack.matter().rand())).adapt();
124+
// Can be anything implementing `rs_matter::dm::AsyncHandler`
125+
let on_off = OnOffHandler::new_standalone(
126+
Dataver::new_rand(stack.matter().rand()),
127+
1,
128+
TestOnOffDeviceLogic::new(),
129+
);
125130

126131
// Chain our endpoint clusters with the
127132
// (root) Endpoint 0 system clusters in the final handler
128133
let handler = EmptyHandler
129134
// Our on-off cluster, on Endpoint 1
130135
.chain(
131-
EpClMatcher::new(Some(LIGHT_ENDPOINT_ID), Some(OnOffHandler::CLUSTER.id)),
132-
Async(&on_off),
136+
EpClMatcher::new(
137+
Some(LIGHT_ENDPOINT_ID),
138+
Some(TestOnOffDeviceLogic::CLUSTER.id),
139+
),
140+
on_off::HandlerAsyncAdaptor(&on_off),
133141
)
134142
// Each Endpoint needs a Descriptor cluster too
135143
// Just use the one that `rs-matter` provides out of the box
@@ -169,11 +177,11 @@ mod example {
169177
Timer::after(Duration::from_secs(5)).await;
170178

171179
// Toggle
172-
on_off.0.set(!on_off.0.get());
180+
on_off.set_on_off(!on_off.on_off());
173181

174182
// Let the Matter stack know that we have changed
175183
// the state of our Light device
176-
stack.notify_changed();
184+
stack.notify_cluster_changed(1, TestOnOffDeviceLogic::CLUSTER.id);
177185

178186
info!("Light toggled");
179187
}
@@ -202,7 +210,7 @@ mod example {
202210
Endpoint {
203211
id: LIGHT_ENDPOINT_ID,
204212
device_types: devices!(DEV_TYPE_ON_OFF_LIGHT),
205-
clusters: clusters!(DescHandler::CLUSTER, OnOffHandler::CLUSTER),
213+
clusters: clusters!(DescHandler::CLUSTER, TestOnOffDeviceLogic::CLUSTER),
206214
},
207215
],
208216
};

0 commit comments

Comments
 (0)