Skip to content

Commit 0da2fd0

Browse files
committed
Implement DeviceType and map time functions
1 parent 9517983 commit 0da2fd0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+6748
-75
lines changed

Generator/ClusterGenerator.cs

Lines changed: 97 additions & 62 deletions
Large diffs are not rendered by default.

Generator/DeviceTypeGenerator.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// MatterDotNet Copyright (C) 2025
2+
//
3+
// This program is free software: you can redistribute it and/or modify
4+
// it under the terms of the GNU Affero General Public License as published by
5+
// the Free Software Foundation, either version 3 of the License, or any later version.
6+
// This program is distributed in the hope that it will be useful,
7+
// but WITHOUT ANY WARRANTY, without even the implied warranty of
8+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9+
// See the GNU Affero General Public License for more details.
10+
// You should have received a copy of the GNU Affero General Public License
11+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
12+
13+
using Generator.Schema;
14+
using System.Collections.Immutable;
15+
using System.Text;
16+
using System.Xml.Serialization;
17+
18+
namespace Generator
19+
{
20+
public class DeviceTypeGenerator
21+
{
22+
private static HashSet<string> includes = new HashSet<string>();
23+
public static void Generate()
24+
{
25+
XmlSerializer deserializer = new XmlSerializer(typeof(DeviceType));
26+
IEnumerable<string> deviceTypeXMLs = Directory.EnumerateFiles("..\\..\\..\\DeviceTypes");
27+
StreamWriter deviceTypeEnum = new StreamWriter("outputs\\DeviceType.cs");
28+
deviceTypeEnum.NewLine = "\n";
29+
deviceTypeEnum.WriteLine("// MatterDotNet Copyright (C) 2025 \n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or any later version.\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY, without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n// See the GNU Affero General Public License for more details.\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <http://www.gnu.org/licenses/>.\n//\n// WARNING: This file was auto-generated. Do not edit.\n");
30+
deviceTypeEnum.WriteLine("namespace MatterDotNet\n{\n /// <summary>\n /// Matter Device Type\n /// </summary>\n public enum DeviceTypeEnum : uint\n {");
31+
foreach (string deviceTypeXML in deviceTypeXMLs)
32+
{
33+
includes.Clear();
34+
if (deviceTypeXML.EndsWith(".xml"))
35+
{
36+
Console.WriteLine("Generating " + deviceTypeXML + "...");
37+
DeviceType? deviceTypeObject = deserializer.Deserialize(File.OpenRead(deviceTypeXML)) as DeviceType;
38+
if (deviceTypeObject == null)
39+
throw new IOException("Failed to parse device type " + deviceTypeXML);
40+
if (!string.IsNullOrEmpty(deviceTypeObject.id))
41+
{
42+
deviceTypeEnum.WriteLine($" /// <summary>\n /// {deviceTypeObject.name} Type\n /// </summary>");
43+
deviceTypeEnum.WriteLine($" {deviceTypeObject.name.Replace(" ", "").Replace('/', '_').Replace("-", "")} = {deviceTypeObject.id},");
44+
}
45+
}
46+
}
47+
deviceTypeEnum.WriteLine(" }\n}");
48+
deviceTypeEnum.Close();
49+
}
50+
}
51+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
Copyright (C) Connectivity Standards Alliance (2021). All rights reserved.
4+
The information within this document is the property of the Connectivity
5+
Standards Alliance and its use and disclosure are restricted, except as
6+
expressly set forth herein.
7+
8+
Connectivity Standards Alliance hereby grants you a fully-paid, non-exclusive,
9+
nontransferable, worldwide, limited and revocable license (without the right to
10+
sublicense), under Connectivity Standards Alliance's applicable copyright
11+
rights, to view, download, save, reproduce and use the document solely for your
12+
own internal purposes and in accordance with the terms of the license set forth
13+
herein. This license does not authorize you to, and you expressly warrant that
14+
you shall not: (a) permit others (outside your organization) to use this
15+
document; (b) post or publish this document; (c) modify, adapt, translate, or
16+
otherwise change this document in any manner or create any derivative work
17+
based on this document; (d) remove or modify any notice or label on this
18+
document, including this Copyright Notice, License and Disclaimer. The
19+
Connectivity Standards Alliance does not grant you any license hereunder other
20+
than as expressly stated herein.
21+
22+
Elements of this document may be subject to third party intellectual property
23+
rights, including without limitation, patent, copyright or trademark rights,
24+
and any such third party may or may not be a member of the Connectivity
25+
Standards Alliance. Connectivity Standards Alliance members grant other
26+
Connectivity Standards Alliance members certain intellectual property rights as
27+
set forth in the Connectivity Standards Alliance IPR Policy. Connectivity
28+
Standards Alliance members do not grant you any rights under this license. The
29+
Connectivity Standards Alliance is not responsible for, and shall not be held
30+
responsible in any manner for, identifying or failing to identify any or all
31+
such third party intellectual property rights. Please visit www.csa-iot.org for
32+
more information on how to become a member of the Connectivity Standards
33+
Alliance.
34+
35+
This document and the information contained herein are provided on an “AS IS”
36+
basis and the Connectivity Standards Alliance DISCLAIMS ALL WARRANTIES EXPRESS
37+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO (A) ANY WARRANTY THAT THE USE OF THE
38+
INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OF THIRD PARTIES (INCLUDING
39+
WITHOUT LIMITATION ANY INTELLECTUAL PROPERTY RIGHTS INCLUDING PATENT, COPYRIGHT
40+
OR TRADEMARK RIGHTS); OR (B) ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
41+
FOR A PARTICULAR PURPOSE, TITLE OR NONINFRINGEMENT. IN NO EVENT WILL THE
42+
CONNECTIVITY STANDARDS ALLIANCE BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF
43+
BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF BUSINESS, OR FOR ANY OTHER
44+
DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
45+
DAMAGES OF ANY KIND, IN CONTRACT OR IN TORT, IN CONNECTION WITH THIS DOCUMENT
46+
OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
47+
LOSS OR DAMAGE.
48+
49+
All company, brand and product names in this document may be trademarks that
50+
are the sole property of their respective owners.
51+
52+
This notice and disclaimer must be included on all copies of this document.
53+
54+
Connectivity Standards Alliance
55+
508 Second Street, Suite 206
56+
Davis, CA 95616, USA
57+
-->
58+
<deviceType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="types types.xsd devicetype devicetype.xsd" id="0x000E" name="Aggregator" revision="1">
59+
<revisionHistory>
60+
<revision revision="1" summary="Initial release of this document"/>
61+
</revisionHistory>
62+
<classification class="simple" scope="endpoint"/>
63+
<conditions/>
64+
<clusters>
65+
<cluster id="0x0003" name="Identify" side="server">
66+
<optionalConform/>
67+
</cluster>
68+
<cluster id="0x0025" name="Actions" side="server">
69+
<optionalConform/>
70+
</cluster>
71+
</clusters>
72+
</deviceType>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
Copyright (C) Connectivity Standards Alliance (2023). All rights reserved.
4+
The information within this document is the property of the Connectivity
5+
Standards Alliance and its use and disclosure are restricted, except as
6+
expressly set forth herein.
7+
8+
Connectivity Standards Alliance hereby grants you a fully-paid, non-exclusive,
9+
nontransferable, worldwide, limited and revocable license (without the right to
10+
sublicense), under Connectivity Standards Alliance's applicable copyright
11+
rights, to view, download, save, reproduce and use the document solely for your
12+
own internal purposes and in accordance with the terms of the license set forth
13+
herein. This license does not authorize you to, and you expressly warrant that
14+
you shall not: (a) permit others (outside your organization) to use this
15+
document; (b) post or publish this document; (c) modify, adapt, translate, or
16+
otherwise change this document in any manner or create any derivative work
17+
based on this document; (d) remove or modify any notice or label on this
18+
document, including this Copyright Notice, License and Disclaimer. The
19+
Connectivity Standards Alliance does not grant you any license hereunder other
20+
than as expressly stated herein.
21+
22+
Elements of this document may be subject to third party intellectual property
23+
rights, including without limitation, patent, copyright or trademark rights,
24+
and any such third party may or may not be a member of the Connectivity
25+
Standards Alliance. Connectivity Standards Alliance members grant other
26+
Connectivity Standards Alliance members certain intellectual property rights as
27+
set forth in the Connectivity Standards Alliance IPR Policy. Connectivity
28+
Standards Alliance members do not grant you any rights under this license. The
29+
Connectivity Standards Alliance is not responsible for, and shall not be held
30+
responsible in any manner for, identifying or failing to identify any or all
31+
such third party intellectual property rights. Please visit www.csa-iot.org for
32+
more information on how to become a member of the Connectivity Standards
33+
Alliance.
34+
35+
This document and the information contained herein are provided on an “AS IS”
36+
basis and the Connectivity Standards Alliance DISCLAIMS ALL WARRANTIES EXPRESS
37+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO (A) ANY WARRANTY THAT THE USE OF THE
38+
INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OF THIRD PARTIES (INCLUDING
39+
WITHOUT LIMITATION ANY INTELLECTUAL PROPERTY RIGHTS INCLUDING PATENT, COPYRIGHT
40+
OR TRADEMARK RIGHTS); OR (B) ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
41+
FOR A PARTICULAR PURPOSE, TITLE OR NONINFRINGEMENT. IN NO EVENT WILL THE
42+
CONNECTIVITY STANDARDS ALLIANCE BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF
43+
BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF BUSINESS, OR FOR ANY OTHER
44+
DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
45+
DAMAGES OF ANY KIND, IN CONTRACT OR IN TORT, IN CONNECTION WITH THIS DOCUMENT
46+
OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
47+
LOSS OR DAMAGE.
48+
49+
All company, brand and product names in this document may be trademarks that
50+
are the sole property of their respective owners.
51+
52+
This notice and disclaimer must be included on all copies of this document.
53+
54+
Connectivity Standards Alliance
55+
508 Second Street, Suite 206
56+
Davis, CA 95616, USA
57+
-->
58+
<deviceType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="types types.xsd devicetype devicetype.xsd" id="0x002D" name="Air Purifier" revision="1">
59+
<revisionHistory>
60+
<revision revision="1" summary="Initial Matter release"/>
61+
</revisionHistory>
62+
<classification class="simple" scope="endpoint"/>
63+
<conditions/>
64+
<clusters>
65+
<cluster id="0x0003" name="Identify" side="server">
66+
<mandatoryConform/>
67+
</cluster>
68+
<cluster id="0x0004" name="Groups" side="server">
69+
<optionalConform/>
70+
</cluster>
71+
<cluster id="0x0071" name="HEPA Filter Monitoring" side="server">
72+
<optionalConform/>
73+
</cluster>
74+
<cluster id="0x0072" name="Activated Carbon Filter Monitoring" side="server">
75+
<optionalConform/>
76+
</cluster>
77+
<cluster id="0x0202" name="Fan Control" side="server">
78+
<mandatoryConform/>
79+
</cluster>
80+
</clusters>
81+
</deviceType>
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
Copyright (C) Connectivity Standards Alliance (2023). All rights reserved.
4+
The information within this document is the property of the Connectivity
5+
Standards Alliance and its use and disclosure are restricted, except as
6+
expressly set forth herein.
7+
8+
Connectivity Standards Alliance hereby grants you a fully-paid, non-exclusive,
9+
nontransferable, worldwide, limited and revocable license (without the right to
10+
sublicense), under Connectivity Standards Alliance's applicable copyright
11+
rights, to view, download, save, reproduce and use the document solely for your
12+
own internal purposes and in accordance with the terms of the license set forth
13+
herein. This license does not authorize you to, and you expressly warrant that
14+
you shall not: (a) permit others (outside your organization) to use this
15+
document; (b) post or publish this document; (c) modify, adapt, translate, or
16+
otherwise change this document in any manner or create any derivative work
17+
based on this document; (d) remove or modify any notice or label on this
18+
document, including this Copyright Notice, License and Disclaimer. The
19+
Connectivity Standards Alliance does not grant you any license hereunder other
20+
than as expressly stated herein.
21+
22+
Elements of this document may be subject to third party intellectual property
23+
rights, including without limitation, patent, copyright or trademark rights,
24+
and any such third party may or may not be a member of the Connectivity
25+
Standards Alliance. Connectivity Standards Alliance members grant other
26+
Connectivity Standards Alliance members certain intellectual property rights as
27+
set forth in the Connectivity Standards Alliance IPR Policy. Connectivity
28+
Standards Alliance members do not grant you any rights under this license. The
29+
Connectivity Standards Alliance is not responsible for, and shall not be held
30+
responsible in any manner for, identifying or failing to identify any or all
31+
such third party intellectual property rights. Please visit www.csa-iot.org for
32+
more information on how to become a member of the Connectivity Standards
33+
Alliance.
34+
35+
This document and the information contained herein are provided on an “AS IS”
36+
basis and the Connectivity Standards Alliance DISCLAIMS ALL WARRANTIES EXPRESS
37+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO (A) ANY WARRANTY THAT THE USE OF THE
38+
INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OF THIRD PARTIES (INCLUDING
39+
WITHOUT LIMITATION ANY INTELLECTUAL PROPERTY RIGHTS INCLUDING PATENT, COPYRIGHT
40+
OR TRADEMARK RIGHTS); OR (B) ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
41+
FOR A PARTICULAR PURPOSE, TITLE OR NONINFRINGEMENT. IN NO EVENT WILL THE
42+
CONNECTIVITY STANDARDS ALLIANCE BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF
43+
BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF BUSINESS, OR FOR ANY OTHER
44+
DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
45+
DAMAGES OF ANY KIND, IN CONTRACT OR IN TORT, IN CONNECTION WITH THIS DOCUMENT
46+
OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
47+
LOSS OR DAMAGE.
48+
49+
All company, brand and product names in this document may be trademarks that
50+
are the sole property of their respective owners.
51+
52+
This notice and disclaimer must be included on all copies of this document.
53+
54+
Connectivity Standards Alliance
55+
508 Second Street, Suite 206
56+
Davis, CA 95616, USA
57+
-->
58+
<deviceType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="types types.xsd devicetype devicetype.xsd" id="0x002C" name="Air Quality Sensor" revision="1">
59+
<revisionHistory>
60+
<revision revision="1" summary="Initial release of this document"/>
61+
</revisionHistory>
62+
<classification class="simple" scope="endpoint"/>
63+
<conditions/>
64+
<clusters>
65+
<cluster id="0x0003" name="Identify" side="server">
66+
<mandatoryConform/>
67+
</cluster>
68+
<cluster id="0x005B" name="Air Quality" side="server">
69+
<mandatoryConform/>
70+
</cluster>
71+
<cluster id="0x0402" name="Temperature Measurement" side="server">
72+
<optionalConform/>
73+
</cluster>
74+
<cluster id="0x0405" name="Relative Humidity Measurement" side="server">
75+
<optionalConform/>
76+
</cluster>
77+
<cluster id="0x040C" name="Carbon Monoxide Concentration Measurement" side="server">
78+
<optionalConform/>
79+
</cluster>
80+
<cluster id="0x040D" name="Carbon Dioxide Concentration Measurement" side="server">
81+
<optionalConform/>
82+
</cluster>
83+
<cluster id="0x0413" name="Nitrogen Dioxide Concentration Measurement" side="server">
84+
<optionalConform/>
85+
</cluster>
86+
<cluster id="0x0415" name="Ozone Concentration Measurement" side="server">
87+
<optionalConform/>
88+
</cluster>
89+
<cluster id="0x042A" name="PM2.5 Concentration Measurement" side="server">
90+
<optionalConform/>
91+
</cluster>
92+
<cluster id="0x042B" name="Formaldehyde Concentration Measurement" side="server">
93+
<optionalConform/>
94+
</cluster>
95+
<cluster id="0x042C" name="PM1 Concentration Measurement" side="server">
96+
<optionalConform/>
97+
</cluster>
98+
<cluster id="0x042D" name="PM10 Concentration Measurement" side="server">
99+
<optionalConform/>
100+
</cluster>
101+
<cluster id="0x042E" name="Total Volatile Organic Compounds Concentration Measurement" side="server">
102+
<optionalConform/>
103+
</cluster>
104+
<cluster id="0x042F" name="Radon Concentration Measurement" side="server">
105+
<optionalConform/>
106+
</cluster>
107+
</clusters>
108+
</deviceType>

0 commit comments

Comments
 (0)