12
12
#include <app-common/zap-generated/ids/Attributes.h>
13
13
#include <app-common/zap-generated/ids/Clusters.h>
14
14
#include <lib/support/TypeTraits.h>
15
+ #include <lib/core/DataModelTypes.h>
15
16
16
17
using namespace chip;
17
18
using namespace chip::app;
18
19
20
+ static id _Nullable DecodeGlobalAttributeValue(AttributeId aAttributeId, TLV::TLVReader & aReader, CHIP_ERROR * aError)
21
+ {
22
+ using namespace Clusters::Globals;
23
+ switch (aAttributeId) {
24
+ {{#zcl_attributes_server removeKeys='isOptional'}}
25
+ {{#unless clusterRef}}
26
+ {{#if (isSupported "" globalAttribute=(asUpperCamelCase name preserveAcronyms=true))}}
27
+ {{#if (isProvisional "" globalAttribute=(asUpperCamelCase name preserveAcronyms=true))}}
28
+ #if MTR_ENABLE_PROVISIONAL
29
+ {{/if}}
30
+ case Attributes::{{asUpperCamelCase name}}::Id: {
31
+ using TypeInfo = Attributes::{{asUpperCamelCase name}}::TypeInfo;
32
+ TypeInfo::DecodableType cppValue;
33
+ *aError = DataModel::Decode(aReader, cppValue);
34
+ if (*aError != CHIP_NO_ERROR)
35
+ {
36
+ return nil;
37
+ }
38
+ {{asObjectiveCType type ""}} value;
39
+ {{>decode_value target="value" source="cppValue" cluster="" errorCode="*aError = err; return nil;" depth=0}}
40
+ return value;
41
+ }
42
+ {{#if (isProvisional "" globalAttribute=(asUpperCamelCase name preserveAcronyms=true))}}
43
+ #endif // MTR_ENABLE_PROVISIONAL
44
+ {{/if}}
45
+ {{/if}}
46
+ {{/unless}}
47
+ {{/zcl_attributes_server}}
48
+ default: {
49
+ break;
50
+ }
51
+ }
52
+
53
+ *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
54
+ return nil;
55
+ }
56
+
19
57
{{#zcl_clusters}}
20
58
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
21
59
static id _Nullable DecodeAttributeValueFor{{asUpperCamelCase name preserveAcronyms=true}}Cluster(AttributeId aAttributeId, TLV::TLVReader & aReader, CHIP_ERROR * aError)
22
60
{
23
61
using namespace Clusters::{{asUpperCamelCase name}};
24
62
switch (aAttributeId) {
25
63
{{#zcl_attributes_server removeKeys='isOptional'}}
64
+ {{#if clusterRef}}
26
65
{{#if (isSupported (asUpperCamelCase ../name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
27
66
{{#if (isProvisional (asUpperCamelCase ../name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
28
67
#if MTR_ENABLE_PROVISIONAL
@@ -43,6 +82,7 @@ static id _Nullable DecodeAttributeValueFor{{asUpperCamelCase name preserveAcron
43
82
#endif // MTR_ENABLE_PROVISIONAL
44
83
{{/if}}
45
84
{{/if}}
85
+ {{/if}}
46
86
{{/zcl_attributes_server}}
47
87
default: {
48
88
break;
@@ -57,6 +97,10 @@ static id _Nullable DecodeAttributeValueFor{{asUpperCamelCase name preserveAcron
57
97
58
98
id _Nullable MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader & aReader, CHIP_ERROR * aError)
59
99
{
100
+ if (IsGlobalAttribute(aPath.mAttributeId)) {
101
+ return DecodeGlobalAttributeValue(aPath.mAttributeId, aReader, aError);
102
+ }
103
+
60
104
switch (aPath.mClusterId) {
61
105
{{#zcl_clusters}}
62
106
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
0 commit comments