matter_kit/clusters/generated/
meter_identification.rs1#![allow(unused_imports)]
15
16use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
17use crate::dm::meta::{EventPriority, Reporting};
18use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
19use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
20use crate::error::Result;
21use crate::im::{AttributeId, ClusterId, CommandId, EventId};
22use crate::tlv::{
23 ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
24};
25
26pub const ID: ClusterId = 0x0B06;
28
29pub const REVISION: u16 = 1;
32
33pub const PICS: &str = "MTRID";
35
36pub mod feature {
41 pub const POWER_THRESHOLD: u32 = 1 << 0;
45}
46
47pub const FEATURES: &[Feature] = &[Feature {
49 bit: 0,
50 code: "PWRTHLD",
51 name: "PowerThreshold",
52 conform: Conform::OPTIONAL,
53}];
54
55pub mod attribute {
57 use crate::im::AttributeId;
58
59 pub const METER_TYPE: AttributeId = 0x00;
61 pub const POINT_OF_DELIVERY: AttributeId = 0x01;
63 pub const METER_SERIAL_NUMBER: AttributeId = 0x02;
65 pub const PROTOCOL_VERSION: AttributeId = 0x03;
67 pub const POWER_THRESHOLD: AttributeId = 0x04;
69}
70
71#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
73#[repr(u8)]
74pub enum MeterTypeEnum {
75 Utility = 0,
77 Private = 1,
79 Generic = 2,
81}
82
83impl MeterTypeEnum {
84 #[must_use]
86 pub const fn from_value(value: u8) -> Option<Self> {
87 match value {
88 0 => Some(Self::Utility),
89 1 => Some(Self::Private),
90 2 => Some(Self::Generic),
91 _ => None,
92 }
93 }
94
95 #[must_use]
97 pub const fn value(self) -> u8 {
98 self as u8
99 }
100}
101
102impl ToTlv for MeterTypeEnum {
103 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
104 self.value().to_tlv(w, tag)
105 }
106}
107
108impl<'a> FromTlv<'a> for MeterTypeEnum {
109 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
110 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
111 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
112 }
113}
114
115pub const ATTRIBUTES: &[Attribute] = &[
117 Attribute {
118 id: 0x0000,
119 name: "MeterType",
120 kind: "MeterTypeEnum",
121 access: Access::read_only(Privilege::View),
122 qualities: AttributeQualities::NULLABLE,
123 reporting: Reporting::OnChange,
124 conform: Conform::MANDATORY,
125 },
126 Attribute {
127 id: 0x0001,
128 name: "PointOfDelivery",
129 kind: "string",
130 access: Access::read_only(Privilege::View),
131 qualities: AttributeQualities::NULLABLE,
132 reporting: Reporting::OnChange,
133 conform: Conform::MANDATORY,
134 },
135 Attribute {
136 id: 0x0002,
137 name: "MeterSerialNumber",
138 kind: "string",
139 access: Access::read_only(Privilege::View),
140 qualities: AttributeQualities::NULLABLE,
141 reporting: Reporting::OnChange,
142 conform: Conform::MANDATORY,
143 },
144 Attribute {
145 id: 0x0003,
146 name: "ProtocolVersion",
147 kind: "string",
148 access: Access::read_only(Privilege::View),
149 qualities: AttributeQualities::NULLABLE,
150 reporting: Reporting::OnChange,
151 conform: Conform::OPTIONAL,
152 },
153 Attribute {
154 id: 0x0004,
155 name: "PowerThreshold",
156 kind: "PowerThresholdStruct",
157 access: Access::read_only(Privilege::View),
158 qualities: AttributeQualities::NULLABLE,
159 reporting: Reporting::OnChange,
160 conform: Conform {
161 clauses: &[Clause {
162 verdict: Conformance::Mandatory,
163 when: Condition::Feature(0),
164 }],
165 },
166 },
167];
168
169pub const COMMANDS: &[Command] = &[];
171
172pub const EVENTS: &[Event] = &[];
174
175pub const CLUSTER: Cluster = Cluster {
177 id: ID,
178 name: "Meter Identification",
179 revision: REVISION,
180 pics: "MTRID",
181 derived_from: None,
182 features: FEATURES,
183 attributes: ATTRIBUTES,
184 commands: COMMANDS,
185 events: EVENTS,
186};