Skip to content

Commit 15fed34

Browse files
authored
Merge branch 'master' into add-water-heater-management-to-all-clusters-app
2 parents a7f74bd + f8d8c22 commit 15fed34

31 files changed

+934
-536
lines changed

examples/chip-tool/templates/ComplexArgumentParser-src.zapt

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
{{#zcl_structs}}
66
{{#if has_more_than_one_cluster}}
77
{{> struct_parser_impl namespace="detail"}}
8+
{{else if has_no_clusters}}
9+
{{> struct_parser_impl namespace="Globals"}}
810
{{/if}}
911
{{/zcl_structs}}
1012

examples/chip-tool/templates/ComplexArgumentParser.zapt

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
{{#zcl_structs}}
99
{{#if has_more_than_one_cluster}}
1010
{{> struct_parser_decl namespace="detail"}}
11+
{{else if has_no_clusters}}
12+
{{> struct_parser_decl namespace="Globals"}}
1113
{{/if}}
1214
{{/zcl_structs}}
1315

examples/chip-tool/templates/logging/DataModelLogger-src.zapt

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ using namespace chip::app::Clusters;
77
{{#zcl_structs}}
88
{{#if has_more_than_one_cluster}}
99
{{> struct_logger_impl namespace="detail"}}
10+
{{else if has_no_clusters}}
11+
{{> struct_logger_impl namespace="Globals"}}
1012
{{/if}}
1113
{{/zcl_structs}}
1214

examples/chip-tool/templates/logging/DataModelLogger.zapt

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
{{#zcl_structs}}
77
{{#if has_more_than_one_cluster}}
88
{{> struct_logger_decl namespace="detail"}}
9+
{{else if has_no_clusters}}
10+
{{> struct_logger_decl namespace="Globals"}}
911
{{/if}}
1012
{{/zcl_structs}}
1113

scripts/py_matter_idl/matter_idl/backwards_compatibility.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def attribute_name(attribute: Attribute) -> str:
5454

5555
def not_stable(maturity: ApiMaturity):
5656
"""Determine if the given api maturity allows binary/api changes or not."""
57-
# TODO: internal and deprecated not currently widely used,
58-
# so we enforce stability on them for now.
59-
return maturity == ApiMaturity.PROVISIONAL
57+
# NOTE: deprecated are not to be used, so we expect no changes. They were
58+
# probably "stable" at some point
59+
return (maturity == ApiMaturity.PROVISIONAL) or (maturity == ApiMaturity.INTERNAL)
6060

6161

6262
class CompatibilityChecker:

scripts/py_matter_idl/matter_idl/test_backwards_compatibility.py

+7
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ def test_provisional_cluster(self):
188188
"provisional server cluster A = 16 { enum X : ENUM8 { A = 1; B = 3; } info event A = 2 { int16u x = 1;} }",
189189
Compatibility.ALL_OK)
190190

191+
def test_internal_cluster(self):
192+
self.ValidateUpdate(
193+
"Internal cluster changes are ok.",
194+
"internal server cluster A = 16 { enum X : ENUM8 { A = 1; B = 2; } info event A = 1 { int8u x = 1;} }",
195+
"internal server cluster A = 16 { enum X : ENUM8 { A = 1; B = 3; } info event A = 2 { int16u x = 1;} }",
196+
Compatibility.ALL_OK)
197+
191198
def test_clusters_enum_code(self):
192199
self.ValidateUpdate(
193200
"Adding an enum is ok. Also validates code formatting",

src/app/common/templates/templates.json

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
"name": "cluster_enums_enum",
2626
"path": "../../zap-templates/partials/cluster-enums-enum.zapt"
2727
},
28+
{
29+
"name": "cluster_enums_ensure_known_value",
30+
"path": "../../zap-templates/partials/cluster-enums-ensure-known-value.zapt"
31+
},
2832
{
2933
"name": "cluster_objects_field_init",
3034
"path": "../../zap-templates/partials/cluster-objects-field-init.zapt"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{#unless (isInConfigList (concat ns "::" label) "EnumsNotUsedAsTypeInXML")}}
2+
static auto __attribute__((unused)) EnsureKnownEnumValue({{ns}}::{{asType label}} val)
3+
{
4+
using EnumType = {{ns}}::{{asType label}};
5+
switch (val) {
6+
{{#zcl_enum_items}}
7+
case EnumType::k{{asUpperCamelCase label}}:
8+
{{/zcl_enum_items}}
9+
return val;
10+
default:
11+
return EnumType::kUnknownEnumValue;
12+
}
13+
}
14+
{{/unless}}

src/app/zap-templates/templates/app/cluster-enums-check.zapt

+5-28
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,17 @@ namespace app {
99
namespace Clusters {
1010
{{#zcl_enums}}
1111
{{#if has_more_than_one_cluster}}
12-
{{#unless (isInConfigList (concat "::" label) "EnumsNotUsedAsTypeInXML")}}
13-
static auto __attribute__((unused)) EnsureKnownEnumValue(detail::{{asType label}} val)
14-
{
15-
using EnumType = detail::{{asType label}};
16-
switch (val) {
17-
{{#zcl_enum_items}}
18-
case EnumType::k{{asUpperCamelCase label}}:
19-
{{/zcl_enum_items}}
20-
return val;
21-
default:
22-
return EnumType::kUnknownEnumValue;
23-
}
24-
}
25-
{{/unless}}
12+
{{> cluster_enums_ensure_known_value ns="detail"}}
13+
{{else if has_no_clusters}}
14+
{{> cluster_enums_ensure_known_value ns="Globals"}}
15+
2616
{{/if}}
2717
{{/zcl_enums}}
2818

2919
{{#zcl_clusters}}
3020
{{#zcl_enums}}
3121
{{#unless has_more_than_one_cluster}}
32-
{{#unless (isInConfigList (concat (asUpperCamelCase ../name) "::" label) "EnumsNotUsedAsTypeInXML")}}
33-
static auto __attribute__((unused)) EnsureKnownEnumValue({{asUpperCamelCase ../name}}::{{asType label}} val)
34-
{
35-
using EnumType = {{asUpperCamelCase ../name}}::{{asType label}};
36-
switch (val) {
37-
{{#zcl_enum_items}}
38-
case EnumType::k{{asUpperCamelCase label}}:
39-
{{/zcl_enum_items}}
40-
return val;
41-
default:
42-
return EnumType::kUnknownEnumValue;
43-
}
44-
}
45-
{{/unless}}
22+
{{> cluster_enums_ensure_known_value ns=(asUpperCamelCase ../name)}}
4623
{{/unless}}
4724
{{/zcl_enums}}
4825

src/app/zap-templates/templates/app/cluster-enums.zapt

+31
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,37 @@ k{{asUpperCamelCase label}} = {{asHex mask}},
3737

3838
} // namespace detail
3939

40+
namespace Globals {
41+
// Global enums.
42+
{{#zcl_enums}}
43+
44+
{{#if has_no_clusters}}
45+
46+
{{> cluster_enums_enum ns=""}}
47+
48+
{{/if}}
49+
{{/zcl_enums}}
50+
51+
// Global bitmaps.
52+
{{#zcl_bitmaps}}
53+
54+
{{#if has_no_clusters}}
55+
{{! Work around https://github.com/project-chip/zap/issues/1370 and manually filter out built-in bitmap types. }}
56+
{{#if_is_atomic label}}
57+
{{else}}
58+
59+
// Bitmap for {{label}}
60+
enum class {{asType label}} : {{asUnderlyingZclType name}} {
61+
{{#zcl_bitmap_items}}
62+
k{{asUpperCamelCase label}} = {{asHex mask}},
63+
{{/zcl_bitmap_items}}
64+
};
65+
66+
{{/if_is_atomic}}
67+
{{/if}}
68+
{{/zcl_bitmaps}}
69+
70+
} // namespace Globals
4071

4172
{{#zcl_clusters}}
4273
namespace {{asUpperCamelCase name}} {

src/app/zap-templates/templates/app/cluster-objects-src.zapt

+12
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ namespace Structs {
6464
} // namespace Structs
6565
} // namespace detail
6666

67+
namespace Globals {
68+
// Global structs
69+
namespace Structs {
70+
{{#zcl_structs}}
71+
{{#if has_no_clusters}}
72+
{{> cluster_objects_struct header=false}}
73+
74+
{{/if}}
75+
{{/zcl_structs}}
76+
} // namespace Structs
77+
} // namespace Globals
78+
6779
{{#zcl_clusters}}
6880
namespace {{asUpperCamelCase name}} {
6981
{{#zcl_structs}}

src/app/zap-templates/templates/app/cluster-objects.zapt

+12
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ namespace Structs {
3535
} // namespace detail
3636

3737
namespace Globals {
38+
39+
// Global structs.
40+
namespace Structs {
41+
42+
{{#zcl_structs}}
43+
{{#if has_no_clusters}}
44+
{{> cluster_objects_struct header=true}}
45+
46+
{{/if}}
47+
{{/zcl_structs}}
48+
} // namespace Structs
49+
3850
namespace Attributes {
3951
{{#zcl_attributes_server}}
4052
{{#unless clusterRef}}

src/controller/python/chip/clusters/Attribute.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def _BuildClusterIndex():
288288
''' Build internal cluster index for locating the corresponding cluster object by path in the future.
289289
'''
290290
for clusterName, obj in inspect.getmembers(sys.modules['chip.clusters.Objects']):
291-
if ('chip.clusters.Objects' in str(obj)) and inspect.isclass(obj):
291+
if ('chip.clusters.Objects' in str(obj)) and inspect.isclass(obj) and issubclass(obj, Cluster):
292292
_ClusterIndex[obj.id] = obj
293293

294294

0 commit comments

Comments
 (0)