Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Jan 8, 2024
1 parent 370035e commit 5610857
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion examples/onoff_light/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mod dev_att;
#[cfg(feature = "std")]
fn main() -> Result<(), Error> {
let thread = std::thread::Builder::new()
.stack_size(160 * 1024)
.stack_size(180 * 1024)
.spawn(run)
.unwrap();

Expand Down Expand Up @@ -74,6 +74,7 @@ fn run() -> Result<(), Error> {
device_name: "OnOff Light",
product_name: "Light123",
vendor_name: "Vendor PQR",
unique_id: "aabbccdd",
};

let (ipv4_addr, ipv6_addr, interface) = initialize_network()?;
Expand Down
9 changes: 9 additions & 0 deletions rs-matter/src/data_model/cluster_basic_information.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub enum Attributes {
SwVer(AttrType<u32>) = 9,
SwVerString(AttrUtfType) = 0xa,
SerialNo(AttrUtfType) = 0x0f,
UniqueId(AttrUtfType) = 0x12,
}

attribute_enum!(Attributes);
Expand All @@ -56,6 +57,7 @@ pub enum AttributesDiscriminants {
SwVer = 9,
SwVerString = 0xa,
SerialNo = 0x0f,
UniqueId = 0x12,
}

#[derive(Default)]
Expand All @@ -70,6 +72,7 @@ pub struct BasicInfoConfig<'a> {
pub device_name: &'a str,
pub vendor_name: &'a str,
pub product_name: &'a str,
pub unique_id: &'a str,
}

pub const CLUSTER: Cluster<'static> = Cluster {
Expand Down Expand Up @@ -128,6 +131,11 @@ pub const CLUSTER: Cluster<'static> = Cluster {
Access::RV,
Quality::FIXED,
),
Attribute::new(
AttributesDiscriminants::UniqueId as u16,
Access::RV,
Quality::FIXED,
),
],
commands: &[],
};
Expand Down Expand Up @@ -166,6 +174,7 @@ impl<'a> BasicInfoCluster<'a> {
Attributes::SwVer(codec) => codec.encode(writer, self.cfg.sw_ver),
Attributes::SwVerString(codec) => codec.encode(writer, self.cfg.sw_ver_str),
Attributes::SerialNo(codec) => codec.encode(writer, self.cfg.serial_no),
Attributes::UniqueId(codec) => codec.encode(writer, self.cfg.unique_id),
}
}
} else {
Expand Down
8 changes: 6 additions & 2 deletions rs-matter/src/data_model/objects/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::{
interaction_model::messages::ib::{AttrDataTag, AttrRespTag},
tlv::{FromTLV, TLVElement, TLVWriter, TagType, ToTLV},
};
use log::error;
use log::{error, warn};

use super::{AttrDetails, CmdDetails, DataModelHandler};

Expand Down Expand Up @@ -149,7 +149,10 @@ impl<'a, 'b, 'c> AttrDataEncoder<'a, 'b, 'c> {
};

if let Some(status) = status {
AttrResp::Status(status).to_tlv(tw, TagType::Anonymous)?;
let resp = AttrResp::Status(status);
warn!("Read status: {:?}", resp);

resp.to_tlv(tw, TagType::Anonymous)?;
}

Ok(true)
Expand All @@ -172,6 +175,7 @@ impl<'a, 'b, 'c> AttrDataEncoder<'a, 'b, 'c> {
};

if let Some(status) = status {
warn!("Write status: {:?}", status);
status.to_tlv(tw, TagType::Anonymous)?;
}

Expand Down
1 change: 0 additions & 1 deletion rs-matter/src/transport/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,6 @@ impl<'a> Matter<'a> {
};

if send {
dest_tx.log("Sending packet");
self.notify_changed();

return Ok(true);
Expand Down
2 changes: 2 additions & 0 deletions rs-matter/src/transport/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ impl Session {
pub(crate) fn send(&mut self, epoch: Epoch, tx: &mut Packet) -> Result<(), Error> {
self.last_use = epoch();

tx.log("About to send packet");

tx.proto_encode(
self.peer_addr,
self.peer_nodeid,
Expand Down

0 comments on commit 5610857

Please sign in to comment.