Skip to content

Commit

Permalink
Fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Jun 27, 2024
1 parent 12172f5 commit 84a6cc1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Since ESP-IDF does support the Rust Standard Library, UDP networking just works.
//!
//! The example implements a fictitious Light device (an On-Off Matter cluster).

use core::borrow::Borrow;
use core::pin::pin;

use embassy_futures::select::select;
Expand All @@ -46,7 +45,7 @@ use log::{error, info};
use rs_matter::data_model::cluster_basic_information::BasicInfoConfig;
use rs_matter::data_model::cluster_on_off;
use rs_matter::data_model::device_types::DEV_TYPE_ON_OFF_LIGHT;
use rs_matter::data_model::objects::{Endpoint, HandlerCompat, Node};
use rs_matter::data_model::objects::{Dataver, Endpoint, HandlerCompat, Node};
use rs_matter::data_model::system_model::descriptor;
use rs_matter::secure_channel::spake2p::VerifierData;
use rs_matter::utils::select::Coalesce;
Expand Down Expand Up @@ -108,7 +107,7 @@ async fn matter() -> Result<(), anyhow::Error> {

// Our "light" on-off cluster.
// Can be anything implementing `rs_matter::data_model::AsyncHandler`
let on_off = cluster_on_off::OnOffCluster::new(*stack.matter().borrow());
let on_off = cluster_on_off::OnOffCluster::new(Dataver::new_rand(stack.matter().rand()));

// Chain our endpoint clusters with the
// (root) Endpoint 0 system clusters in the final handler
Expand All @@ -125,7 +124,7 @@ async fn matter() -> Result<(), anyhow::Error> {
.chain(
LIGHT_ENDPOINT_ID,
descriptor::ID,
HandlerCompat(descriptor::DescriptorCluster::new(*stack.matter().borrow())),
HandlerCompat(descriptor::DescriptorCluster::new(Dataver::new_rand(stack.matter().rand()))),
);

// Run the Matter stack with our handler
Expand All @@ -144,7 +143,7 @@ async fn matter() -> Result<(), anyhow::Error> {
EspModem::new(peripherals.modem, sysloop, timers, nvs, stack),
// Hard-coded for demo purposes
CommissioningData {
verifier: VerifierData::new_with_pw(123456, *stack.matter().borrow()),
verifier: VerifierData::new_with_pw(123456, stack.matter().rand()),
discriminator: 250,
},
// Our `AsyncHandler` + `AsyncMetadata` impl
Expand Down
11 changes: 6 additions & 5 deletions examples/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//!
//! The example implements a fictitious Light device (an On-Off Matter cluster).
use core::borrow::Borrow;
use core::pin::pin;

use embassy_futures::select::select;
Expand All @@ -25,7 +24,7 @@ use log::{error, info};
use rs_matter::data_model::cluster_basic_information::BasicInfoConfig;
use rs_matter::data_model::cluster_on_off;
use rs_matter::data_model::device_types::DEV_TYPE_ON_OFF_LIGHT;
use rs_matter::data_model::objects::{Endpoint, HandlerCompat, Node};
use rs_matter::data_model::objects::{Dataver, Endpoint, HandlerCompat, Node};
use rs_matter::data_model::system_model::descriptor;
use rs_matter::secure_channel::spake2p::VerifierData;
use rs_matter::utils::select::Coalesce;
Expand Down Expand Up @@ -87,7 +86,7 @@ async fn matter() -> Result<(), anyhow::Error> {

// Our "light" on-off cluster.
// Can be anything implementing `rs_matter::data_model::AsyncHandler`
let on_off = cluster_on_off::OnOffCluster::new(*stack.matter().borrow());
let on_off = cluster_on_off::OnOffCluster::new(Dataver::new_rand(stack.matter().rand()));

// Chain our endpoint clusters with the
// (root) Endpoint 0 system clusters in the final handler
Expand All @@ -104,7 +103,9 @@ async fn matter() -> Result<(), anyhow::Error> {
.chain(
LIGHT_ENDPOINT_ID,
descriptor::ID,
HandlerCompat(descriptor::DescriptorCluster::new(*stack.matter().borrow())),
HandlerCompat(descriptor::DescriptorCluster::new(Dataver::new_rand(
stack.matter().rand(),
))),
);

// Run the Matter stack with our handler
Expand All @@ -123,7 +124,7 @@ async fn matter() -> Result<(), anyhow::Error> {
EspModem::new(peripherals.modem, sysloop, timers, nvs, stack),
// Hard-coded for demo purposes
CommissioningData {
verifier: VerifierData::new_with_pw(123456, *stack.matter().borrow()),
verifier: VerifierData::new_with_pw(123456, stack.matter().rand()),
discriminator: 250,
},
// Our `AsyncHandler` + `AsyncMetadata` impl
Expand Down
11 changes: 6 additions & 5 deletions examples/light_eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//!
//! The example implements a fictitious Light device (an On-Off Matter cluster).
use core::borrow::Borrow;
use core::pin::pin;

use embassy_futures::select::select;
Expand All @@ -32,7 +31,7 @@ use log::{error, info};
use rs_matter::data_model::cluster_basic_information::BasicInfoConfig;
use rs_matter::data_model::cluster_on_off;
use rs_matter::data_model::device_types::DEV_TYPE_ON_OFF_LIGHT;
use rs_matter::data_model::objects::{Endpoint, HandlerCompat, Node};
use rs_matter::data_model::objects::{Dataver, Endpoint, HandlerCompat, Node};
use rs_matter::data_model::system_model::descriptor;
use rs_matter::secure_channel::spake2p::VerifierData;
use rs_matter::utils::select::Coalesce;
Expand Down Expand Up @@ -113,7 +112,7 @@ async fn matter() -> Result<(), anyhow::Error> {

// Our "light" on-off cluster.
// Can be anything implementing `rs_matter::data_model::AsyncHandler`
let on_off = cluster_on_off::OnOffCluster::new(*stack.matter().borrow());
let on_off = cluster_on_off::OnOffCluster::new(Dataver::new_rand(stack.matter().rand()));

// Chain our endpoint clusters with the
// (root) Endpoint 0 system clusters in the final handler
Expand All @@ -130,7 +129,9 @@ async fn matter() -> Result<(), anyhow::Error> {
.chain(
LIGHT_ENDPOINT_ID,
descriptor::ID,
HandlerCompat(descriptor::DescriptorCluster::new(*stack.matter().borrow())),
HandlerCompat(descriptor::DescriptorCluster::new(Dataver::new_rand(
stack.matter().rand(),
))),
);

// Run the Matter stack with our handler
Expand All @@ -148,7 +149,7 @@ async fn matter() -> Result<(), anyhow::Error> {
EspMatterNetif::new(wifi.wifi().sta_netif(), sysloop),
// Hard-coded for demo purposes
CommissioningData {
verifier: VerifierData::new_with_pw(123456, *stack.matter().borrow()),
verifier: VerifierData::new_with_pw(123456, stack.matter().rand()),
discriminator: 250,
},
// Our `AsyncHandler` + `AsyncMetadata` impl
Expand Down

0 comments on commit 84a6cc1

Please sign in to comment.