#![allow(unused_imports)]
use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
use crate::dm::meta::{EventPriority, Reporting};
use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
use crate::error::Result;
use crate::im::{AttributeId, ClusterId, CommandId, EventId};
use crate::tlv::{
ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
};
pub const ID: ClusterId = 0x0038;
pub const REVISION: u16 = 2;
pub const PICS: &str = "TIMESYNC";
pub mod feature {
pub const TIME_ZONE: u32 = 1 << 0;
pub const NTP_CLIENT: u32 = 1 << 1;
pub const NTP_SERVER: u32 = 1 << 2;
pub const TIME_SYNC_CLIENT: u32 = 1 << 3;
}
pub const FEATURES: &[Feature] = &[
Feature {
bit: 0,
code: "TZ",
name: "TimeZone",
conform: Conform::OPTIONAL,
},
Feature {
bit: 1,
code: "NTPC",
name: "NTPClient",
conform: Conform::OPTIONAL,
},
Feature {
bit: 2,
code: "NTPS",
name: "NTPServer",
conform: Conform::OPTIONAL,
},
Feature {
bit: 3,
code: "TSC",
name: "TimeSyncClient",
conform: Conform::OPTIONAL,
},
];
pub mod attribute {
use crate::im::AttributeId;
pub const UTC_TIME: AttributeId = 0x00;
pub const GRANULARITY: AttributeId = 0x01;
pub const TIME_SOURCE: AttributeId = 0x02;
pub const TRUSTED_TIME_SOURCE: AttributeId = 0x03;
pub const DEFAULT_NTP: AttributeId = 0x04;
pub const TIME_ZONE: AttributeId = 0x05;
pub const DST_OFFSET: AttributeId = 0x06;
pub const LOCAL_TIME: AttributeId = 0x07;
pub const TIME_ZONE_DATABASE: AttributeId = 0x08;
pub const NTP_SERVER_AVAILABLE: AttributeId = 0x09;
pub const TIME_ZONE_LIST_MAX_SIZE: AttributeId = 0x0A;
pub const DST_OFFSET_LIST_MAX_SIZE: AttributeId = 0x0B;
pub const SUPPORTS_DNS_RESOLVE: AttributeId = 0x0C;
}
pub mod command {
use crate::im::CommandId;
pub const SET_UTC_TIME: CommandId = 0x00;
pub const SET_TRUSTED_TIME_SOURCE: CommandId = 0x01;
pub const SET_TIME_ZONE: CommandId = 0x02;
pub const SET_TIME_ZONE_RESPONSE: CommandId = 0x03;
pub const SET_DST_OFFSET: CommandId = 0x04;
pub const SET_DEFAULT_NTP: CommandId = 0x05;
}
pub mod event {
use crate::im::EventId;
pub const DST_TABLE_EMPTY: EventId = 0x00;
pub const DST_STATUS: EventId = 0x01;
pub const TIME_ZONE_STATUS: EventId = 0x02;
pub const TIME_FAILURE: EventId = 0x03;
pub const MISSING_TRUSTED_TIME_SOURCE: EventId = 0x04;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum GranularityEnum {
NoTimeGranularity = 0,
MinutesGranularity = 1,
SecondsGranularity = 2,
MillisecondsGranularity = 3,
MicrosecondsGranularity = 4,
}
impl GranularityEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::NoTimeGranularity),
1 => Some(Self::MinutesGranularity),
2 => Some(Self::SecondsGranularity),
3 => Some(Self::MillisecondsGranularity),
4 => Some(Self::MicrosecondsGranularity),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for GranularityEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for GranularityEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum StatusCodeEnum {
TimeNotAccepted = 2,
}
impl StatusCodeEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
2 => Some(Self::TimeNotAccepted),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for StatusCodeEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for StatusCodeEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum TimeSourceEnum {
None = 0,
Unknown = 1,
Admin = 2,
NodeTimeCluster = 3,
NonMatterSNTP = 4,
NonMatterNTP = 5,
MatterSNTP = 6,
MatterNTP = 7,
MixedNTP = 8,
NonMatterSNTPNTS = 9,
NonMatterNTPNTS = 10,
MatterSNTPNTS = 11,
MatterNTPNTS = 12,
MixedNTPNTS = 13,
CloudSource = 14,
PTP = 15,
GNSS = 16,
}
impl TimeSourceEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::None),
1 => Some(Self::Unknown),
2 => Some(Self::Admin),
3 => Some(Self::NodeTimeCluster),
4 => Some(Self::NonMatterSNTP),
5 => Some(Self::NonMatterNTP),
6 => Some(Self::MatterSNTP),
7 => Some(Self::MatterNTP),
8 => Some(Self::MixedNTP),
9 => Some(Self::NonMatterSNTPNTS),
10 => Some(Self::NonMatterNTPNTS),
11 => Some(Self::MatterSNTPNTS),
12 => Some(Self::MatterNTPNTS),
13 => Some(Self::MixedNTPNTS),
14 => Some(Self::CloudSource),
15 => Some(Self::PTP),
16 => Some(Self::GNSS),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for TimeSourceEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for TimeSourceEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum TimeZoneDatabaseEnum {
Full = 0,
Partial = 1,
None = 2,
}
impl TimeZoneDatabaseEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::Full),
1 => Some(Self::Partial),
2 => Some(Self::None),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for TimeZoneDatabaseEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for TimeZoneDatabaseEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct DSTOffsetStruct {
pub offset: i32,
pub valid_starting: u64,
pub valid_until: Nullable<u64>,
}
impl ToTlv for DSTOffsetStruct {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.offset.to_tlv(w, Tag::Context(0))?;
self.valid_starting.to_tlv(w, Tag::Context(1))?;
self.valid_until.to_tlv(w, Tag::Context(2))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for DSTOffsetStruct {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut offset = None;
let mut valid_starting = None;
let mut valid_until = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => offset = Some(<i32>::from_tlv(reader, &field)?),
Some(1) => valid_starting = Some(<u64>::from_tlv(reader, &field)?),
Some(2) => valid_until = Some(<Nullable<u64>>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
offset: offset.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
valid_starting: valid_starting
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
valid_until: valid_until.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FabricScopedTrustedTimeSourceStruct {
pub node_id: crate::msg::NodeId,
pub endpoint: u16,
}
impl ToTlv for FabricScopedTrustedTimeSourceStruct {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.node_id.to_tlv(w, Tag::Context(0))?;
self.endpoint.to_tlv(w, Tag::Context(1))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for FabricScopedTrustedTimeSourceStruct {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut node_id = None;
let mut endpoint = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
Some(1) => endpoint = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
endpoint: endpoint.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct TimeZoneStruct<'a> {
pub offset: i32,
pub valid_at: u64,
pub name: Option<&'a str>,
}
impl<'a> ToTlv for TimeZoneStruct<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.offset.to_tlv(w, Tag::Context(0))?;
self.valid_at.to_tlv(w, Tag::Context(1))?;
if let Some(value) = &self.name {
value.to_tlv(w, Tag::Context(2))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for TimeZoneStruct<'a> {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut offset = None;
let mut valid_at = None;
let mut name = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => offset = Some(<i32>::from_tlv(reader, &field)?),
Some(1) => valid_at = Some(<u64>::from_tlv(reader, &field)?),
Some(2) => name = Some(<&'a str>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
offset: offset.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
valid_at: valid_at.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
name,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct TrustedTimeSourceStruct {
pub fabric_index: crate::msg::FabricIndex,
pub node_id: crate::msg::NodeId,
pub endpoint: u16,
}
impl ToTlv for TrustedTimeSourceStruct {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.fabric_index.to_tlv(w, Tag::Context(0))?;
self.node_id.to_tlv(w, Tag::Context(1))?;
self.endpoint.to_tlv(w, Tag::Context(2))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for TrustedTimeSourceStruct {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut fabric_index = None;
let mut node_id = None;
let mut endpoint = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => {
fabric_index = Some(<crate::msg::FabricIndex>::from_tlv(reader, &field)?)
}
Some(1) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
Some(2) => endpoint = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
fabric_index: fabric_index.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
endpoint: endpoint.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SetUTCTimeFields {
pub utc_time: u64,
pub granularity: GranularityEnum,
pub time_source: Option<TimeSourceEnum>,
}
impl ToTlv for SetUTCTimeFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.utc_time.to_tlv(w, Tag::Context(0))?;
self.granularity.to_tlv(w, Tag::Context(1))?;
if let Some(value) = &self.time_source {
value.to_tlv(w, Tag::Context(2))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for SetUTCTimeFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut utc_time = None;
let mut granularity = None;
let mut time_source = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => utc_time = Some(<u64>::from_tlv(reader, &field)?),
Some(1) => granularity = Some(<GranularityEnum>::from_tlv(reader, &field)?),
Some(2) => time_source = Some(<TimeSourceEnum>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
utc_time: utc_time.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
granularity: granularity.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
time_source,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SetTrustedTimeSourceFields {
pub trusted_time_source: Nullable<FabricScopedTrustedTimeSourceStruct>,
}
impl ToTlv for SetTrustedTimeSourceFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.trusted_time_source.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for SetTrustedTimeSourceFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut trusted_time_source = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => {
trusted_time_source = Some(
<Nullable<FabricScopedTrustedTimeSourceStruct>>::from_tlv(reader, &field)?,
)
}
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
trusted_time_source: trusted_time_source
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SetTimeZoneFields<'a> {
pub time_zone: TlvList<'a, TimeZoneStruct<'a>>,
}
impl<'a> ToTlv for SetTimeZoneFields<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.time_zone.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for SetTimeZoneFields<'a> {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut time_zone = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => {
time_zone = Some(<TlvList<'a, TimeZoneStruct<'a>>>::from_tlv(reader, &field)?)
}
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
time_zone: time_zone.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SetTimeZoneResponseFields {
pub dst_offset_required: bool,
}
impl ToTlv for SetTimeZoneResponseFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.dst_offset_required.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for SetTimeZoneResponseFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut dst_offset_required = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => dst_offset_required = Some(<bool>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
dst_offset_required: dst_offset_required
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SetDSTOffsetFields<'a> {
pub dst_offset: TlvList<'a, DSTOffsetStruct>,
}
impl<'a> ToTlv for SetDSTOffsetFields<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.dst_offset.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for SetDSTOffsetFields<'a> {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut dst_offset = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => {
dst_offset = Some(<TlvList<'a, DSTOffsetStruct>>::from_tlv(reader, &field)?)
}
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
dst_offset: dst_offset.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SetDefaultNTPFields<'a> {
pub default_ntp: Nullable<&'a str>,
}
impl<'a> ToTlv for SetDefaultNTPFields<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.default_ntp.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for SetDefaultNTPFields<'a> {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut default_ntp = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => default_ntp = Some(<Nullable<&'a str>>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
default_ntp: default_ntp.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
pub const ATTRIBUTES: &[Attribute] = &[
Attribute {
id: 0x0000,
name: "UTCTime",
kind: "epoch-us",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE,
reporting: Reporting::ChangesOmitted,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0001,
name: "Granularity",
kind: "GranularityEnum",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0002,
name: "TimeSource",
kind: "TimeSourceEnum",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0003,
name: "TrustedTimeSource",
kind: "TrustedTimeSourceStruct",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(3),
}],
},
},
Attribute {
id: 0x0004,
name: "DefaultNTP",
kind: "string",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Attribute {
id: 0x0005,
name: "TimeZone",
kind: "list[TimeZoneStruct]",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0006,
name: "DSTOffset",
kind: "list[DSTOffsetStruct]",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0007,
name: "LocalTime",
kind: "epoch-us",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE,
reporting: Reporting::ChangesOmitted,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0008,
name: "TimeZoneDatabase",
kind: "TimeZoneDatabaseEnum",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0009,
name: "NTPServerAvailable",
kind: "bool",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Attribute {
id: 0x000A,
name: "TimeZoneListMaxSize",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x000B,
name: "DSTOffsetListMaxSize",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x000C,
name: "SupportsDNSResolve",
kind: "bool",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
];
pub const COMMANDS: &[Command] = &[
Command {
id: 0x00,
name: "SetUTCTime",
to_server: true,
response: None,
access: Access::invoke(Privilege::Administer),
conform: Conform::MANDATORY,
},
Command {
id: 0x01,
name: "SetTrustedTimeSource",
to_server: true,
response: None,
access: Access::invoke(Privilege::Administer)
.with_qualities(AccessQualities::FABRIC_SCOPED),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(3),
}],
},
},
Command {
id: 0x02,
name: "SetTimeZone",
to_server: true,
response: Some(0x03),
access: Access::invoke(Privilege::Manage),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x03,
name: "SetTimeZoneResponse",
to_server: false,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x04,
name: "SetDSTOffset",
to_server: true,
response: None,
access: Access::invoke(Privilege::Manage),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x05,
name: "SetDefaultNTP",
to_server: true,
response: None,
access: Access::invoke(Privilege::Administer),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
];
pub const EVENTS: &[Event] = &[
Event {
id: 0x00,
name: "DSTTableEmpty",
priority: EventPriority::Info,
access: Access::read_only(Privilege::View),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Event {
id: 0x01,
name: "DSTStatus",
priority: EventPriority::Info,
access: Access::read_only(Privilege::View),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Event {
id: 0x02,
name: "TimeZoneStatus",
priority: EventPriority::Info,
access: Access::read_only(Privilege::View),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Event {
id: 0x03,
name: "TimeFailure",
priority: EventPriority::Info,
access: Access::read_only(Privilege::View),
conform: Conform::MANDATORY,
},
Event {
id: 0x04,
name: "MissingTrustedTimeSource",
priority: EventPriority::Info,
access: Access::read_only(Privilege::View),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(3),
}],
},
},
];
pub const CLUSTER: Cluster = Cluster {
id: ID,
name: "Time Synchronization",
revision: REVISION,
pics: "TIMESYNC",
derived_from: None,
features: FEATURES,
attributes: ATTRIBUTES,
commands: COMMANDS,
events: EVENTS,
};