Skip to content

Commit 2e5017f

Browse files
Implement codegen for global things
1 parent f51ac2f commit 2e5017f

File tree

55 files changed

+4609
-271
lines changed

Some content is hidden

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

55 files changed

+4609
-271
lines changed

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+19
Original file line numberDiff line numberDiff line change
@@ -6826,6 +6826,7 @@ internal cluster UnitTesting = 4294048773 {
68266826
SimpleBitmap f = 5;
68276827
single g = 6;
68286828
double h = 7;
6829+
optional TestGlobalEnum i = 8;
68296830
}
68306831

68316832
fabric_scoped struct TestFabricScoped {
@@ -6858,6 +6859,7 @@ internal cluster UnitTesting = 4294048773 {
68586859
int8u a = 0;
68596860
boolean b = 1;
68606861
SimpleStruct c = 2;
6862+
optional TestGlobalStruct d = 3;
68616863
}
68626864

68636865
struct NestedStructList {
@@ -6943,6 +6945,8 @@ internal cluster UnitTesting = 4294048773 {
69436945
timedwrite attribute boolean timedWriteBoolean = 48;
69446946
attribute boolean generalErrorBoolean = 49;
69456947
attribute boolean clusterErrorBoolean = 50;
6948+
attribute TestGlobalEnum globalEnum = 51;
6949+
attribute TestGlobalStruct globalStruct = 52;
69466950
attribute optional boolean unsupported = 255;
69476951
attribute nullable boolean nullableBoolean = 16384;
69486952
attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385;
@@ -6978,6 +6982,8 @@ internal cluster UnitTesting = 4294048773 {
69786982
attribute nullable int16u nullableRangeRestrictedInt16u = 16424;
69796983
attribute nullable int16s nullableRangeRestrictedInt16s = 16425;
69806984
attribute optional int8u writeOnlyInt8u = 16426;
6985+
attribute nullable TestGlobalEnum nullableGlobalEnum = 16435;
6986+
attribute nullable TestGlobalStruct nullableGlobalStruct = 16436;
69816987
attribute int8u meiInt8u = 4294070017;
69826988
readonly attribute command_id generatedCommandList[] = 65528;
69836989
readonly attribute command_id acceptedCommandList[] = 65529;
@@ -7129,6 +7135,11 @@ internal cluster UnitTesting = 4294048773 {
71297135
SimpleEnum arg2 = 1;
71307136
}
71317137

7138+
response struct GlobalEchoResponse = 14 {
7139+
TestGlobalStruct field1 = 0;
7140+
TestGlobalEnum field2 = 1;
7141+
}
7142+
71327143
request struct TestNullableOptionalRequestRequest {
71337144
optional nullable int8u arg1 = 0;
71347145
}
@@ -7182,6 +7193,11 @@ internal cluster UnitTesting = 4294048773 {
71827193
octet_string payload = 0;
71837194
}
71847195

7196+
request struct GlobalEchoRequestRequest {
7197+
TestGlobalStruct field1 = 0;
7198+
TestGlobalEnum field2 = 1;
7199+
}
7200+
71857201
request struct TestDifferentVendorMeiRequestRequest {
71867202
int8u arg1 = 0;
71877203
}
@@ -7265,6 +7281,9 @@ internal cluster UnitTesting = 4294048773 {
72657281
the string back. If the string is large then it would require a session that
72667282
supports large payloads. */
72677283
command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24;
7284+
/** Command that takes arguments that are global structs/enums and the
7285+
response just echoes them back. */
7286+
command GlobalEchoRequest(GlobalEchoRequestRequest): GlobalEchoResponse = 25;
72687287
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
72697288
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
72707289
}

examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter

+19
Original file line numberDiff line numberDiff line change
@@ -5475,6 +5475,7 @@ internal cluster UnitTesting = 4294048773 {
54755475
SimpleBitmap f = 5;
54765476
single g = 6;
54775477
double h = 7;
5478+
optional TestGlobalEnum i = 8;
54785479
}
54795480

54805481
fabric_scoped struct TestFabricScoped {
@@ -5507,6 +5508,7 @@ internal cluster UnitTesting = 4294048773 {
55075508
int8u a = 0;
55085509
boolean b = 1;
55095510
SimpleStruct c = 2;
5511+
optional TestGlobalStruct d = 3;
55105512
}
55115513

55125514
struct NestedStructList {
@@ -5592,6 +5594,8 @@ internal cluster UnitTesting = 4294048773 {
55925594
timedwrite attribute boolean timedWriteBoolean = 48;
55935595
attribute boolean generalErrorBoolean = 49;
55945596
attribute boolean clusterErrorBoolean = 50;
5597+
attribute TestGlobalEnum globalEnum = 51;
5598+
attribute TestGlobalStruct globalStruct = 52;
55955599
attribute optional boolean unsupported = 255;
55965600
attribute nullable boolean nullableBoolean = 16384;
55975601
attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385;
@@ -5627,6 +5631,8 @@ internal cluster UnitTesting = 4294048773 {
56275631
attribute nullable int16u nullableRangeRestrictedInt16u = 16424;
56285632
attribute nullable int16s nullableRangeRestrictedInt16s = 16425;
56295633
attribute optional int8u writeOnlyInt8u = 16426;
5634+
attribute nullable TestGlobalEnum nullableGlobalEnum = 16435;
5635+
attribute nullable TestGlobalStruct nullableGlobalStruct = 16436;
56305636
attribute int8u meiInt8u = 4294070017;
56315637
readonly attribute command_id generatedCommandList[] = 65528;
56325638
readonly attribute command_id acceptedCommandList[] = 65529;
@@ -5778,6 +5784,11 @@ internal cluster UnitTesting = 4294048773 {
57785784
SimpleEnum arg2 = 1;
57795785
}
57805786

5787+
response struct GlobalEchoResponse = 14 {
5788+
TestGlobalStruct field1 = 0;
5789+
TestGlobalEnum field2 = 1;
5790+
}
5791+
57815792
request struct TestNullableOptionalRequestRequest {
57825793
optional nullable int8u arg1 = 0;
57835794
}
@@ -5831,6 +5842,11 @@ internal cluster UnitTesting = 4294048773 {
58315842
octet_string payload = 0;
58325843
}
58335844

5845+
request struct GlobalEchoRequestRequest {
5846+
TestGlobalStruct field1 = 0;
5847+
TestGlobalEnum field2 = 1;
5848+
}
5849+
58345850
request struct TestDifferentVendorMeiRequestRequest {
58355851
int8u arg1 = 0;
58365852
}
@@ -5914,6 +5930,9 @@ internal cluster UnitTesting = 4294048773 {
59145930
the string back. If the string is large then it would require a session that
59155931
supports large payloads. */
59165932
command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24;
5933+
/** Command that takes arguments that are global structs/enums and the
5934+
response just echoes them back. */
5935+
command GlobalEchoRequest(GlobalEchoRequestRequest): GlobalEchoResponse = 25;
59175936
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
59185937
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
59195938
}

examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter

+19
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,7 @@ internal cluster UnitTesting = 4294048773 {
14941494
SimpleBitmap f = 5;
14951495
single g = 6;
14961496
double h = 7;
1497+
optional TestGlobalEnum i = 8;
14971498
}
14981499

14991500
fabric_scoped struct TestFabricScoped {
@@ -1526,6 +1527,7 @@ internal cluster UnitTesting = 4294048773 {
15261527
int8u a = 0;
15271528
boolean b = 1;
15281529
SimpleStruct c = 2;
1530+
optional TestGlobalStruct d = 3;
15291531
}
15301532

15311533
struct NestedStructList {
@@ -1611,6 +1613,8 @@ internal cluster UnitTesting = 4294048773 {
16111613
timedwrite attribute boolean timedWriteBoolean = 48;
16121614
attribute boolean generalErrorBoolean = 49;
16131615
attribute boolean clusterErrorBoolean = 50;
1616+
attribute TestGlobalEnum globalEnum = 51;
1617+
attribute TestGlobalStruct globalStruct = 52;
16141618
attribute optional boolean unsupported = 255;
16151619
attribute nullable boolean nullableBoolean = 16384;
16161620
attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385;
@@ -1646,6 +1650,8 @@ internal cluster UnitTesting = 4294048773 {
16461650
attribute nullable int16u nullableRangeRestrictedInt16u = 16424;
16471651
attribute nullable int16s nullableRangeRestrictedInt16s = 16425;
16481652
attribute optional int8u writeOnlyInt8u = 16426;
1653+
attribute nullable TestGlobalEnum nullableGlobalEnum = 16435;
1654+
attribute nullable TestGlobalStruct nullableGlobalStruct = 16436;
16491655
attribute int8u meiInt8u = 4294070017;
16501656
readonly attribute command_id generatedCommandList[] = 65528;
16511657
readonly attribute command_id acceptedCommandList[] = 65529;
@@ -1797,6 +1803,11 @@ internal cluster UnitTesting = 4294048773 {
17971803
SimpleEnum arg2 = 1;
17981804
}
17991805

1806+
response struct GlobalEchoResponse = 14 {
1807+
TestGlobalStruct field1 = 0;
1808+
TestGlobalEnum field2 = 1;
1809+
}
1810+
18001811
request struct TestNullableOptionalRequestRequest {
18011812
optional nullable int8u arg1 = 0;
18021813
}
@@ -1850,6 +1861,11 @@ internal cluster UnitTesting = 4294048773 {
18501861
octet_string payload = 0;
18511862
}
18521863

1864+
request struct GlobalEchoRequestRequest {
1865+
TestGlobalStruct field1 = 0;
1866+
TestGlobalEnum field2 = 1;
1867+
}
1868+
18531869
request struct TestDifferentVendorMeiRequestRequest {
18541870
int8u arg1 = 0;
18551871
}
@@ -1933,6 +1949,9 @@ internal cluster UnitTesting = 4294048773 {
19331949
the string back. If the string is large then it would require a session that
19341950
supports large payloads. */
19351951
command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24;
1952+
/** Command that takes arguments that are global structs/enums and the
1953+
response just echoes them back. */
1954+
command GlobalEchoRequest(GlobalEchoRequestRequest): GlobalEchoResponse = 25;
19361955
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
19371956
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
19381957
}

src/app/zap-templates/zcl/data-model/chip/test-cluster.xml

+29
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@ limitations under the License.
5858
<item name="f" type="SimpleBitmap" optional="false"/>
5959
<item name="g" type="single" optional="false"/>
6060
<item name="h" type="double" optional="false"/>
61+
<item name="i" type="TestGlobalEnum" optional="true"/>
6162
</struct>
6263

6364
<struct name="NestedStruct">
6465
<cluster code="0xFFF1FC05"/>
6566
<item name="a" type="int8u" optional="false"/>
6667
<item name="b" type="boolean" optional="false"/>
6768
<item name="c" type="SimpleStruct" optional="false"/>
69+
<item name="d" type="TestGlobalStruct" optional="true"/>
6870
</struct>
6971

7072
<struct name="NestedStructList">
@@ -198,6 +200,9 @@ limitations under the License.
198200
<attribute side="server" code="0x0032" define="CLUSTER_ERROR_BOOLEAN"
199201
type="boolean" writable="true" optional="false">cluster_error_boolean</attribute>
200202

203+
<attribute side="server" code="0x0033" define="GLOBAL_ENUM" type="TestGlobalEnum" writable="true">global_enum</attribute>
204+
<attribute side="server" code="0x0034" define="GLOBAL_STRUCT" type="TestGlobalStruct" writable="true">global_struct</attribute>
205+
201206
<attribute side="server" code="0x4000" define="NULLABLE_BOOLEAN" type="boolean" writable="true" default="false" isNullable="true" optional="false">nullable_boolean</attribute>
202207
<attribute side="server" code="0x4001" define="NULLABLE_BITMAP8" type="Bitmap8MaskMap" writable="true" default="0" isNullable="true" optional="false">nullable_bitmap8</attribute>
203208
<attribute side="server" code="0x4002" define="NULLABLE_BITMAP16" type="Bitmap16MaskMap" writable="true" default="0" isNullable="true" optional="false">nullable_bitmap16</attribute>
@@ -232,8 +237,14 @@ limitations under the License.
232237
<attribute side="server" code="0x4028" define="NULLABLE_RANGE_RESTRICTED_INT16U" type="int16u" min="100" max="1000" writable="true" isNullable="true" optional="false" default="200">nullable_range_restricted_int16u</attribute>
233238
<attribute side="server" code="0x4029" define="NULLABLE_RANGE_RESTRICTED_INT16S" type="int16s" min="-150" max="200" writable="true" isNullable="true" optional="false" default="-5">nullable_range_restricted_int16s</attribute>
234239

240+
<!-- NOTE: write_only_int8u should not have been added in the 0x4... range
241+
where the nullable versions of attributes go, but now we have to be a
242+
bit careful about our attribute IDs as a result. -->
235243
<attribute side="server" code="0x402A" define="WRITE_ONLY_INT8U" type="int8u" writable="true" default="0" optional="true">write_only_int8u</attribute>
236244

245+
<attribute side="server" code="0x4033" define="NULLABLE_GLOBAL_ENUM" type="TestGlobalEnum" isNullable="true" writable="true">nullable_global_enum</attribute>
246+
<attribute side="server" code="0x4034" define="NULLABLE_GLOBAL_STRUCT" type="TestGlobalStruct" isNullable="true" writable="true">nullable_global_struct</attribute>
247+
237248
<!-- Attribute MEI sample having a different vendor ID than the cluster. -->
238249
<attribute side="server" code="0xFFF24F01" define="MEI_INT8U" type="int8u" writable="true" default="0" optional="false">mei_int8u</attribute>
239250

@@ -474,6 +485,16 @@ limitations under the License.
474485
<arg name="payload" type="octet_string"/>
475486
</command>
476487

488+
<command source="client" code="0x19" name="GlobalEchoRequest"
489+
response="GlobalEchoResponse" optional="true">
490+
<description>
491+
Command that takes arguments that are global structs/enums and the
492+
response just echoes them back.
493+
</description>
494+
<arg name="field1" type="TestGlobalStruct"/>
495+
<arg name="field2" type="TestGlobalEnum"/>
496+
</command>
497+
477498
<command source="client" code="0xFFF200AA" name="TestDifferentVendorMeiRequest"
478499
optional="true" response="TestDifferentVendorMeiResponse">
479500
<description>
@@ -622,6 +643,14 @@ limitations under the License.
622643
<arg name="payload" type="octet_string"/>
623644
</command>
624645

646+
<command source="server" code="0x0E" name="GlobalEchoResponse" optional="true" disableDefaultResponse="true">
647+
<description>
648+
Response to GlobalEchoRequest.
649+
</description>
650+
<arg name="field1" type="TestGlobalStruct"/>
651+
<arg name="field2" type="TestGlobalEnum"/>
652+
</command>
653+
625654
<command source="server" code="0xFFF200BB" name="TestDifferentVendorMeiResponse" optional="true" disableDefaultResponse="true">
626655
<description>
627656
Response to TestDifferentVendorMeiRequest, which is a command having a different MEI vendor ID than the cluster.

src/app/zap-templates/zcl/zcl-with-test-extensions.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@
299299
"struct_attr",
300300
"nullable_struct",
301301
"general_error_boolean",
302-
"cluster_error_boolean"
302+
"cluster_error_boolean",
303+
"global_struct",
304+
"nullable_global_struct"
303305
],
304306
"Thread Network Diagnostics": [
305307
"Channel",

src/app/zap-templates/zcl/zcl.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@
297297
"struct_attr",
298298
"nullable_struct",
299299
"general_error_boolean",
300-
"cluster_error_boolean"
300+
"cluster_error_boolean",
301+
"global_struct",
302+
"nullable_global_struct"
301303
],
302304
"Thread Network Diagnostics": [
303305
"Channel",

src/controller/data_model/controller-clusters.matter

+19
Original file line numberDiff line numberDiff line change
@@ -9676,6 +9676,7 @@ internal cluster UnitTesting = 4294048773 {
96769676
SimpleBitmap f = 5;
96779677
single g = 6;
96789678
double h = 7;
9679+
optional TestGlobalEnum i = 8;
96799680
}
96809681

96819682
fabric_scoped struct TestFabricScoped {
@@ -9708,6 +9709,7 @@ internal cluster UnitTesting = 4294048773 {
97089709
int8u a = 0;
97099710
boolean b = 1;
97109711
SimpleStruct c = 2;
9712+
optional TestGlobalStruct d = 3;
97119713
}
97129714

97139715
struct NestedStructList {
@@ -9793,6 +9795,8 @@ internal cluster UnitTesting = 4294048773 {
97939795
timedwrite attribute boolean timedWriteBoolean = 48;
97949796
attribute boolean generalErrorBoolean = 49;
97959797
attribute boolean clusterErrorBoolean = 50;
9798+
attribute TestGlobalEnum globalEnum = 51;
9799+
attribute TestGlobalStruct globalStruct = 52;
97969800
attribute optional boolean unsupported = 255;
97979801
attribute nullable boolean nullableBoolean = 16384;
97989802
attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385;
@@ -9828,6 +9832,8 @@ internal cluster UnitTesting = 4294048773 {
98289832
attribute nullable int16u nullableRangeRestrictedInt16u = 16424;
98299833
attribute nullable int16s nullableRangeRestrictedInt16s = 16425;
98309834
attribute optional int8u writeOnlyInt8u = 16426;
9835+
attribute nullable TestGlobalEnum nullableGlobalEnum = 16435;
9836+
attribute nullable TestGlobalStruct nullableGlobalStruct = 16436;
98319837
attribute int8u meiInt8u = 4294070017;
98329838
readonly attribute command_id generatedCommandList[] = 65528;
98339839
readonly attribute command_id acceptedCommandList[] = 65529;
@@ -9979,6 +9985,11 @@ internal cluster UnitTesting = 4294048773 {
99799985
SimpleEnum arg2 = 1;
99809986
}
99819987

9988+
response struct GlobalEchoResponse = 14 {
9989+
TestGlobalStruct field1 = 0;
9990+
TestGlobalEnum field2 = 1;
9991+
}
9992+
99829993
request struct TestNullableOptionalRequestRequest {
99839994
optional nullable int8u arg1 = 0;
99849995
}
@@ -10032,6 +10043,11 @@ internal cluster UnitTesting = 4294048773 {
1003210043
octet_string payload = 0;
1003310044
}
1003410045

10046+
request struct GlobalEchoRequestRequest {
10047+
TestGlobalStruct field1 = 0;
10048+
TestGlobalEnum field2 = 1;
10049+
}
10050+
1003510051
request struct TestDifferentVendorMeiRequestRequest {
1003610052
int8u arg1 = 0;
1003710053
}
@@ -10115,6 +10131,9 @@ internal cluster UnitTesting = 4294048773 {
1011510131
the string back. If the string is large then it would require a session that
1011610132
supports large payloads. */
1011710133
command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24;
10134+
/** Command that takes arguments that are global structs/enums and the
10135+
response just echoes them back. */
10136+
command GlobalEchoRequest(GlobalEchoRequestRequest): GlobalEchoResponse = 25;
1011810137
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
1011910138
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
1012010139
}

0 commit comments

Comments
 (0)