Skip to main content

matter_kit/clusters/generated/
switch.rs

1// Generated by `cargo xtask` from the CSA data model 1.6. Do not edit.
2//
3// Switch — cluster 0x003B.
4//
5// Regenerate with `cargo xtask clusters --dm <checkout>/data_model/1.6`; `cargo xtask check`
6// is the CI gate that keeps this file honest. The XML itself is not vendored here — it
7// carries the CSA's own copyright notice and is not redistributable.
8
9//! Switch (cluster `0x003B`, revision 2).
10//!
11//! 10 identifiers, 6 feature bits, and the specification's own conformance for
12//! every element. `CLUSTER` is the whole table.
13
14#![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
26/// The cluster id.
27pub const ID: ClusterId = 0x003B;
28
29/// The highest revision the specification's history defines — what `ClusterRevision`
30/// must report (Core §7.13.1).
31pub const REVISION: u16 = 2;
32
33/// The PICS code, which a certification declaration names the cluster by.
34pub const PICS: &str = "SWTCH";
35
36/// The `FeatureMap` bits (Core §7.13.2).
37///
38/// A feature has conformance of its own: a device may not claim one the
39/// specification forbids it alongside another.
40pub mod feature {
41    /// Switch is latching
42    ///
43    /// Code `LS`, bit 0.
44    pub const LATCHING_SWITCH: u32 = 1 << 0;
45    /// Switch is momentary
46    ///
47    /// Code `MS`, bit 1.
48    pub const MOMENTARY_SWITCH: u32 = 1 << 1;
49    /// Switch supports release events generation
50    ///
51    /// Code `MSR`, bit 2.
52    pub const MOMENTARY_SWITCH_RELEASE: u32 = 1 << 2;
53    /// Switch supports long press detection
54    ///
55    /// Code `MSL`, bit 3.
56    pub const MOMENTARY_SWITCH_LONG_PRESS: u32 = 1 << 3;
57    /// Switch supports multi-press detection
58    ///
59    /// Code `MSM`, bit 4.
60    pub const MOMENTARY_SWITCH_MULTI_PRESS: u32 = 1 << 4;
61    /// Switch is momentary, targeted at specific user actions (focus on multi-press and optionally long press) with a reduced event generation scheme
62    ///
63    /// Code `AS`, bit 5.
64    pub const ACTION_SWITCH: u32 = 1 << 5;
65}
66
67/// Every feature bit, with its conformance.
68pub const FEATURES: &[Feature] = &[
69    Feature {
70        bit: 0,
71        code: "LS",
72        name: "LatchingSwitch",
73        conform: Conform::OPTIONAL,
74    },
75    Feature {
76        bit: 1,
77        code: "MS",
78        name: "MomentarySwitch",
79        conform: Conform::OPTIONAL,
80    },
81    Feature {
82        bit: 2,
83        code: "MSR",
84        name: "MomentarySwitchRelease",
85        conform: Conform {
86            clauses: &[Clause {
87                verdict: Conformance::Optional,
88                when: Condition::All(&[
89                    Condition::Feature(1),
90                    Condition::Not(&Condition::Feature(5)),
91                ]),
92            }],
93        },
94    },
95    Feature {
96        bit: 3,
97        code: "MSL",
98        name: "MomentarySwitchLongPress",
99        conform: Conform {
100            clauses: &[Clause {
101                verdict: Conformance::Optional,
102                when: Condition::All(&[
103                    Condition::Feature(1),
104                    Condition::Any(&[Condition::Feature(2), Condition::Feature(5)]),
105                ]),
106            }],
107        },
108    },
109    Feature {
110        bit: 4,
111        code: "MSM",
112        name: "MomentarySwitchMultiPress",
113        conform: Conform {
114            clauses: &[
115                Clause {
116                    verdict: Conformance::Mandatory,
117                    when: Condition::Feature(5),
118                },
119                Clause {
120                    verdict: Conformance::Optional,
121                    when: Condition::All(&[Condition::Feature(1), Condition::Feature(2)]),
122                },
123            ],
124        },
125    },
126    Feature {
127        bit: 5,
128        code: "AS",
129        name: "ActionSwitch",
130        conform: Conform {
131            clauses: &[Clause {
132                verdict: Conformance::Optional,
133                when: Condition::Feature(1),
134            }],
135        },
136    },
137];
138
139/// The attribute ids.
140pub mod attribute {
141    use crate::im::AttributeId;
142
143    /// `NumberOfPositions`.
144    pub const NUMBER_OF_POSITIONS: AttributeId = 0x00;
145    /// `CurrentPosition`.
146    pub const CURRENT_POSITION: AttributeId = 0x01;
147    /// `MultiPressMax`.
148    pub const MULTI_PRESS_MAX: AttributeId = 0x02;
149}
150
151/// The event ids.
152pub mod event {
153    use crate::im::EventId;
154
155    /// `SwitchLatched`.
156    pub const SWITCH_LATCHED: EventId = 0x00;
157    /// `InitialPress`.
158    pub const INITIAL_PRESS: EventId = 0x01;
159    /// `LongPress`.
160    pub const LONG_PRESS: EventId = 0x02;
161    /// `ShortRelease`.
162    pub const SHORT_RELEASE: EventId = 0x03;
163    /// `LongRelease`.
164    pub const LONG_RELEASE: EventId = 0x04;
165    /// `MultiPressOngoing`.
166    pub const MULTI_PRESS_ONGOING: EventId = 0x05;
167    /// `MultiPressComplete`.
168    pub const MULTI_PRESS_COMPLETE: EventId = 0x06;
169}
170
171/// Every attribute the specification defines, with its conformance.
172pub const ATTRIBUTES: &[Attribute] = &[
173    Attribute {
174        id: 0x0000,
175        name: "NumberOfPositions",
176        kind: "uint8",
177        access: Access::read_only(Privilege::View),
178        qualities: AttributeQualities::FIXED,
179        reporting: Reporting::OnChange,
180        conform: Conform::MANDATORY,
181    },
182    Attribute {
183        id: 0x0001,
184        name: "CurrentPosition",
185        kind: "uint8",
186        access: Access::read_only(Privilege::View),
187        qualities: AttributeQualities::NON_VOLATILE,
188        reporting: Reporting::OnChange,
189        conform: Conform::MANDATORY,
190    },
191    Attribute {
192        id: 0x0002,
193        name: "MultiPressMax",
194        kind: "uint8",
195        access: Access::read_only(Privilege::View),
196        qualities: AttributeQualities::FIXED,
197        reporting: Reporting::OnChange,
198        conform: Conform {
199            clauses: &[Clause {
200                verdict: Conformance::Mandatory,
201                when: Condition::Feature(4),
202            }],
203        },
204    },
205];
206
207/// Every command, with its conformance.
208pub const COMMANDS: &[Command] = &[];
209
210/// Every event, with its conformance.
211pub const EVENTS: &[Event] = &[
212    Event {
213        id: 0x00,
214        name: "SwitchLatched",
215        priority: EventPriority::Info,
216        access: Access::read_only(Privilege::View),
217        conform: Conform {
218            clauses: &[Clause {
219                verdict: Conformance::Mandatory,
220                when: Condition::Feature(0),
221            }],
222        },
223    },
224    Event {
225        id: 0x01,
226        name: "InitialPress",
227        priority: EventPriority::Info,
228        access: Access::read_only(Privilege::View),
229        conform: Conform {
230            clauses: &[Clause {
231                verdict: Conformance::Mandatory,
232                when: Condition::Feature(1),
233            }],
234        },
235    },
236    Event {
237        id: 0x02,
238        name: "LongPress",
239        priority: EventPriority::Info,
240        access: Access::read_only(Privilege::View),
241        conform: Conform {
242            clauses: &[Clause {
243                verdict: Conformance::Mandatory,
244                when: Condition::Feature(3),
245            }],
246        },
247    },
248    Event {
249        id: 0x03,
250        name: "ShortRelease",
251        priority: EventPriority::Info,
252        access: Access::read_only(Privilege::View),
253        conform: Conform {
254            clauses: &[Clause {
255                verdict: Conformance::Mandatory,
256                when: Condition::Feature(2),
257            }],
258        },
259    },
260    Event {
261        id: 0x04,
262        name: "LongRelease",
263        priority: EventPriority::Info,
264        access: Access::read_only(Privilege::View),
265        conform: Conform {
266            clauses: &[Clause {
267                verdict: Conformance::Mandatory,
268                when: Condition::Feature(3),
269            }],
270        },
271    },
272    Event {
273        id: 0x05,
274        name: "MultiPressOngoing",
275        priority: EventPriority::Info,
276        access: Access::read_only(Privilege::View),
277        conform: Conform {
278            clauses: &[Clause {
279                verdict: Conformance::Mandatory,
280                when: Condition::All(&[
281                    Condition::Feature(4),
282                    Condition::Not(&Condition::Feature(5)),
283                ]),
284            }],
285        },
286    },
287    Event {
288        id: 0x06,
289        name: "MultiPressComplete",
290        priority: EventPriority::Info,
291        access: Access::read_only(Privilege::View),
292        conform: Conform {
293            clauses: &[Clause {
294                verdict: Conformance::Mandatory,
295                when: Condition::Feature(4),
296            }],
297        },
298    },
299];
300
301/// The whole cluster, as the specification defines it.
302pub const CLUSTER: Cluster = Cluster {
303    id: ID,
304    name: "Switch",
305    revision: REVISION,
306    pics: "SWTCH",
307    derived_from: None,
308    features: FEATURES,
309    attributes: ATTRIBUTES,
310    commands: COMMANDS,
311    events: EVENTS,
312};