#![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 = 0x0550;
pub const REVISION: u16 = 1;
pub const PICS: &str = "ZONEMGMT";
pub mod feature {
pub const TWO_DIMENSIONAL_CARTESIAN_ZONE: u32 = 1 << 0;
pub const PER_ZONE_SENSITIVITY: u32 = 1 << 1;
pub const USER_DEFINED: u32 = 1 << 2;
pub const FOCUS_ZONES: u32 = 1 << 3;
}
pub const FEATURES: &[Feature] = &[
Feature {
bit: 0,
code: "TWODCART",
name: "TwoDimensionalCartesianZone",
conform: Conform::OPTIONAL,
},
Feature {
bit: 1,
code: "PERZONESENS",
name: "PerZoneSensitivity",
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Feature(0),
}],
},
},
Feature {
bit: 2,
code: "USERDEFINED",
name: "UserDefined",
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Feature(0),
}],
},
},
Feature {
bit: 3,
code: "FOCUSZONES",
name: "FocusZones",
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Feature(2),
}],
},
},
];
pub mod attribute {
use crate::im::AttributeId;
pub const MAX_USER_DEFINED_ZONES: AttributeId = 0x00;
pub const MAX_ZONES: AttributeId = 0x01;
pub const ZONES: AttributeId = 0x02;
pub const TRIGGERS: AttributeId = 0x03;
pub const SENSITIVITY_MAX: AttributeId = 0x04;
pub const SENSITIVITY: AttributeId = 0x05;
pub const TWO_D_CARTESIAN_MAX: AttributeId = 0x06;
}
pub mod command {
use crate::im::CommandId;
pub const CREATE_TWO_D_CARTESIAN_ZONE: CommandId = 0x00;
pub const CREATE_TWO_D_CARTESIAN_ZONE_RESPONSE: CommandId = 0x01;
pub const UPDATE_TWO_D_CARTESIAN_ZONE: CommandId = 0x02;
pub const REMOVE_ZONE: CommandId = 0x03;
pub const CREATE_OR_UPDATE_TRIGGER: CommandId = 0x04;
pub const REMOVE_TRIGGER: CommandId = 0x05;
}
pub mod event {
use crate::im::EventId;
pub const ZONE_TRIGGERED: EventId = 0x00;
pub const ZONE_STOPPED: EventId = 0x01;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum ZoneEventStoppedReasonEnum {
ActionStopped = 0,
Timeout = 1,
}
impl ZoneEventStoppedReasonEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::ActionStopped),
1 => Some(Self::Timeout),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for ZoneEventStoppedReasonEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for ZoneEventStoppedReasonEnum {
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 ZoneEventTriggeredReasonEnum {
Motion = 0,
}
impl ZoneEventTriggeredReasonEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::Motion),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for ZoneEventTriggeredReasonEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for ZoneEventTriggeredReasonEnum {
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 ZoneSourceEnum {
Mfg = 0,
User = 1,
}
impl ZoneSourceEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::Mfg),
1 => Some(Self::User),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for ZoneSourceEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for ZoneSourceEnum {
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 ZoneTypeEnum {
TwoDCARTZone = 0,
}
impl ZoneTypeEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::TwoDCARTZone),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for ZoneTypeEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for ZoneTypeEnum {
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 ZoneUseEnum {
Motion = 0,
Privacy = 1,
Focus = 2,
}
impl ZoneUseEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::Motion),
1 => Some(Self::Privacy),
2 => Some(Self::Focus),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for ZoneUseEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for ZoneUseEnum {
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 TwoDCartesianVertexStruct {
pub x: u16,
pub y: u16,
}
impl ToTlv for TwoDCartesianVertexStruct {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.x.to_tlv(w, Tag::Context(0))?;
self.y.to_tlv(w, Tag::Context(1))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for TwoDCartesianVertexStruct {
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 x = None;
let mut y = 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) => x = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => y = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
x: x.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
y: y.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct TwoDCartesianZoneStruct<'a> {
pub name: &'a str,
pub use_: ZoneUseEnum,
pub vertices: TlvList<'a, TwoDCartesianVertexStruct>,
pub color: Option<&'a str>,
}
impl<'a> ToTlv for TwoDCartesianZoneStruct<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.name.to_tlv(w, Tag::Context(0))?;
self.use_.to_tlv(w, Tag::Context(1))?;
self.vertices.to_tlv(w, Tag::Context(2))?;
if let Some(value) = &self.color {
value.to_tlv(w, Tag::Context(3))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for TwoDCartesianZoneStruct<'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 name = None;
let mut use_ = None;
let mut vertices = None;
let mut color = 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) => name = Some(<&'a str>::from_tlv(reader, &field)?),
Some(1) => use_ = Some(<ZoneUseEnum>::from_tlv(reader, &field)?),
Some(2) => {
vertices = Some(<TlvList<'a, TwoDCartesianVertexStruct>>::from_tlv(
reader, &field,
)?)
}
Some(3) => color = Some(<&'a str>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
name: name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
use_: use_.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
vertices: vertices.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
color,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct ZoneInformationStruct<'a> {
pub zone_id: u16,
pub zone_type: ZoneTypeEnum,
pub zone_source: ZoneSourceEnum,
pub two_d_cartesian_zone: Option<TwoDCartesianZoneStruct<'a>>,
}
impl<'a> ToTlv for ZoneInformationStruct<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.zone_id.to_tlv(w, Tag::Context(0))?;
self.zone_type.to_tlv(w, Tag::Context(1))?;
self.zone_source.to_tlv(w, Tag::Context(2))?;
if let Some(value) = &self.two_d_cartesian_zone {
value.to_tlv(w, Tag::Context(3))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for ZoneInformationStruct<'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 zone_id = None;
let mut zone_type = None;
let mut zone_source = None;
let mut two_d_cartesian_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) => zone_id = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => zone_type = Some(<ZoneTypeEnum>::from_tlv(reader, &field)?),
Some(2) => zone_source = Some(<ZoneSourceEnum>::from_tlv(reader, &field)?),
Some(3) => {
two_d_cartesian_zone =
Some(<TwoDCartesianZoneStruct<'a>>::from_tlv(reader, &field)?)
}
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
zone_id: zone_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
zone_type: zone_type.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
zone_source: zone_source.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
two_d_cartesian_zone,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct ZoneTriggerControlStruct {
pub zone_id: u16,
pub initial_duration: u32,
pub augmentation_duration: u32,
pub max_duration: u32,
pub blind_duration: u32,
pub sensitivity: Option<u8>,
}
impl ToTlv for ZoneTriggerControlStruct {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.zone_id.to_tlv(w, Tag::Context(0))?;
self.initial_duration.to_tlv(w, Tag::Context(1))?;
self.augmentation_duration.to_tlv(w, Tag::Context(2))?;
self.max_duration.to_tlv(w, Tag::Context(3))?;
self.blind_duration.to_tlv(w, Tag::Context(4))?;
if let Some(value) = &self.sensitivity {
value.to_tlv(w, Tag::Context(5))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for ZoneTriggerControlStruct {
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 zone_id = None;
let mut initial_duration = None;
let mut augmentation_duration = None;
let mut max_duration = None;
let mut blind_duration = None;
let mut sensitivity = 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) => zone_id = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => initial_duration = Some(<u32>::from_tlv(reader, &field)?),
Some(2) => augmentation_duration = Some(<u32>::from_tlv(reader, &field)?),
Some(3) => max_duration = Some(<u32>::from_tlv(reader, &field)?),
Some(4) => blind_duration = Some(<u32>::from_tlv(reader, &field)?),
Some(5) => sensitivity = Some(<u8>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
zone_id: zone_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
initial_duration: initial_duration
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
augmentation_duration: augmentation_duration
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
max_duration: max_duration.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
blind_duration: blind_duration
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
sensitivity,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct CreateTwoDCartesianZoneFields<'a> {
pub zone: TwoDCartesianZoneStruct<'a>,
}
impl<'a> ToTlv for CreateTwoDCartesianZoneFields<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.zone.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for CreateTwoDCartesianZoneFields<'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 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) => zone = Some(<TwoDCartesianZoneStruct<'a>>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
zone: zone.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct CreateTwoDCartesianZoneResponseFields {
pub zone_id: u16,
}
impl ToTlv for CreateTwoDCartesianZoneResponseFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.zone_id.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for CreateTwoDCartesianZoneResponseFields {
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 zone_id = 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) => zone_id = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
zone_id: zone_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct UpdateTwoDCartesianZoneFields<'a> {
pub zone_id: u16,
pub zone: TwoDCartesianZoneStruct<'a>,
}
impl<'a> ToTlv for UpdateTwoDCartesianZoneFields<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.zone_id.to_tlv(w, Tag::Context(0))?;
self.zone.to_tlv(w, Tag::Context(1))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for UpdateTwoDCartesianZoneFields<'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 zone_id = None;
let mut 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) => zone_id = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => zone = Some(<TwoDCartesianZoneStruct<'a>>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
zone_id: zone_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
zone: zone.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct RemoveZoneFields {
pub zone_id: u16,
}
impl ToTlv for RemoveZoneFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.zone_id.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for RemoveZoneFields {
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 zone_id = 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) => zone_id = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
zone_id: zone_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct CreateOrUpdateTriggerFields {
pub trigger: ZoneTriggerControlStruct,
}
impl ToTlv for CreateOrUpdateTriggerFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.trigger.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for CreateOrUpdateTriggerFields {
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 trigger = 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) => trigger = Some(<ZoneTriggerControlStruct>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
trigger: trigger.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct RemoveTriggerFields {
pub zone_id: u16,
}
impl ToTlv for RemoveTriggerFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.zone_id.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for RemoveTriggerFields {
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 zone_id = 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) => zone_id = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
zone_id: zone_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
pub const ATTRIBUTES: &[Attribute] = &[
Attribute {
id: 0x0000,
name: "MaxUserDefinedZones",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Attribute {
id: 0x0001,
name: "MaxZones",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0002,
name: "Zones",
kind: "list[ZoneInformationStruct]",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0003,
name: "Triggers",
kind: "list[ZoneTriggerControlStruct]",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0004,
name: "SensitivityMax",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0005,
name: "Sensitivity",
kind: "uint8",
access: Access::read_write_with(Privilege::View, Privilege::Operate),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Not(&Condition::Feature(1)),
}],
},
},
Attribute {
id: 0x0006,
name: "TwoDCartesianMax",
kind: "TwoDCartesianVertexStruct",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
];
pub const COMMANDS: &[Command] = &[
Command {
id: 0x00,
name: "CreateTwoDCartesianZone",
to_server: true,
response: Some(0x01),
access: Access::invoke(Privilege::Manage),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::All(&[Condition::Feature(0), Condition::Feature(2)]),
}],
},
},
Command {
id: 0x01,
name: "CreateTwoDCartesianZoneResponse",
to_server: false,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::All(&[Condition::Feature(0), Condition::Feature(2)]),
}],
},
},
Command {
id: 0x02,
name: "UpdateTwoDCartesianZone",
to_server: true,
response: None,
access: Access::invoke(Privilege::Manage),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::All(&[Condition::Feature(0), Condition::Feature(2)]),
}],
},
},
Command {
id: 0x03,
name: "RemoveZone",
to_server: true,
response: None,
access: Access::invoke(Privilege::Manage),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Command {
id: 0x04,
name: "CreateOrUpdateTrigger",
to_server: true,
response: None,
access: Access::invoke(Privilege::Manage),
conform: Conform::MANDATORY,
},
Command {
id: 0x05,
name: "RemoveTrigger",
to_server: true,
response: None,
access: Access::invoke(Privilege::Manage),
conform: Conform::MANDATORY,
},
];
pub const EVENTS: &[Event] = &[
Event {
id: 0x00,
name: "ZoneTriggered",
priority: EventPriority::Info,
access: Access::read_only(Privilege::View),
conform: Conform::MANDATORY,
},
Event {
id: 0x01,
name: "ZoneStopped",
priority: EventPriority::Info,
access: Access::read_only(Privilege::View),
conform: Conform::MANDATORY,
},
];
pub const CLUSTER: Cluster = Cluster {
id: ID,
name: "Zone Management",
revision: REVISION,
pics: "ZONEMGMT",
derived_from: None,
features: FEATURES,
attributes: ATTRIBUTES,
commands: COMMANDS,
events: EVENTS,
};