Skip to content

Commit 1065152

Browse files
brdandupull[bot]
authored andcommitted
Deprecating chip_server_cluster_attributes (#25687)
* Replacing a state helper such as chip_server_cluster_attributes with a stateless helper zcl_attributes_server such that we can get deprecate the stateful helpers one by one. Updating the zap being used Github: ZAP#898 * Updating min version to 3.16 instead of 3.17 Github: ZAP#898
1 parent d675d7c commit 1065152

File tree

17 files changed

+76
-49
lines changed

17 files changed

+76
-49
lines changed

examples/darwin-framework-tool/templates/commands.zapt

+5-5
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private:
9292
{{/unless}}
9393
{{/chip_cluster_commands}}
9494

95-
{{#chip_server_cluster_attributes}}
95+
{{#zcl_attributes_server removeKeys='isOptional'}}
9696
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
9797
{{#*inline "cluster"}}Cluster{{asUpperCamelCase parent.name preserveAcronyms=true}}{{/inline}}
9898
{{#*inline "attribute"}}Attribute{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}}
@@ -201,7 +201,7 @@ private:
201201
{{else if (isCharString type)}}
202202
chip::ByteSpan mValue;
203203
{{else}}
204-
{{chipType}} mValue;
204+
{{as_underlying_zcl_type type}} mValue;
205205
{{/if_chip_complex}}
206206
};
207207

@@ -246,7 +246,7 @@ public:
246246

247247
{{/if}}
248248
{{/unless}}
249-
{{/chip_server_cluster_attributes}}
249+
{{/zcl_attributes_server}}
250250
{{/unless}}
251251
{{/chip_client_clusters}}
252252

@@ -268,7 +268,7 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands)
268268
make_unique<{{asUpperCamelCase clusterName}}{{asUpperCamelCase name}}>(), //
269269
{{/unless}}
270270
{{/chip_cluster_commands}}
271-
{{#chip_server_cluster_attributes}}
271+
{{#zcl_attributes_server removeKeys='isOptional'}}
272272
{{#first}}
273273
make_unique<ReadAttribute>(Id), //
274274
{{/first}}
@@ -291,7 +291,7 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands)
291291
make_unique<SubscribeAttribute{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(), //
292292
{{/if}}
293293
{{/unless}}
294-
{{/chip_server_cluster_attributes}}
294+
{{/zcl_attributes_server}}
295295
{{#zcl_events}}
296296
{{#first}}
297297
make_unique<ReadEvent>(Id), //

integrations/docker/images/chip-cert-bins/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ARG COMMITHASH=7b99e6399c6069037c613782d78132c69b9dcabb
77
# ZAP Development install, so that it runs on both x64 and arm64
88
# Generally this should match with the ZAP version that is used for codegen within the
99
# specified SHA
10-
ARG ZAP_VERSION=v2023.03.06-nightly
10+
ARG ZAP_VERSION=v2023.03.17-nightly
1111

1212
# Ensure TARGETPLATFORM is set
1313
RUN case ${TARGETPLATFORM} in \

scripts/setup/zap.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"mac-arm64",
99
"windows-amd64"
1010
],
11-
"tags": ["version:2@v2023.03.06-nightly.1"]
11+
"tags": ["version:2@v2023.03.17-nightly.1"]
1212
}
1313
]
1414
}

scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/CHIPClientCallbacks.h

+8
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,11 @@
2929
#include <lib/support/Span.h>
3030

3131
// List specific responses
32+
typedef void (*OtaSoftwareUpdateProviderGeneratedCommandListListAttributeCallback)(
33+
void * context, const chip::app::DataModel::DecodableList<chip::CommandId> & data);
34+
typedef void (*OtaSoftwareUpdateProviderAcceptedCommandListListAttributeCallback)(
35+
void * context, const chip::app::DataModel::DecodableList<chip::CommandId> & data);
36+
typedef void (*OtaSoftwareUpdateProviderEventListListAttributeCallback)(
37+
void * context, const chip::app::DataModel::DecodableList<chip::EventId> & data);
38+
typedef void (*OtaSoftwareUpdateProviderAttributeListListAttributeCallback)(
39+
void * context, const chip::app::DataModel::DecodableList<chip::AttributeId> & data);

scripts/tools/zap/tests/outputs/lighting-app/app-templates/CHIPClientCallbacks.h

+8
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,11 @@
2929
#include <lib/support/Span.h>
3030

3131
// List specific responses
32+
typedef void (*OtaSoftwareUpdateProviderGeneratedCommandListListAttributeCallback)(
33+
void * context, const chip::app::DataModel::DecodableList<chip::CommandId> & data);
34+
typedef void (*OtaSoftwareUpdateProviderAcceptedCommandListListAttributeCallback)(
35+
void * context, const chip::app::DataModel::DecodableList<chip::CommandId> & data);
36+
typedef void (*OtaSoftwareUpdateProviderEventListListAttributeCallback)(
37+
void * context, const chip::app::DataModel::DecodableList<chip::EventId> & data);
38+
typedef void (*OtaSoftwareUpdateProviderAttributeListListAttributeCallback)(
39+
void * context, const chip::app::DataModel::DecodableList<chip::AttributeId> & data);

scripts/tools/zap/zap_execution.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# Use scripts/tools/zap/version_update.py to manage ZAP versioning as many
2424
# files may need updating for versions
2525
#
26-
MIN_ZAP_VERSION = '2023.3.6'
26+
MIN_ZAP_VERSION = '2023.3.16'
2727

2828

2929
class ZapTool:

src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
// List specific responses
1616
{{#chip_client_clusters}}
17-
{{#chip_server_cluster_attributes}}
17+
{{#zcl_attributes_server removeKeys='isOptional'}}
1818
{{#if isArray}}
1919
typedef void (*{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}ListAttributeCallback)(void * context, {{zapTypeToDecodableClusterObjectType type ns=parent.name isArgument=true}} data);
2020
{{/if}}
21-
{{/chip_server_cluster_attributes}}
21+
{{/zcl_attributes_server}}
2222
{{/chip_client_clusters}}
2323

2424
{{/if}}

src/app/zap-templates/templates/app/access.zapt

+12-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// Parallel array data (*cluster*, attribute, privilege) for read attribute
1616
#define GENERATED_ACCESS_READ_ATTRIBUTE__CLUSTER { \
1717
{{/first}}
18-
{{#chip_server_cluster_attributes}}
18+
{{#enabled_attributes_for_cluster_and_side name 'server'}}
1919
{{#access entity="attribute"}}
2020
{{#if hasOperation}}
2121
{{#if (isStrEqual operation "read")}}
@@ -37,7 +37,7 @@
3737
{{/if}}
3838
{{/if}}
3939
{{/access}}
40-
{{/chip_server_cluster_attributes}}
40+
{{/enabled_attributes_for_cluster_and_side}}
4141
{{#last}}
4242
}
4343
{{/last}}
@@ -48,7 +48,7 @@
4848
// Parallel array data (cluster, *attribute*, privilege) for read attribute
4949
#define GENERATED_ACCESS_READ_ATTRIBUTE__ATTRIBUTE { \
5050
{{/first}}
51-
{{#chip_server_cluster_attributes}}
51+
{{#enabled_attributes_for_cluster_and_side name 'server'}}
5252
{{#access entity="attribute"}}
5353
{{#if hasOperation}}
5454
{{#if (isStrEqual operation "read")}}
@@ -70,7 +70,7 @@
7070
{{/if}}
7171
{{/if}}
7272
{{/access}}
73-
{{/chip_server_cluster_attributes}}
73+
{{/enabled_attributes_for_cluster_and_side}}
7474
{{#last}}
7575
}
7676
{{/last}}
@@ -81,7 +81,7 @@
8181
// Parallel array data (cluster, attribute, *privilege*) for read attribute
8282
#define GENERATED_ACCESS_READ_ATTRIBUTE__PRIVILEGE { \
8383
{{/first}}
84-
{{#chip_server_cluster_attributes}}
84+
{{#enabled_attributes_for_cluster_and_side name 'server'}}
8585
{{#access entity="attribute"}}
8686
{{#if hasOperation}}
8787
{{#if (isStrEqual operation "read")}}
@@ -103,7 +103,7 @@
103103
{{/if}}
104104
{{/if}}
105105
{{/access}}
106-
{{/chip_server_cluster_attributes}}
106+
{{/enabled_attributes_for_cluster_and_side}}
107107
{{#last}}
108108
}
109109
{{/last}}
@@ -116,7 +116,7 @@
116116
// Parallel array data (*cluster*, attribute, privilege) for write attribute
117117
#define GENERATED_ACCESS_WRITE_ATTRIBUTE__CLUSTER { \
118118
{{/first}}
119-
{{#chip_server_cluster_attributes}}
119+
{{#enabled_attributes_for_cluster_and_side name 'server'}}
120120
{{#access entity="attribute"}}
121121
{{#if hasOperation}}
122122
{{#if (isStrEqual operation "write")}}
@@ -138,7 +138,7 @@
138138
{{/if}}
139139
{{/if}}
140140
{{/access}}
141-
{{/chip_server_cluster_attributes}}
141+
{{/enabled_attributes_for_cluster_and_side}}
142142
{{#last}}
143143
}
144144
{{/last}}
@@ -149,7 +149,7 @@
149149
// Parallel array data (cluster, *attribute*, privilege) for write attribute
150150
#define GENERATED_ACCESS_WRITE_ATTRIBUTE__ATTRIBUTE { \
151151
{{/first}}
152-
{{#chip_server_cluster_attributes}}
152+
{{#enabled_attributes_for_cluster_and_side name 'server'}}
153153
{{#access entity="attribute"}}
154154
{{#if hasOperation}}
155155
{{#if (isStrEqual operation "write")}}
@@ -171,7 +171,7 @@
171171
{{/if}}
172172
{{/if}}
173173
{{/access}}
174-
{{/chip_server_cluster_attributes}}
174+
{{/enabled_attributes_for_cluster_and_side}}
175175
{{#last}}
176176
}
177177
{{/last}}
@@ -182,7 +182,7 @@
182182
// Parallel array data (cluster, attribute, *privilege*) for write attribute
183183
#define GENERATED_ACCESS_WRITE_ATTRIBUTE__PRIVILEGE { \
184184
{{/first}}
185-
{{#chip_server_cluster_attributes}}
185+
{{#enabled_attributes_for_cluster_and_side name 'server'}}
186186
{{#access entity="attribute"}}
187187
{{#if hasOperation}}
188188
{{#if (isStrEqual operation "write")}}
@@ -204,7 +204,7 @@
204204
{{/if}}
205205
{{/if}}
206206
{{/access}}
207-
{{/chip_server_cluster_attributes}}
207+
{{/enabled_attributes_for_cluster_and_side}}
208208
{{#last}}
209209
}
210210
{{/last}}

src/app/zap-templates/templates/app/attributes/Accessors.zapt

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace Attributes {
2626
{{#if_is_struct type}}
2727
{{else if (canHaveSimpleAccessors this)}}
2828
namespace {{asUpperCamelCase label}} {
29-
EmberAfStatus Get(chip::EndpointId endpoint, {{accessorGetterType this}} value); // {{type}} {{isArray}}
29+
EmberAfStatus Get(chip::EndpointId endpoint, {{accessorGetterType this}} value); // {{type}}
3030
EmberAfStatus Set(chip::EndpointId endpoint, {{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotNullable=true forceNotOptional=true}} value);
3131
{{#if isNullable}}
3232
EmberAfStatus SetNull(chip::EndpointId endpoint);

src/darwin/Framework/CHIP/templates/MTRAttributeTLVValueDecoder-src.zapt

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader &
2424
using namespace Clusters::{{asUpperCamelCase name}};
2525
switch (aPath.mAttributeId)
2626
{
27-
{{#chip_server_cluster_attributes}}
27+
{{#zcl_attributes_server removeKeys='isOptional'}}
2828
{{#unless (wasRemoved (asUpperCamelCase ../name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
2929
case Attributes::{{asUpperCamelCase name}}::Id: {
3030
using TypeInfo = Attributes::{{asUpperCamelCase name}}::TypeInfo;
@@ -39,7 +39,7 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader &
3939
return value;
4040
}
4141
{{/unless}}
42-
{{/chip_server_cluster_attributes}}
42+
{{/zcl_attributes_server}}
4343
default:
4444
*aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
4545
break;

src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt

+4-4
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ MTR{{cluster}}Cluster{{command}}Params
129129
command=(asUpperCamelCase name preserveAcronyms=true)}}
130130
{{/chip_cluster_commands}}
131131

132-
{{#chip_server_cluster_attributes}}
132+
{{#zcl_attributes_server removeKeys='isOptional'}}
133133
{{! This is used as the implementation for both the new-name and old-name bits, so check for both here. }}
134134
{{#unless (and (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))
135135
(or (wasRemoved (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))
@@ -232,7 +232,7 @@ reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value
232232

233233
{{/if}}
234234
{{/unless}}
235-
{{/chip_server_cluster_attributes}}
235+
{{/zcl_attributes_server}}
236236

237237
@end
238238
{{/unless}}
@@ -277,7 +277,7 @@ reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value
277277
command=(compatCommandNameRemapping parent.name name)}}
278278
{{/chip_cluster_commands}}
279279

280-
{{#chip_server_cluster_attributes}}
280+
{{#zcl_attributes_server removeKeys='isOptional'}}
281281
{{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))
282282
(not (wasRemoved (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))))}}
283283
{{#*inline "attribute"}}Attribute{{compatAttributeNameRemapping parent.name name}}{{/inline}}
@@ -333,7 +333,7 @@ subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptio
333333
}
334334
{{/if}}
335335
{{/if}}
336-
{{/chip_server_cluster_attributes}}
336+
{{/zcl_attributes_server}}
337337

338338
- (nullable instancetype)initWithDevice:(MTRBaseDevice *)device
339339
endpoint:(uint16_t)endpoint

src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ NS_ASSUME_NONNULL_BEGIN
4242
command=(asUpperCamelCase name preserveAcronyms=true)}}
4343
{{/chip_cluster_commands}}
4444

45-
{{#chip_server_cluster_attributes}}
45+
{{#zcl_attributes_server removeKeys='isOptional'}}
4646
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
4747
{{#*inline "attribute"}}Attribute{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}}
4848
- (void)read{{>attribute}}With
@@ -62,7 +62,7 @@ subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptio
6262
+ (void) read{{>attribute}}WithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))completion {{availability (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp"}};
6363
{{/if}}
6464
{{/unless}}
65-
{{/chip_server_cluster_attributes}}
65+
{{/zcl_attributes_server}}
6666

6767
- (instancetype)init NS_UNAVAILABLE;
6868
+ (instancetype)new NS_UNAVAILABLE;
@@ -203,7 +203,7 @@ typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName bitm
203203
command=(compatCommandNameRemapping parent.name name)}}
204204
{{/chip_cluster_commands}}
205205

206-
{{#chip_server_cluster_attributes}}
206+
{{#zcl_attributes_server removeKeys='isOptional'}}
207207
{{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))
208208
(not (wasRemoved (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))))}}
209209
{{#*inline "attribute"}}Attribute{{compatAttributeNameRemapping parent.name name}}{{/inline}}
@@ -225,7 +225,7 @@ subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptio
225225
+ (void) read{{>attribute}}WithAttributeCache:(MTRAttributeCacheContainer *)attributeCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completionHandler:(void (^)({{asObjectiveCClass type parent.name compatRemapClusterName=true}} * _Nullable value, NSError * _Nullable error))completionHandler {{availability (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use readAttribute" (asUpperCamelCase name preserveAcronyms=true) "WithAttributeCache:endpoint:queue:completion:")}};
226226
{{/if}}
227227
{{/if}}
228-
{{/chip_server_cluster_attributes}}
228+
{{/zcl_attributes_server}}
229229

230230
@end
231231

src/darwin/Framework/CHIP/templates/MTRCallbackBridge-src.zapt

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
{{#>MTRCallbackBridge type="vendor_id" isNullable=true ns="chip"}}NullableVendorIdAttributeCallback{{/MTRCallbackBridge}}
3939

4040
{{#chip_client_clusters includeAll=true}}
41-
{{#chip_server_cluster_attributes}}
41+
{{#zcl_attributes_server removeKeys='isOptional'}}
4242
{{#unless (wasRemoved (asUpperCamelCase ../name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
4343
{{#if isArray}}
4444
{{#>MTRCallbackBridge ns=parent.name }}{{asUpperCamelCase ../../name preserveAcronyms=true}}{{asUpperCamelCase ../name preserveAcronyms=true}}ListAttributeCallback{{/MTRCallbackBridge}}
@@ -51,7 +51,7 @@
5151
{{/if_is_strongly_typed_bitmap}}
5252
{{/if}}
5353
{{/unless}}
54-
{{/chip_server_cluster_attributes}}
54+
{{/zcl_attributes_server}}
5555
{{/chip_client_clusters}}
5656

5757
{{#chip_client_clusters includeAll=true}}

src/darwin/Framework/CHIP/templates/MTRCallbackBridge.zapt

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ typedef void (*Nullable{{asUpperCamelCase parent.name preserveAcronyms=true}}Clu
3232
{{/zcl_clusters}}
3333

3434
{{#chip_client_clusters includeAll=true}}
35-
{{#chip_server_cluster_attributes}}
35+
{{#zcl_attributes_server removeKeys='isOptional'}}
3636
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
3737
{{#if isArray}}
3838
typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCamelCase name preserveAcronyms=true}}ListAttributeCallback)(void * context, {{zapTypeToDecodableClusterObjectType type ns=parent.name isArgument=true}} data);
@@ -45,7 +45,7 @@ typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCa
4545
{{/if_is_strongly_typed_bitmap}}
4646
{{/if}}
4747
{{/unless}}
48-
{{/chip_server_cluster_attributes}}
48+
{{/zcl_attributes_server}}
4949
{{/chip_client_clusters}}
5050

5151
{{#>MTRCallbackBridge header="1" partial-type="Status" }}DefaultSuccessCallback{{/MTRCallbackBridge}}
@@ -80,7 +80,7 @@ typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCa
8080
{{#>MTRCallbackBridge header="1" type="vendor_id" isNullable=true ns="chip"}}NullableVendorIdAttributeCallback{{/MTRCallbackBridge}}
8181

8282
{{#chip_client_clusters includeAll=true}}
83-
{{#chip_server_cluster_attributes}}
83+
{{#zcl_attributes_server removeKeys='isOptional'}}
8484
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
8585
{{#if isArray}}
8686
{{#>MTRCallbackBridge header="1" ns=parent.name }}{{asUpperCamelCase ../../name preserveAcronyms=true}}{{asUpperCamelCase ../name preserveAcronyms=true}}ListAttributeCallback{{/MTRCallbackBridge}}
@@ -93,7 +93,7 @@ typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCa
9393
{{/if_is_strongly_typed_bitmap}}
9494
{{/if}}
9595
{{/unless}}
96-
{{/chip_server_cluster_attributes}}
96+
{{/zcl_attributes_server}}
9797
{{/chip_client_clusters}}
9898

9999
{{#chip_client_clusters includeAll=true}}

0 commit comments

Comments
 (0)