Skip to content

Commit d4474a6

Browse files
committed
TimeSync, TrustedTimeSource client
1 parent ceb98ab commit d4474a6

11 files changed

Lines changed: 743 additions & 363 deletions

File tree

examples/src/bin/chip_tool_tests.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,13 @@ const NODE: Node<'static> = Node {
463463
ROOT_ENDPOINT_ID,
464464
devices!(DEV_TYPE_ROOT_NODE),
465465
clusters!(
466-
eth;
466+
eth,
467+
// Claim `TimeSynchronization.TIME_SYNC_CLIENT` (Matter Core
468+
// spec §11.17.13) so the device advertises the
469+
// `TrustedTimeSource` attribute + `SetTrustedTimeSource`
470+
// command — exercised by `TC_TIMESYNC_2_13` and
471+
// consumed by [`time_sync::client::TimeSyncClient`].
472+
time_sync(time_sync_client);
467473
groups::GroupsHandler::CLUSTER,
468474
user_label::CLUSTER,
469475
binding::CLUSTER

rs-matter/src/dm/clusters/noc.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ impl ClusterHandler for NocHandler {
530530
let status = NodeOperationalCertStatusEnum::map(GenCommHandler::with_armed_failsafe(
531531
&ctx,
532532
|state, mut notify_mdns| {
533-
let lkg_utc_secs = state.lkg_utc_secs();
533+
let lkg_utc_secs = state.rtc.utc_time_best_effort() / 1_000_000;
534534
let sess = ctx.exchange().id().session(&mut state.sessions);
535535

536536
let fabric = state.failsafe.add_noc(
@@ -621,7 +621,7 @@ impl ClusterHandler for NocHandler {
621621
let status = NodeOperationalCertStatusEnum::map(GenCommHandler::with_armed_failsafe(
622622
&ctx,
623623
|state, notify_mdns| {
624-
let lkg_utc_secs = state.lkg_utc_secs();
624+
let lkg_utc_secs = state.rtc.utc_time_best_effort() / 1_000_000;
625625
let sess = ctx.exchange().id().session(&mut state.sessions);
626626

627627
state.failsafe.update_noc(
@@ -739,6 +739,18 @@ impl ClusterHandler for NocHandler {
739739

740740
persist.remove(fab_idx)?;
741741

742+
// Matter Core spec §11.17.8.7: if the removed fabric is the
743+
// one that installed the TrustedTimeSource, the device SHALL
744+
// clear the attribute (and emit `MissingTrustedTimeSource`).
745+
if state.rtc.trusted_time_source().map(|tts| tts.fab_idx) == Some(fab_idx) {
746+
state.rtc.set_trusted_time_source_persist(
747+
None,
748+
persist.persist_mut(),
749+
&ctx,
750+
&ctx,
751+
)?;
752+
}
753+
742754
info!("Removed operational fabric with local index {}", fab_idx);
743755

744756
// If the removed fabric was the one that opened the current
@@ -792,7 +804,7 @@ impl ClusterHandler for NocHandler {
792804
let mut buf = [0u8; crate::cert::MAX_CERT_ASN1_LEN];
793805

794806
GenCommHandler::with_armed_failsafe(&ctx, |state, _| {
795-
let lkg_utc_secs = state.lkg_utc_secs();
807+
let lkg_utc_secs = state.rtc.utc_time_best_effort() / 1_000_000;
796808
let sess = ctx.exchange().id().session(&mut state.sessions);
797809

798810
state.failsafe.add_trusted_root_cert(

0 commit comments

Comments
 (0)