Skip to content

Commit f22b534

Browse files
committed
Enable command inheritance
1 parent 1e31fdc commit f22b534

36 files changed

+2868
-119
lines changed

Generator/ClusterGenerator.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1212

1313
using Generator.Schema;
14+
using MatterDotNet;
1415
using System.Collections.Immutable;
1516
using System.Text;
1617
using System.Xml.Serialization;
@@ -262,7 +263,9 @@ private static void WriteStruct(clusterCommand command, bool toServer, TextWrite
262263
case "max":
263264
case "maxCount":
264265
case "maxLength":
265-
if (long.TryParse(field.constraint.value, out long toVal))
266+
if (field.constraint.value == "RESP_MAX Constant Type")
267+
to = Constants.RESP_MAX;
268+
else if (long.TryParse(field.constraint.value, out long toVal))
266269
to = toVal;
267270
break;
268271
case "between":
@@ -395,6 +398,7 @@ private static void WriteStructType(bool optional, bool nullable, string type, s
395398
case "command-id":
396399
case "trans-id":
397400
case "data-ver":
401+
case "AlarmBitmap":
398402
writer.Write($"{totalIndent}writer.WriteUInt({id}, {name}");
399403
if (to != null)
400404
writer.Write($", {to.Value}");
@@ -420,7 +424,7 @@ private static void WriteStructType(bool optional, bool nullable, string type, s
420424
case "elapsed-s":
421425
if (nullable && !optional)
422426
writer.Write($"{totalIndent}if (!{name}.HasValue)\n{totalIndent} writer.WriteNull({id});\n{totalIndent}else\n ");
423-
writer.Write($"{totalIndent}writer.WriteUInt({id}, {name}");
427+
writer.Write($"{totalIndent}writer.WriteUInt({id}, (uint){name}");
424428
if (nullable && !optional)
425429
writer.Write("!.Value.TotalSeconds");
426430
else
@@ -636,6 +640,7 @@ private static void WriteFieldReader(bool optional, bool nullable, string type,
636640
case "command-id":
637641
case "trans-id":
638642
case "data-ver":
643+
case "AlarmBitmap":
639644
writer.Write($"reader.GetUInt({id}");
640645
break;
641646
case "uint40":
@@ -677,7 +682,7 @@ private static void WriteFieldReader(bool optional, bool nullable, string type,
677682
break;
678683
case "elapsed-s":
679684
writer.Write($"TimeSpan.FromSeconds(reader.GetUInt({id}");
680-
extraInsideClose = true;
685+
extraOutsideClose = true;
681686
break;
682687
case "epoch-us":
683688
includes.Add("MatterDotNet.Util");
@@ -900,25 +905,25 @@ private static void WriteCommands(Cluster cluster, TextWriter writer)
900905
}
901906
writer.WriteLine(" };");
902907
if (cmd.access.timed)
903-
writer.WriteLine(" InvokeResponseIB resp = await InteractionManager.ExecTimedCommand(session, endPoint, CLUSTER_ID, commandTimeoutMS, " + cmd.id + ", requestFields);");
908+
writer.WriteLine(" InvokeResponseIB resp = await InteractionManager.ExecTimedCommand(session, endPoint, cluster, commandTimeoutMS, " + cmd.id + ", requestFields);");
904909
else
905-
writer.WriteLine(" InvokeResponseIB resp = await InteractionManager.ExecCommand(session, endPoint, CLUSTER_ID, " + cmd.id + ", requestFields);");
910+
writer.WriteLine(" InvokeResponseIB resp = await InteractionManager.ExecCommand(session, endPoint, cluster, " + cmd.id + ", requestFields);");
906911
}
907912
else
908913
{
909914
if (cmd.response == "N")
910915
{
911916
if (cmd.access.timed)
912-
writer.WriteLine(" await InteractionManager.SendTimedCommand(session, endPoint, CLUSTER_ID, commandTimeoutMS, " + cmd.id + ");");
917+
writer.WriteLine(" await InteractionManager.SendTimedCommand(session, endPoint, cluster, commandTimeoutMS, " + cmd.id + ");");
913918
else
914-
writer.WriteLine(" await InteractionManager.SendCommand(session, endPoint, CLUSTER_ID, " + cmd.id + ");");
919+
writer.WriteLine(" await InteractionManager.SendCommand(session, endPoint, cluster, " + cmd.id + ");");
915920
}
916921
else
917922
{
918923
if (cmd.access.timed)
919-
writer.WriteLine(" InvokeResponseIB resp = await InteractionManager.ExecTimedCommand(session, endPoint, CLUSTER_ID, commandTimeoutMS, " + cmd.id + ");");
924+
writer.WriteLine(" InvokeResponseIB resp = await InteractionManager.ExecTimedCommand(session, endPoint, cluster, commandTimeoutMS, " + cmd.id + ");");
920925
else
921-
writer.WriteLine(" InvokeResponseIB resp = await InteractionManager.ExecCommand(session, endPoint, CLUSTER_ID, " + cmd.id + ");");
926+
writer.WriteLine(" InvokeResponseIB resp = await InteractionManager.ExecCommand(session, endPoint, cluster, " + cmd.id + ");");
922927
}
923928
}
924929
if (response == null)
@@ -1255,6 +1260,7 @@ private static void WriteType(string type, string? entryType, TextWriter writer)
12551260
case "command-id":
12561261
case "trans-id":
12571262
case "data-ver":
1263+
case "AlarmBitmap":
12581264
writer.Write("uint");
12591265
break;
12601266
case "elapsed-s":

Generator/Clusters/AlarmBase.xml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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+
:xrefstyle: basic
59+
-->
60+
<cluster xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="types types.xsd cluster cluster.xsd" id="" name="Alarm Base Cluster" revision="1">
61+
<revisionHistory>
62+
<revision revision="1" summary="Initial revision"/>
63+
</revisionHistory>
64+
<clusterIds>
65+
<clusterId name="Alarm Base"/>
66+
</clusterIds>
67+
<classification hierarchy="base" role="application" picsCode="ALARM" scope="Endpoint"/>
68+
<features>
69+
<feature bit="0" code="RESET" name="Reset" summary="Supports the ability to reset alarms">
70+
<optionalConform/>
71+
</feature>
72+
</features>
73+
<dataTypes>
74+
<number name="AlarmBitmap" type=""/>
75+
</dataTypes>
76+
<attributes>
77+
<attribute id="0x0000" name="Mask" type="AlarmBitmap" default="0">
78+
<access read="true" readPrivilege="view"/>
79+
<mandatoryConform/>
80+
</attribute>
81+
<attribute id="0x0001" name="Latch" type="AlarmBitmap" default="0">
82+
<access read="true" readPrivilege="view"/>
83+
<quality changeOmitted="false" nullable="false" scene="false" persistence="fixed" reportable="false" sourceAttribution="false" quieterReporting="false"/>
84+
<mandatoryConform>
85+
<feature name="RESET"/>
86+
</mandatoryConform>
87+
</attribute>
88+
<attribute id="0x0002" name="State" type="AlarmBitmap" default="0">
89+
<access read="true" readPrivilege="view"/>
90+
<mandatoryConform/>
91+
</attribute>
92+
<attribute id="0x0003" name="Supported" type="AlarmBitmap" default="0">
93+
<access read="true" readPrivilege="view"/>
94+
<quality changeOmitted="false" nullable="false" scene="false" persistence="fixed" reportable="false" sourceAttribution="false" quieterReporting="false"/>
95+
<mandatoryConform/>
96+
</attribute>
97+
</attributes>
98+
<commands>
99+
<command id="0x00" name="Reset" direction="commandToServer" response="Y">
100+
<access invokePrivilege="operate"/>
101+
<mandatoryConform>
102+
<feature name="RESET"/>
103+
</mandatoryConform>
104+
<field id="0" name="Alarms" type="AlarmBitmap" default="0">
105+
<mandatoryConform/>
106+
</field>
107+
</command>
108+
<command id="0x01" name="ModifyEnabledAlarms" direction="commandToServer" response="Y">
109+
<access invokePrivilege="operate"/>
110+
<optionalConform/>
111+
<field id="0" name="Mask" type="AlarmBitmap" default="0">
112+
<mandatoryConform/>
113+
</field>
114+
</command>
115+
</commands>
116+
<events>
117+
<event id="0x00" name="Notify" priority="info">
118+
<access readPrivilege="view"/>
119+
<mandatoryConform/>
120+
<field id="1" name="Active" type="AlarmBitmap" default="0">
121+
<mandatoryConform/>
122+
</field>
123+
<field id="2" name="Inactive" type="AlarmBitmap" default="0">
124+
<mandatoryConform/>
125+
</field>
126+
<field id="3" name="State" type="AlarmBitmap" default="0">
127+
<mandatoryConform/>
128+
</field>
129+
<field id="4" name="Mask" type="AlarmBitmap" default="0">
130+
<mandatoryConform/>
131+
</field>
132+
</event>
133+
</events>
134+
</cluster>

0 commit comments

Comments
 (0)