Skip to content

Commit

Permalink
Improvements to the TLV framework (#206)
Browse files Browse the repository at this point in the history
* Improvements to the TLV framework

Delay the creation of the Error type as it is expensive when backtrace is enabled

* Derive optimized init_from_tlv for structs

* Remove the unused writer module

* Remove tests which are covered by test_matter_spec_examples

* Remove unused commented out code

* Fix TLVTool
  • Loading branch information
ivmarkov committed Sep 17, 2024
1 parent 2dc8cff commit 93d2082
Show file tree
Hide file tree
Showing 74 changed files with 10,943 additions and 5,154 deletions.
2 changes: 1 addition & 1 deletion examples/onoff_light/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn main() -> Result<(), Error> {
// e.g., an opt-level of "0" will require a several times' larger stack.
//
// Optimizing/lowering `rs-matter` memory consumption is an ongoing topic.
.stack_size(65 * 1024)
.stack_size(54 * 1024)
.spawn(run)
.unwrap();

Expand Down
8 changes: 3 additions & 5 deletions examples/onoff_light_bt/src/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use rs_matter::data_model::sdm::nw_commissioning::{
use rs_matter::error::{Error, ErrorCode};
use rs_matter::interaction_model::core::IMStatusCode;
use rs_matter::interaction_model::messages::ib::Status;
use rs_matter::tlv::{FromTLV, OctetStr, TLVElement};
use rs_matter::tlv::{FromTLV, Octets, TLVElement, TLVWrite};
use rs_matter::transport::exchange::Exchange;
use rs_matter::utils::sync::Notification;

Expand Down Expand Up @@ -70,7 +70,7 @@ impl<'a> WifiNwCommCluster<'a> {
match attr.attr_id.try_into()? {
Attributes::MaxNetworks => AttrType::<u8>::new().encode(writer, 1_u8),
Attributes::Networks => {
writer.start_array(AttrDataWriter::TAG)?;
writer.start_array(&AttrDataWriter::TAG)?;

writer.end_container()?;
writer.complete()
Expand All @@ -79,9 +79,7 @@ impl<'a> WifiNwCommCluster<'a> {
Attributes::ConnectMaxTimeSecs => AttrType::new().encode(writer, 60_u8),
Attributes::InterfaceEnabled => AttrType::new().encode(writer, true),
Attributes::LastNetworkingStatus => AttrType::new().encode(writer, 0_u8),
Attributes::LastNetworkID => {
AttrType::new().encode(writer, OctetStr("ssid".as_bytes()))
}
Attributes::LastNetworkID => AttrType::new().encode(writer, Octets("ssid".as_bytes())),
Attributes::LastConnectErrorValue => AttrType::new().encode(writer, 0),
}
}
Expand Down
Loading

0 comments on commit 93d2082

Please sign in to comment.