Skip to content

Commit fb18595

Browse files
Remove the MfgSpecificPing command from Darwin API. (#24139)
* Remove the MfgSpecificPing command from Darwin API. Except for the backwards-compat shims, of course. The template refactorings are to reduce repetition and to enable handling for removal and renaming of commands. * Fix darwin-framework-tool compile.
1 parent 50e7c19 commit fb18595

File tree

21 files changed

+231
-171
lines changed

21 files changed

+231
-171
lines changed

.github/workflows/zap_regeneration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
runs-on: ubuntu-20.04
3030
container:
31-
image: connectedhomeip/chip-build:0.6.23
31+
image: connectedhomeip/chip-build:0.6.24
3232
defaults:
3333
run:
3434
shell: sh

.github/workflows/zap_templates.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
runs-on: ubuntu-20.04
3131
container:
32-
image: connectedhomeip/chip-build:0.6.23
32+
image: connectedhomeip/chip-build:0.6.24
3333
defaults:
3434
run:
3535
shell: sh

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
{{> cluster_header}}
2222

2323
{{#chip_cluster_commands}}
24+
{{#unless (wasRemoved (asUpperCamelCase clusterName preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
2425
/*
2526
* Command {{asUpperCamelCase name}}
2627
*/
@@ -87,6 +88,7 @@ private:
8788
{{/chip_cluster_command_arguments}}
8889
};
8990

91+
{{/unless}}
9092
{{/chip_cluster_commands}}
9193

9294
{{#chip_server_cluster_attributes}}
@@ -257,7 +259,9 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands)
257259
commands_list clusterCommands = {
258260
make_unique<ClusterCommand>(Id), //
259261
{{#chip_cluster_commands}}
262+
{{#unless (wasRemoved (asUpperCamelCase clusterName preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
260263
make_unique<{{asUpperCamelCase clusterName}}{{asUpperCamelCase name}}>(), //
264+
{{/unless}}
261265
{{/chip_cluster_commands}}
262266
{{#chip_server_cluster_attributes}}
263267
{{#first}}

examples/darwin-framework-tool/templates/templates.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"resources": {
1414
"pics-metafile": "../../../src/app/tests/suites/certification/PICS.yaml",
1515
"certification-metadir": "../../../src/app/tests/suites/certification",
16-
"test-metadir": "../../../src/app/tests/suites"
16+
"test-metadir": "../../../src/app/tests/suites",
17+
"availability-data": "../../../src/darwin/Framework/CHIP/templates/availability.yaml"
1718
},
1819
"override": "../../../src/app/zap-templates/common/override.js",
1920
"partials": [

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

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,26 @@ using chip::SessionHandle;
4141
}
4242

4343
{{#chip_cluster_commands}}
44-
{{#*inline "cluster"}}{{asUpperCamelCase parent.name preserveAcronyms=true}}{{/inline}}
45-
{{#*inline "command"}}{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}}
46-
{{#*inline "callbackName"}}{{#if hasSpecificResponse}}{{>cluster}}Cluster{{asUpperCamelCase responseName preserveAcronyms=true}}{{else}}CommandSuccess{{/if}}{{/inline}}
44+
{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }}
45+
{{#*inline "commandImpl"}}
46+
{{! This is used as the implementation for both the new-name and old-name bits, so check for both here. }}
47+
{{#unless (and (wasRemoved cluster command=command)
48+
(wasRemoved (compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name)))}}
49+
{{#*inline "callbackName"}}{{#if hasSpecificResponse}}{{cluster}}Cluster{{asUpperCamelCase responseName preserveAcronyms=true}}{{else}}CommandSuccess{{/if}}{{/inline}}
50+
{{#*inline "paramsType"}}
51+
{{#if (wasRemoved cluster command=command)}}
52+
MTR{{compatClusterNameRemapping parent.name}}Cluster{{compatCommandNameRemapping parent.name name}}Params
53+
{{else}}
54+
MTR{{cluster}}Cluster{{command}}Params
55+
{{/if}}
56+
{{/inline}}
4757
{{#unless (hasArguments)}}
4858
- (void){{asLowerCamelCase name}}WithCompletion:({{>command_completion_type command=.}})completion
4959
{
5060
[self {{asLowerCamelCase name}}WithParams:nil completion:completion];
5161
}
5262
{{/unless}}
53-
- (void){{asLowerCamelCase name}}WithParams: (MTR{{>cluster}}Cluster{{>command}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params completion:({{>command_completion_type command=.}})completion
63+
- (void){{asLowerCamelCase name}}WithParams: ({{> paramsType}} * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params completion:({{>command_completion_type command=.}})completion
5464
{
5565
// Make a copy of params before we go async.
5666
params = [params copy];
@@ -100,6 +110,10 @@ using chip::SessionHandle;
100110
});
101111
std::move(*bridge).DispatchAction(self.device);
102112
}
113+
{{/unless}}
114+
{{/inline}}
115+
{{> commandImpl cluster=(asUpperCamelCase parent.name preserveAcronyms=true)
116+
command=(asUpperCamelCase name preserveAcronyms=true)}}
103117
{{/chip_cluster_commands}}
104118

105119
{{#chip_server_cluster_attributes}}
@@ -212,31 +226,37 @@ reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value
212226
@implementation MTRBaseCluster{{compatClusterNameRemapping name}} (Deprecated)
213227

214228
{{#chip_cluster_commands}}
215-
- (void){{asLowerCamelCase name}}WithParams:(MTR{{compatClusterNameRemapping parent.name}}Cluster{{asUpperCamelCase name}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params completionHandler:({{>command_completion_type command=. compatRemapClusterName=true}})completionHandler
229+
{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }}
230+
{{#*inline "commandImpl"}}
231+
{{#unless (wasRemoved cluster command=command)}}
232+
- (void){{asLowerCamelCase command}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler
216233
{
217234
[self {{asLowerCamelCase name}}WithParams:params completion:
218235
{{#if hasSpecificResponse}}
219236
^(MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase responseName preserveAcronyms=true}}Params * _Nullable data, NSError * _Nullable error) {
220237
// Cast is safe because subclass does not add any selectors.
221-
completionHandler(static_cast<MTR{{compatClusterNameRemapping parent.name}}Cluster{{asUpperCamelCase responseName}}Params *>(data), error);
238+
completionHandler(static_cast<MTR{{cluster}}Cluster{{compatCommandNameRemapping parent.name responseName}}Params *>(data), error);
222239
}
223240
{{else}}
224241
completionHandler
225242
{{/if}}
226243
];
227244
}
228245
{{#unless (hasArguments)}}
229-
- (void){{asLowerCamelCase name}}WithCompletionHandler:({{>command_completion_type command=. compatRemapClusterName=true}})completionHandler
246+
- (void){{asLowerCamelCase command}}WithCompletionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler
230247
{
231248
[self {{asLowerCamelCase name}}WithParams:nil completionHandler:completionHandler];
232249
}
233250
{{/unless}}
251+
{{/unless}}
252+
{{/inline}}
253+
{{> commandImpl cluster=(compatClusterNameRemapping parent.name)
254+
command=(compatCommandNameRemapping parent.name name)}}
234255
{{/chip_cluster_commands}}
235256

236257
{{#chip_server_cluster_attributes}}
237-
{{!Backwards compat for now: Treat DeviceTypeList as DeviceList. That's OK, since this is a deprecated API. }}
238-
{{#*inline "attribute"}}Attribute{{#if (isStrEqual (asUpperCamelCase parent.name) "Descriptor")}}{{#if (isStrEqual (asUpperCamelCase name) "DeviceTypeList")}}DeviceList{{else}}{{asUpperCamelCase name}}{{/if}}{{else}}{{asUpperCamelCase name}}{{/if}}{{/inline}}
239-
{{! TODO: We need a better setup for the API_AVALABLE annotations here; this does not scale at all sanely. }}
258+
{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))}}
259+
{{#*inline "attribute"}}Attribute{{compatAttributeNameRemapping parent.name name}}{{/inline}}
240260
- (void)read{{>attribute}}With
241261
{{~#if_is_fabric_scoped_struct type~}}
242262
Params:(MTRReadParams * _Nullable)params completionHandler:
@@ -288,6 +308,7 @@ subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptio
288308
}];
289309
}
290310
{{/if}}
311+
{{/if}}
291312
{{/chip_server_cluster_attributes}}
292313

293314
- (nullable instancetype)initWithDevice:(MTRBaseDevice *)device

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,22 @@ NS_ASSUME_NONNULL_BEGIN
2525
queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER {{availability (asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp"}};
2626

2727
{{#chip_cluster_commands}}
28+
{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }}
29+
{{#*inline "commandDecl"}}
30+
{{#unless (wasRemoved cluster command=command)}}
2831
/**
2932
* Command {{name}}
3033
*
3134
* {{description}}
3235
*/
33-
{{#*inline "cluster"}}{{asUpperCamelCase parent.name preserveAcronyms=true}}{{/inline~}}
34-
{{~#*inline "command"}}{{asUpperCamelCase name preserveAcronyms=true}}{{/inline~}}
35-
- (void){{asLowerCamelCase name}}WithParams:(MTR{{>cluster}}Cluster{{>command}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params completion:({{>command_completion_type command=.}})completion {{availability (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp"}};
36+
- (void){{asLowerCamelCase name}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params completion:({{>command_completion_type command=.}})completion {{availability cluster command=command minimalRelease="First major API revamp"}};
3637
{{#unless (hasArguments)}}
37-
- (void){{asLowerCamelCase name}}WithCompletion:({{>command_completion_type command=.}})completion {{availability (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp"}};
38+
- (void){{asLowerCamelCase name}}WithCompletion:({{>command_completion_type command=.}})completion {{availability cluster command=command minimalRelease="First major API revamp"}};
3839
{{/unless}}
40+
{{/unless}}
41+
{{/inline}}
42+
{{> commandDecl cluster=(asUpperCamelCase parent.name preserveAcronyms=true)
43+
command=(asUpperCamelCase name preserveAcronyms=true)}}
3944
{{/chip_cluster_commands}}
4045

4146
{{#chip_server_cluster_attributes}}
@@ -117,14 +122,20 @@ typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName labe
117122
queue:(dispatch_queue_t)queue {{availability (compatClusterNameRemapping name) deprecatedRelease="First major API revamp" deprecationMessage="Please use initWithDevice:endpointID:queue:"}};
118123

119124
{{#chip_cluster_commands}}
120-
{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) command=(asUpperCamelCase name))}}
121-
- (void){{asLowerCamelCase name}}WithParams:(MTR{{compatClusterNameRemapping parent.name}}Cluster{{asUpperCamelCase name}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params completionHandler:({{>command_completion_type command=. compatRemapClusterName=true}})completionHandler
122-
{{availability (compatClusterNameRemapping parent.name) command=(asUpperCamelCase name) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithParams:completion:")}};
125+
{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }}
126+
{{#*inline "commandDecl"}}
127+
{{#if (and (wasIntroducedBeforeRelease "First major API revamp" cluster command=command)
128+
(not (wasRemoved cluster command=command)))}}
129+
- (void){{asLowerCamelCase command}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler
130+
{{availability cluster command=command deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithParams:completion:")}};
123131
{{#unless (hasArguments)}}
124-
- (void){{asLowerCamelCase name}}WithCompletionHandler:({{>command_completion_type command=. compatRemapClusterName=true}})completionHandler
125-
{{availability (compatClusterNameRemapping parent.name) command=(asUpperCamelCase name) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithCompletion:")}};
132+
- (void){{asLowerCamelCase command}}WithCompletionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler
133+
{{availability cluster command=command deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithCompletion:")}};
126134
{{/unless}}
127135
{{/if}}
136+
{{/inline}}
137+
{{> commandDecl cluster=(compatClusterNameRemapping parent.name)
138+
command=(compatCommandNameRemapping parent.name name)}}
128139
{{/chip_cluster_commands}}
129140

130141
{{#chip_server_cluster_attributes}}

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,34 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) {
103103
// Cluster {{compatClusterNameRemapping ../clusterName}} deprecated command id names
104104
{{/if}}
105105
{{/first}}
106-
{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping ../clusterName) command=(asUpperCamelCase label) isForIds=true)}}
107-
MTRCluster{{compatClusterNameRemapping ../clusterName}}Command{{asUpperCamelCase label}}ID
108-
{{availability (compatClusterNameRemapping ../clusterName) command=(asUpperCamelCase label) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use MTRCommandIDTypeCluster" (asUpperCamelCase ../clusterName preserveAcronyms=true) "Command" (asUpperCamelCase label preserveAcronyms=true) "ID") isForIds=true}}
106+
{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }}
107+
{{#*inline "commandIdDecl"}}
108+
{{#if (and (wasIntroducedBeforeRelease "First major API revamp" cluster command=command isForIds=true)
109+
(not (wasRemoved cluster command=command isForIds=true)))}}
110+
MTRCluster{{cluster}}Command{{command}}ID
111+
{{availability cluster command=command deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use MTRCommandIDTypeCluster" (asUpperCamelCase ../clusterName preserveAcronyms=true) "Command" (asUpperCamelCase name preserveAcronyms=true) "ID") isForIds=true}}
109112
= {{asMEI manufacturerCode code}},
110113
{{/if}}
114+
{{/inline}}
115+
{{> commandIdDecl cluster=(compatClusterNameRemapping ../clusterName)
116+
command=(compatCommandNameRemapping ../clusterName name)}}
111117
{{#last}}
112118

113119
{{/last}}
114120
{{/zcl_commands}}
115121
{{#zcl_commands}}
116122
{{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}}
117-
{{~#*inline "command"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}}
118123
{{#first}}
119124
// Cluster {{>cluster}} commands
120125
{{/first}}
121-
MTRCommandIDTypeCluster{{>cluster}}Command{{>command}}ID {{availability (asUpperCamelCase ../clusterName preserveAcronyms=true) command=(asUpperCamelCase label preserveAcronyms=true) minimalRelease="First major API revamp" isForIds=true}} = {{asMEI manufacturerCode code}},
126+
{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }}
127+
{{#*inline "commandIdDecl"}}
128+
{{#unless (wasRemoved cluster command=command isForIds=true)}}
129+
MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID {{availability cluster command=command minimalRelease="First major API revamp" isForIds=true}} = {{asMEI manufacturerCode code}},
130+
{{/unless}}
131+
{{/inline}}
132+
{{> commandIdDecl cluster=(asUpperCamelCase ../clusterName preserveAcronyms=true)
133+
command=(asUpperCamelCase name preserveAcronyms=true)}}
122134
{{#last}}
123135

124136
{{/last}}

0 commit comments

Comments
 (0)