Skip to main content

rs_matter/dm/
devices.rs

1/*
2 *
3 *    Copyright (c) 2022-2026 Project CHIP Authors
4 *
5 *    Licensed under the Apache License, Version 2.0 (the "License");
6 *    you may not use this file except in compliance with the License.
7 *    You may obtain a copy of the License at
8 *
9 *        http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *    Unless required by applicable law or agreed to in writing, software
12 *    distributed under the License is distributed on an "AS IS" BASIS,
13 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *    See the License for the specific language governing permissions and
15 *    limitations under the License.
16 */
17
18use super::types::DeviceType;
19
20pub mod test;
21
22/// A constant representing the device type for the root (ep0) endpoint in Matter.
23///
24/// Matter Device Library revision history: rev 1 was initial; rev 2
25/// added Power Source (conditional, optional); rev 3 added MNGD-feature
26/// restriction on Access Control; rev 4 added conditions and cluster
27/// requirements for Time Sync, TLS Certificate/Client Management. All four
28/// rev-2..4 additions are either conditional or `O` (optional) per spec;
29/// rs-matter implements the rev-1 mandatory set (BasicInfo, AccessControl,
30/// GeneralCommissioning, NetworkCommissioning, GeneralDiagnostics,
31/// AdminCommissioning, OperationalCredentials, GroupKeyManagement) and is
32/// therefore conformant at rev 4.
33pub const DEV_TYPE_ROOT_NODE: DeviceType = DeviceType {
34    dtype: 0x0016,
35    drev: 4,
36};
37
38/// A constant representing the device type for a power source endpoint in the node.
39///
40/// Utility device type, node-scoped: it is declared *alongside* the primary
41/// device type of the endpoint hosting the `PowerSource` cluster (typically the
42/// root node - see Device Library spec which lists this device type under the
43/// Root Node's requirements with `PowerSourceCond, O`).
44pub const DEV_TYPE_POWER_SOURCE: DeviceType = DeviceType {
45    dtype: 0x0011,
46    drev: 1,
47};
48
49/// A constant representing the device type for a bridged device endpoint in the node.
50pub const DEV_TYPE_BRIDGED_NODE: DeviceType = DeviceType {
51    dtype: 0x0013,
52    drev: 1,
53};
54
55/// A constant representing the device type for an aggregator endpoint in the node
56///  when the Node contains bridged endpoints.
57pub const DEV_TYPE_AGGREGATOR: DeviceType = DeviceType {
58    dtype: 0x000e,
59    drev: 1,
60};
61
62/// The OTA Requestor device type: a node that obtains and applies software
63/// updates. It hosts the OTA Software Update Requestor cluster (server) and is a
64/// client of the OTA Software Update Provider cluster.
65pub const DEV_TYPE_OTA_REQUESTOR: DeviceType = DeviceType {
66    dtype: 0x0012,
67    drev: 1,
68};
69
70/// The OTA Provider device type: a node that serves software updates. It hosts
71/// the OTA Software Update Provider cluster (server) and is a client of the OTA
72/// Software Update Requestor cluster.
73pub const DEV_TYPE_OTA_PROVIDER: DeviceType = DeviceType {
74    dtype: 0x0014,
75    drev: 1,
76};
77
78/// A constant representing the On/Off Light device in Matter.
79///
80/// Matter Device Library revision history: rev 1 was Zigbee-3.0
81/// initial; rev 2 was the new data-model-format/notation rewrite; rev 3
82/// swapped the deprecated Scenes cluster (0x0005) for Scenes Management
83/// (0x0062). Conformance tests (TC_DeviceConformance::test_TC_IDM_10_5/_6)
84/// always evaluate the cluster set against the *current* spec, so claiming
85/// the latest revision matches the test framework's expectation.
86///
87/// Note: `On/Off Light` mandates Identify, Groups, On/Off (with the `LT`
88/// Lighting feature), and Scenes Management at rev 3. rs-matter does not
89/// yet implement Scenes Management — applications using this device type
90/// won't pass `test_TC_IDM_10_5` until that gap is closed.
91pub const DEV_TYPE_ON_OFF_LIGHT: DeviceType = DeviceType {
92    dtype: 0x0100,
93    drev: 3,
94};
95
96pub const DEV_TYPE_DIMMABLE_LIGHT: DeviceType = DeviceType {
97    dtype: 0x0101,
98    drev: 3,
99};
100
101/// On/Off Light Switch — a controller device type that mandates the
102/// `OnOff` cluster as a **client** (i.e. it initiates On/Off commands to a
103/// bound light) plus the `Binding` cluster as a server (its address book of
104/// bound targets). See the Matter Device Library spec.
105pub const DEV_TYPE_ON_OFF_LIGHT_SWITCH: DeviceType = DeviceType {
106    dtype: 0x0103,
107    drev: 3,
108};
109
110/// Generic Switch — a device type for a button/switch that reports user
111/// presses via the `Switch` cluster (as a **server**), emitting events such as
112/// `InitialPress`/`ShortRelease`. Ecosystems surface these events as automation
113/// triggers. Unlike `DEV_TYPE_ON_OFF_LIGHT_SWITCH`, it does not bind to or
114/// command any device itself. See the Matter Device Library spec.
115pub const DEV_TYPE_GENERIC_SWITCH: DeviceType = DeviceType {
116    dtype: 0x000F,
117    drev: 2,
118};
119
120/// Extended Color Light — mandates OnOff, LevelControl, and
121/// ColorControl with the full feature set (HUE_AND_SATURATION, XY,
122/// COLOR_TEMPERATURE, ENHANCED_HUE, COLOR_LOOP).
123pub const DEV_TYPE_EXTENDED_COLOR_LIGHT: DeviceType = DeviceType {
124    dtype: 0x010D,
125    drev: 4,
126};
127
128/// A constant representing the Smart Speaker device in Matter.
129pub const DEV_TYPE_SMART_SPEAKER: DeviceType = DeviceType {
130    dtype: 0x0022,
131    drev: 2,
132};
133
134/// A constant representing the casting video player device in Matter.
135pub const DEV_TYPE_CASTING_VIDEO_PLAYER: DeviceType = DeviceType {
136    dtype: 0x0023,
137    drev: 1,
138};
139
140/// A constant representing the video player device in Matter.
141pub const DEV_TYPE_VIDEO_PLAYER: DeviceType = DeviceType {
142    dtype: 0x0028,
143    drev: 1,
144};
145
146/// A macro to generate the devices for an endpoint.
147#[allow(unused_macros)]
148#[macro_export]
149macro_rules! devices {
150    ($($device:expr $(,)?)*) => {
151        &[
152            $($device,)*
153        ]
154    }
155}