8000 Extensions to Basic Information Cluster; AttrId is now `u32`; report more global elements (Was: Chip tool tests) by ivmarkov · Pull Request #232 · project-chip/rs-matter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Extensions to Basic Information Cluster; AttrId is now u32; report more global elements (Was: Chip tool tests) #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions chip-tool-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
CHIP_HOME="../connectedhomeip"
RS_MATTER=`pwd`
RS_MATTER_DATA="/tmp/rs-matter"

rm -rf ${RS_MATTER_DATA}
cd ${CHIP_HOME}
#${CHIP_HOME}/scripts/run_in_build_env.sh "${CHIP_HOME}/scripts/tests/run_test_suite.py --log-level warn --target TestAccessControlCluster --runner chip_tool_python --chip-tool ${CHIP_HOME}/out/host/chip-tool run --iterations 1 --test-timeout-seconds 120 --all-clusters-app ${RS_MATTER}/target/debug/examples/onoff_light --lock-app ${RS_MATTER}/target/debug/examples/onoff_light"
#${CHIP_HOME}/scripts/run_in_build_env.sh "${CHIP_HOME}/scripts/tests/run_test_suite.py --log-level warn --target TestBasicInformation --runner chip_tool_python --chip-tool ${CHIP_HOME}/out/host/chip-tool run --iterations 1 --test-timeout-seconds 120 --all-clusters-app ${RS_MATTER}/target/debug/examples/onoff_light --lock-app ${RS_MATTER}/target/debug/examples/onoff_light"
${CHIP_HOME}/scripts/run_in_build_env.sh "${CHIP_HOME}/scripts/tests/run_test_suite.py --log-level warn --target TestAttributesById --runner chip_tool_python --chip-tool ${CHIP_HOME}/out/host/chip-tool run --iterations 1 --test-timeout-seconds 120 --all-clusters-app ${RS_MATTER}/target/debug/examples/onoff_light --lock-app ${RS_MATTER}/target/debug/examples/onoff_light"
cd ${RS_MATTER}
12 changes: 11 additions & 1 deletion examples/onoff_light/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static DEV_DET: BasicInfoConfig = BasicInfoConfig {
vid: 0xFFF1,
pid: 0x8001,
hw_ver: 2,
hw_ver_str: "2",
sw_ver: 1,
sw_ver_str: "1",
serial_no: "aabbccdd",
Expand Down Expand Up @@ -98,6 +99,16 @@ fn run() -> Result<(), Error> {
env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"),
);

// NOTE: chip-tool tests need the log to go to `stdout` instead
// env_logger::builder()
// .format(|buf, record| {
// use std::io::Write;
// writeln!(buf, "{}: {}", record.level(), record.args())
// })
// .target(env_logger::Target::Stdout)
// .filter_level(::log::LevelFilter::Info)
// .init();

info!(
"Matter memory: Matter (BSS)={}B, IM Buffers (BSS)={}B, Subscriptions (BSS)={}B",
core::mem::size_of::<Matter>(),
Expand Down Expand Up @@ -281,7 +292,6 @@ async fn run_mdns(matter: &Matter<'_>) -> Result<(), Error> {
.filter_map(|ia| {
ia.address
.and_then(|addr| addr.as_sockaddr_in6().map(SockaddrIn6::ip))
.filter(|ip| ip.octets()[..2] == [0xfe, 0x80])
.map(|ipv6| (ia.interface_name, ipv6))
})
.filter_map(|(iname, ipv6)| {
Expand Down
1 change: 1 addition & 0 deletions examples/onoff_light_bt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ fn run() -> Result<(), Error> {
vid: 0xFFF1,
pid: 0x8000,
hw_ver: 2,
hw_ver_str: "2",
sw_ver: 1,
sw_ver_str: "1",
serial_no: "aabbccdd",
Expand Down
33 changes: 25 additions & 8 deletions rs-matter/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use embassy_sync::blocking_mutex::raw::NoopRawMutex;

use crate::data_model::{
cluster_basic_information::BasicInfoConfig,
cluster_basic_information::{BasicInfoConfig, BasicInfoSettings},
sdm::{dev_att::DevAttDataFetcher, failsafe::FailSafe},
};
use crate::error::*;
Expand Down Expand Up @@ -54,6 +54,7 @@ pub struct Matter<'a> {
pub fabric_mgr: RefCell<FabricMgr>, // Public for tests
pub(crate) pase_mgr: RefCell<PaseMgr>,
pub(crate) failsafe: RefCell<FailSafe>,
pub(crate) basic_info_settings: RefCell<BasicInfoSettings>,
pub transport_mgr: TransportMgr<'a>, // Public for tests
persist_notification: Notification<NoopRawMutex>,
epoch: Epoch,
Expand Down Expand Up @@ -122,6 +123,7 @@ impl<'a> Matter<'a> {
pase_mgr: RefCell::new(PaseMgr::new(epoch, rand)),
failsafe: RefCell::new(FailSafe::new(epoch, rand)),
transport_mgr: TransportMgr::new(mdns, dev_det, port, epoch, rand),
basic_info_settings: RefCell::new(BasicInfoSettings::new()),
persist_notification: Notification::new(),
epoch,
rand,
Expand Down Expand Up @@ -189,6 +191,7 @@ impl<'a> Matter<'a> {
pase_mgr <- RefCell::init(PaseMgr::init(epoch, rand)),
failsafe: RefCell::new(FailSafe::new(epoch, rand)),
transport_mgr <- TransportMgr::init(mdns, dev_det, port, epoch, rand),
basic_info_settings <- RefCell::init(BasicInfoSettings::init()),
persist_notification: Notification::new(),
epoch,
rand,
Expand Down Expand Up @@ -274,6 +277,18 @@ impl<'a> Matter<'a> {
self.fabric_mgr.borrow().is_changed()
}

pub fn load_basic_info(&self, data: &[u8]) -> Result<(), Error> {
self.basic_info_settings.borrow_mut().load(data)
}

pub fn store_basic_info<'b>(&self, buf: &'b mut [u8]) -> Result<Option<&'b [u8]>, Error> {
self.basic_info_settings.borrow_mut().store(buf)
}

pub fn basic_info_changed(&self) -> bool {
self.basic_info_settings.borrow().changed
}

/// Return `true` if there is at least one commissioned fabric
//
// TODO:
Expand Down Expand Up @@ -346,6 +361,8 @@ impl<'a> Matter<'a> {
S: NetworkSend,
R: NetworkReceive,
{
// TODO: Figure out why chip-tool-tests expect the device to still be in commissioning mode
// post device reboot, even if it was already commissioned
if !self.is_commissioned() {
self.enable_basic_commissioning(discovery_capabilities, 0 /*TODO*/)
.await?;
Expand Down Expand Up @@ -390,24 +407,24 @@ impl<'a> Matter<'a> {
.await
}

/// Notify that the ACLs or Fabrics _might_ have changed
/// This method is supposed to be called after processing SC and IM messages that might affect the ACLs or Fabrics.
/// Notify that the ACLs, Fabrics or Basic Info _might_ have changed
/// This method is supposed to be called after processing SC and IM messages that might affect the ACLs, Fabrics or Basic Info.
///
/// The default IM and SC handlers (`DataModel` and `SecureChannel`) do call this method after processing the messages.
///
/// TODO: Fix the method name as it is not clear enough. Potentially revamp the whole persistence notification logic
pub fn notify_fabrics_maybe_changed(&self) {
if self.fabrics_changed() {
pub fn notify_persist(&self) {
if self.fabrics_changed() || self.basic_info_changed() {
self.persist_notification.notify();
}
}

/// A hook for user persistence code to wait for potential changes in ACLs and/or Fabrics.
/// Once this future resolves, user code is supposed to inspect ACLs and Fabrics for changes, and
/// A hook for user persistence code to wait for potential changes in ACLs, Fabrics or basic info.
/// Once this future resolves, user code is supposed to inspect ACLs, Fabrics and basic info for changes, and
/// if there are changes, persist them.
///
/// TODO: Fix the method name as it is not clear enough. Potentially revamp the whole persistence notification logic
pub async fn wait_fabrics_changed(&self) {
pub async fn wait_persist(&self) {
self.persist_notification.wait().await
}
}
Loading
0