From 1405108875a0f0dc5bae082c5060d0f15ea6acd4 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 20 Dec 2022 12:37:23 -0500 Subject: [PATCH] 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. --- .github/workflows/zap_regeneration.yaml | 2 +- .github/workflows/zap_templates.yaml | 2 +- .../templates/commands.zapt | 4 ++ .../templates/templates.json | 3 +- .../CHIP/templates/MTRBaseClusters-src.zapt | 41 ++++++++--- .../CHIP/templates/MTRBaseClusters.zapt | 29 +++++--- .../CHIP/templates/MTRClusterConstants.zapt | 22 ++++-- .../CHIP/templates/MTRClusters-src.zapt | 70 +++++++++++++------ .../Framework/CHIP/templates/MTRClusters.zapt | 39 +++++++---- .../templates/MTRCommandPayloadsObjc-src.zapt | 35 +++++++--- .../templates/MTRCommandPayloadsObjc.zapt | 35 ++++++---- .../CHIP/templates/availability.yaml | 23 ++++-- .../partials/command_completion_type.zapt | 11 ++- .../CHIP/zap-generated/MTRBaseClusters.h | 9 --- .../CHIP/zap-generated/MTRBaseClusters.mm | 2 +- .../CHIP/zap-generated/MTRClusterConstants.h | 1 - .../CHIP/zap-generated/MTRClusters.h | 8 --- .../CHIP/zap-generated/MTRClusters.mm | 5 +- .../zap-generated/MTRCommandPayloadsObjc.h | 10 +-- .../zap-generated/MTRCommandPayloadsObjc.mm | 7 +- .../zap-generated/cluster/Commands.h | 44 ------------ 21 files changed, 231 insertions(+), 171 deletions(-) diff --git a/.github/workflows/zap_regeneration.yaml b/.github/workflows/zap_regeneration.yaml index b329059f096259..7db5b259340810 100644 --- a/.github/workflows/zap_regeneration.yaml +++ b/.github/workflows/zap_regeneration.yaml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.23 + image: connectedhomeip/chip-build:0.6.24 defaults: run: shell: sh diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index d6367a9abe1aa9..d59598bff10781 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.23 + image: connectedhomeip/chip-build:0.6.24 defaults: run: shell: sh diff --git a/examples/darwin-framework-tool/templates/commands.zapt b/examples/darwin-framework-tool/templates/commands.zapt index 2d39ca2cd29d7f..6a969072384e6d 100644 --- a/examples/darwin-framework-tool/templates/commands.zapt +++ b/examples/darwin-framework-tool/templates/commands.zapt @@ -21,6 +21,7 @@ {{> cluster_header}} {{#chip_cluster_commands}} +{{#unless (wasRemoved (asUpperCamelCase clusterName preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} /* * Command {{asUpperCamelCase name}} */ @@ -87,6 +88,7 @@ private: {{/chip_cluster_command_arguments}} }; +{{/unless}} {{/chip_cluster_commands}} {{#chip_server_cluster_attributes}} @@ -257,7 +259,9 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands) commands_list clusterCommands = { make_unique(Id), // {{#chip_cluster_commands}} + {{#unless (wasRemoved (asUpperCamelCase clusterName preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} make_unique<{{asUpperCamelCase clusterName}}{{asUpperCamelCase name}}>(), // + {{/unless}} {{/chip_cluster_commands}} {{#chip_server_cluster_attributes}} {{#first}} diff --git a/examples/darwin-framework-tool/templates/templates.json b/examples/darwin-framework-tool/templates/templates.json index a571ccb860cf48..8fa73b9c85e196 100644 --- a/examples/darwin-framework-tool/templates/templates.json +++ b/examples/darwin-framework-tool/templates/templates.json @@ -13,7 +13,8 @@ "resources": { "pics-metafile": "../../../src/app/tests/suites/certification/PICS.yaml", "certification-metadir": "../../../src/app/tests/suites/certification", - "test-metadir": "../../../src/app/tests/suites" + "test-metadir": "../../../src/app/tests/suites", + "availability-data": "../../../src/darwin/Framework/CHIP/templates/availability.yaml" }, "override": "../../../src/app/zap-templates/common/override.js", "partials": [ diff --git a/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt b/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt index f1060cdc3c175e..39163d92e437c3 100644 --- a/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt @@ -41,16 +41,26 @@ using chip::SessionHandle; } {{#chip_cluster_commands}} -{{#*inline "cluster"}}{{asUpperCamelCase parent.name preserveAcronyms=true}}{{/inline}} -{{#*inline "command"}}{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}} -{{#*inline "callbackName"}}{{#if hasSpecificResponse}}{{>cluster}}Cluster{{asUpperCamelCase responseName preserveAcronyms=true}}{{else}}CommandSuccess{{/if}}{{/inline}} +{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} +{{#*inline "commandImpl"}} +{{! This is used as the implementation for both the new-name and old-name bits, so check for both here. }} +{{#unless (and (wasRemoved cluster command=command) + (wasRemoved (compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name)))}} +{{#*inline "callbackName"}}{{#if hasSpecificResponse}}{{cluster}}Cluster{{asUpperCamelCase responseName preserveAcronyms=true}}{{else}}CommandSuccess{{/if}}{{/inline}} +{{#*inline "paramsType"}} +{{#if (wasRemoved cluster command=command)}} +MTR{{compatClusterNameRemapping parent.name}}Cluster{{compatCommandNameRemapping parent.name name}}Params +{{else}} +MTR{{cluster}}Cluster{{command}}Params +{{/if}} +{{/inline}} {{#unless (hasArguments)}} - (void){{asLowerCamelCase name}}WithCompletion:({{>command_completion_type command=.}})completion { [self {{asLowerCamelCase name}}WithParams:nil completion:completion]; } {{/unless}} -- (void){{asLowerCamelCase name}}WithParams: (MTR{{>cluster}}Cluster{{>command}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params completion:({{>command_completion_type command=.}})completion +- (void){{asLowerCamelCase name}}WithParams: ({{> paramsType}} * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params completion:({{>command_completion_type command=.}})completion { // Make a copy of params before we go async. params = [params copy]; @@ -100,6 +110,10 @@ using chip::SessionHandle; }); std::move(*bridge).DispatchAction(self.device); } +{{/unless}} +{{/inline}} +{{> commandImpl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) + command=(asUpperCamelCase name preserveAcronyms=true)}} {{/chip_cluster_commands}} {{#chip_server_cluster_attributes}} @@ -212,13 +226,16 @@ reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value @implementation MTRBaseCluster{{compatClusterNameRemapping name}} (Deprecated) {{#chip_cluster_commands}} -- (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 +{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} +{{#*inline "commandImpl"}} +{{#unless (wasRemoved cluster command=command)}} +- (void){{asLowerCamelCase command}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler { [self {{asLowerCamelCase name}}WithParams:params completion: {{#if hasSpecificResponse}} ^(MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase responseName preserveAcronyms=true}}Params * _Nullable data, NSError * _Nullable error) { // Cast is safe because subclass does not add any selectors. - completionHandler(static_cast(data), error); + completionHandler(static_cast(data), error); } {{else}} completionHandler @@ -226,17 +243,20 @@ reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value ]; } {{#unless (hasArguments)}} -- (void){{asLowerCamelCase name}}WithCompletionHandler:({{>command_completion_type command=. compatRemapClusterName=true}})completionHandler +- (void){{asLowerCamelCase command}}WithCompletionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler { [self {{asLowerCamelCase name}}WithParams:nil completionHandler:completionHandler]; } {{/unless}} +{{/unless}} +{{/inline}} +{{> commandImpl cluster=(compatClusterNameRemapping parent.name) + command=(compatCommandNameRemapping parent.name name)}} {{/chip_cluster_commands}} {{#chip_server_cluster_attributes}} -{{!Backwards compat for now: Treat DeviceTypeList as DeviceList. That's OK, since this is a deprecated API. }} -{{#*inline "attribute"}}Attribute{{#if (isStrEqual (asUpperCamelCase parent.name) "Descriptor")}}{{#if (isStrEqual (asUpperCamelCase name) "DeviceTypeList")}}DeviceList{{else}}{{asUpperCamelCase name}}{{/if}}{{else}}{{asUpperCamelCase name}}{{/if}}{{/inline}} -{{! TODO: We need a better setup for the API_AVALABLE annotations here; this does not scale at all sanely. }} +{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))}} +{{#*inline "attribute"}}Attribute{{compatAttributeNameRemapping parent.name name}}{{/inline}} - (void)read{{>attribute}}With {{~#if_is_fabric_scoped_struct type~}} Params:(MTRReadParams * _Nullable)params completionHandler: @@ -288,6 +308,7 @@ subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptio }]; } {{/if}} +{{/if}} {{/chip_server_cluster_attributes}} - (nullable instancetype)initWithDevice:(MTRBaseDevice *)device diff --git a/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt b/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt index b4ba54fb296425..930091b1d1f527 100644 --- a/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt @@ -25,17 +25,22 @@ NS_ASSUME_NONNULL_BEGIN queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER {{availability (asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp"}}; {{#chip_cluster_commands}} +{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} +{{#*inline "commandDecl"}} +{{#unless (wasRemoved cluster command=command)}} /** * Command {{name}} * * {{description}} */ -{{#*inline "cluster"}}{{asUpperCamelCase parent.name preserveAcronyms=true}}{{/inline~}} -{{~#*inline "command"}}{{asUpperCamelCase name preserveAcronyms=true}}{{/inline~}} -- (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"}}; +- (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"}}; {{#unless (hasArguments)}} -- (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"}}; +- (void){{asLowerCamelCase name}}WithCompletion:({{>command_completion_type command=.}})completion {{availability cluster command=command minimalRelease="First major API revamp"}}; {{/unless}} +{{/unless}} +{{/inline}} +{{> commandDecl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) + command=(asUpperCamelCase name preserveAcronyms=true)}} {{/chip_cluster_commands}} {{#chip_server_cluster_attributes}} @@ -117,14 +122,20 @@ typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName labe queue:(dispatch_queue_t)queue {{availability (compatClusterNameRemapping name) deprecatedRelease="First major API revamp" deprecationMessage="Please use initWithDevice:endpointID:queue:"}}; {{#chip_cluster_commands}} -{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) command=(asUpperCamelCase name))}} -- (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 - {{availability (compatClusterNameRemapping parent.name) command=(asUpperCamelCase name) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithParams:completion:")}}; +{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} +{{#*inline "commandDecl"}} +{{#if (and (wasIntroducedBeforeRelease "First major API revamp" cluster command=command) + (not (wasRemoved cluster command=command)))}} +- (void){{asLowerCamelCase command}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler + {{availability cluster command=command deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithParams:completion:")}}; {{#unless (hasArguments)}} -- (void){{asLowerCamelCase name}}WithCompletionHandler:({{>command_completion_type command=. compatRemapClusterName=true}})completionHandler - {{availability (compatClusterNameRemapping parent.name) command=(asUpperCamelCase name) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithCompletion:")}}; +- (void){{asLowerCamelCase command}}WithCompletionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler + {{availability cluster command=command deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithCompletion:")}}; {{/unless}} {{/if}} +{{/inline}} +{{> commandDecl cluster=(compatClusterNameRemapping parent.name) + command=(compatCommandNameRemapping parent.name name)}} {{/chip_cluster_commands}} {{#chip_server_cluster_attributes}} diff --git a/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt b/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt index 90032d0c2b8dac..87d783e8e1df1a 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt @@ -103,22 +103,34 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) { // Cluster {{compatClusterNameRemapping ../clusterName}} deprecated command id names {{/if}} {{/first}} -{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping ../clusterName) command=(asUpperCamelCase label) isForIds=true)}} -MTRCluster{{compatClusterNameRemapping ../clusterName}}Command{{asUpperCamelCase label}}ID -{{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}} +{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} +{{#*inline "commandIdDecl"}} +{{#if (and (wasIntroducedBeforeRelease "First major API revamp" cluster command=command isForIds=true) + (not (wasRemoved cluster command=command isForIds=true)))}} +MTRCluster{{cluster}}Command{{command}}ID +{{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}} = {{asMEI manufacturerCode code}}, {{/if}} +{{/inline}} +{{> commandIdDecl cluster=(compatClusterNameRemapping ../clusterName) + command=(compatCommandNameRemapping ../clusterName name)}} {{#last}} {{/last}} {{/zcl_commands}} {{#zcl_commands}} {{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}} -{{~#*inline "command"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}} {{#first}} // Cluster {{>cluster}} commands {{/first}} -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}}, +{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} +{{#*inline "commandIdDecl"}} +{{#unless (wasRemoved cluster command=command isForIds=true)}} +MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID {{availability cluster command=command minimalRelease="First major API revamp" isForIds=true}} = {{asMEI manufacturerCode code}}, +{{/unless}} +{{/inline}} +{{> commandIdDecl cluster=(asUpperCamelCase ../clusterName preserveAcronyms=true) + command=(asUpperCamelCase name preserveAcronyms=true)}} {{#last}} {{/last}} diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt index e2727936ef8e24..70ccaf69147034 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt @@ -55,17 +55,42 @@ static void MTRClustersLogCompletion(NSString *logPrefix, id value, NSError *err } {{#chip_cluster_commands}} -{{#*inline "cluster"}}{{asUpperCamelCase parent.name preserveAcronyms=true}}{{/inline}} -{{#*inline "callbackName"}}{{#if hasSpecificResponse}}{{>cluster}}Cluster{{asUpperCamelCase responseName preserveAcronyms=true}}{{else}}CommandSuccess{{/if}}{{/inline}} +{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} +{{#*inline "commandImpl"}} +{{! This is used as the implementation for both the new-name and old-name bits, so check for both here. }} +{{#unless (and (wasRemoved cluster command=command) + (wasRemoved (compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name)))}} +{{#*inline "callbackName"}}{{#if hasSpecificResponse}}{{cluster}}Cluster{{asUpperCamelCase responseName preserveAcronyms=true}}{{else}}CommandSuccess{{/if}}{{/inline}} +{{#*inline "paramsType"}} +{{#if (wasRemoved cluster command=command)}} +MTR{{compatClusterNameRemapping parent.name}}Cluster{{compatCommandNameRemapping parent.name name}}Params +{{else}} +MTR{{cluster}}Cluster{{command}}Params +{{/if}} +{{/inline}} +{{#*inline "clusterId"}} +{{#if (wasRemoved cluster command=command)}} +{{asMEI ../manufacturerCode ../code}} +{{else}} +MTRClusterIDType{{cluster}}ID +{{/if}} +{{/inline}} +{{#*inline "commandId"}} +{{#if (wasRemoved cluster command=command)}} +{{asMEI manufacturerCode code}} +{{else}} +MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID +{{/if}} +{{/inline}} {{#unless (hasArguments)}} - (void){{asLowerCamelCase name}}WithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completion:({{>command_completion_type command=.}})completion { [self {{asLowerCamelCase name}}WithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion]; } {{/unless}} -- (void){{asLowerCamelCase name}}WithParams: (MTR{{>cluster}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params expectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completion:({{>command_completion_type command=.}})completion +- (void){{asLowerCamelCase name}}WithParams: ({{> paramsType}} * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params expectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completion:({{>command_completion_type command=.}})completion { - NSString * logPrefix = [NSString stringWithFormat:@"MTRDevice command %u %u %u %u", self.device.deviceController.fabricIndex, _endpoint, (unsigned int)MTRClusterIDType{{>cluster}}ID, (unsigned int)MTRCommandIDTypeCluster{{>cluster}}Command{{asUpperCamelCase name preserveAcronyms=true}}ID]; + NSString * logPrefix = [NSString stringWithFormat:@"MTRDevice command %u %u %u %u", self.device.deviceController.fabricIndex, _endpoint, (unsigned int){{> clusterId}}, (unsigned int){{> commandId}}]; // Make a copy of params before we go async. params = [params copy]; NSNumber *timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs; @@ -137,6 +162,10 @@ static void MTRClustersLogCompletion(NSString *logPrefix, id value, NSError *err [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; } } +{{/unless}} +{{/inline}} +{{> commandImpl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) + command=(asUpperCamelCase name preserveAcronyms=true)}} {{/chip_cluster_commands}} {{#chip_server_cluster_attributes}} @@ -183,13 +212,16 @@ static void MTRClustersLogCompletion(NSString *logPrefix, id value, NSError *err } {{#chip_cluster_commands}} -- (void){{asLowerCamelCase name}}WithParams:(MTR{{compatClusterNameRemapping parent.name}}Cluster{{asUpperCamelCase name}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completionHandler:({{>command_completion_type command=. compatRemapClusterName=true}})completionHandler +{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} +{{#*inline "commandImpl"}} +{{#unless (wasRemoved cluster command=command)}} +- (void){{asLowerCamelCase command}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler { [self {{asLowerCamelCase name}}WithParams:params expectedValues:expectedDataValueDictionaries expectedValueInterval:expectedValueIntervalMs completion: {{#if hasSpecificResponse}} ^(MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase responseName preserveAcronyms=true}}Params * _Nullable data, NSError * _Nullable error) { // Cast is safe because subclass does not add any selectors. - completionHandler(static_cast(data), error); + completionHandler(static_cast(data), error); } {{else}} completionHandler @@ -197,40 +229,36 @@ static void MTRClustersLogCompletion(NSString *logPrefix, id value, NSError *err ]; } {{#unless (hasArguments)}} -- (void){{asLowerCamelCase name}}WithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completionHandler:({{>command_completion_type command=. compatRemapClusterName=true}})completionHandler +- (void){{asLowerCamelCase command}}WithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler { [self {{asLowerCamelCase name}}WithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completionHandler:completionHandler]; } {{/unless}} +{{/unless}} +{{/inline}} +{{> commandImpl cluster=(compatClusterNameRemapping parent.name) + command=(compatCommandNameRemapping parent.name name)}} {{/chip_cluster_commands}} {{~#chip_server_cluster_attributes}} -{{~!Backwards compat for now: Treat DeviceTypeList as DeviceList. That's OK, since all these bits are deprecated. ~}} -{{~#*inline "attribute"}}Attribute{{#if (isStrEqual (asUpperCamelCase parent.name) "Descriptor")}}{{#if (isStrEqual (asUpperCamelCase name) "DeviceTypeList")}}DeviceList{{else}}{{asUpperCamelCase name}}{{/if}}{{else}}{{asUpperCamelCase name}}{{/if}}{{/inline~}} {{~#*inline "attributeImpls"}} -- (NSDictionary *)read{{>attribute}}WithParams:(MTRReadParams * _Nullable)params +{{#unless (isStrEqual attribute (asUpperCamelCase name preserveAcronyms=true))}} +- (NSDictionary *)readAttribute{{attribute}}WithParams:(MTRReadParams * _Nullable)params { return [self readAttribute{{asUpperCamelCase name preserveAcronyms=true}}WithParams:params]; } {{#if isWritableAttribute}} -- (void)write{{>attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs +- (void)writeAttribute{{attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs { [self writeAttribute{{asUpperCamelCase name preserveAcronyms=true}}WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs]; } -- (void)write{{>attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params +- (void)writeAttribute{{attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params { [self writeAttribute{{asUpperCamelCase name preserveAcronyms=true}}WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:params]; } {{/if}} +{{/unless}} {{/inline~}} -{{#if (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (asUpperCamelCase name))}} - {{#if (isStrEqual (asUpperCamelCase parent.name preserveAcronyms=true) "Descriptor")}} - {{#if (isStrEqual (asUpperCamelCase name preserveAcronyms=true) "DeviceTypeList")}} - {{> attributeImpls}} - {{/if}} - {{/if}} -{{else}} - {{> attributeImpls}} -{{/if}} +{{> attributeImpls attribute=(compatAttributeNameRemapping parent.name name)}} {{/chip_server_cluster_attributes}} @end diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters.zapt index c3c9b2980161d5..eeda4ebcb29c09 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusters.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusters.zapt @@ -24,12 +24,17 @@ NS_ASSUME_NONNULL_BEGIN queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER {{availability (asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp"}}; {{#chip_cluster_commands}} -{{~#*inline "cluster"}}{{asUpperCamelCase parent.name preserveAcronyms=true}}{{/inline~}} -{{~#*inline "command"}}{{asUpperCamelCase name preserveAcronyms=true}}{{/inline~}} -- (void){{asLowerCamelCase name}}WithParams:(MTR{{>cluster}}Cluster{{>command}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:({{>command_completion_type command=.}})completion {{availability (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp"}}; +{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} +{{#*inline "commandDecl"}} +{{#unless (wasRemoved cluster command=command)}} +- (void){{asLowerCamelCase name}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:({{>command_completion_type command=.}})completion {{availability cluster command=command minimalRelease="First major API revamp"}}; {{#unless (hasArguments)}} -- (void){{asLowerCamelCase name}}WithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completion:({{>command_completion_type command=.}})completion {{availability (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp"}}; +- (void){{asLowerCamelCase name}}WithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completion:({{>command_completion_type command=.}})completion {{availability cluster command=command minimalRelease="First major API revamp"}}; {{/unless}} +{{/unless}} +{{/inline}} +{{> commandDecl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) + command=(asUpperCamelCase name preserveAcronyms=true)}} {{/chip_cluster_commands}} {{#chip_server_cluster_attributes}} @@ -69,25 +74,31 @@ NS_ASSUME_NONNULL_BEGIN queue:(dispatch_queue_t)queue {{availability (compatClusterNameRemapping name) deprecatedRelease="First major API revamp" deprecationMessage="Please use initWithDevice:endpoindID:queue:"}}; {{#chip_cluster_commands}} -{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) command=(asUpperCamelCase name))}} -- (void){{asLowerCamelCase name}}WithParams:(MTR{{compatClusterNameRemapping parent.name}}Cluster{{asUpperCamelCase name}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completionHandler:({{>command_completion_type command=. compatRemapClusterName=true}})completionHandler {{availability (compatClusterNameRemapping parent.name) command=(asUpperCamelCase name) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithParams:expectedValues:expectedValueIntervalMs:completion:")}}; +{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} +{{#*inline "commandDecl"}} +{{#if (and (wasIntroducedBeforeRelease "First major API revamp" cluster command=command) + (not (wasRemoved cluster command=command)))}} +- (void){{asLowerCamelCase command}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler {{availability cluster command=command deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithParams:expectedValues:expectedValueIntervalMs:completion:")}}; {{#unless (hasArguments)}} -- (void){{asLowerCamelCase name}}WithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completionHandler:({{>command_completion_type command=. compatRemapClusterName=true}})completionHandler {{availability (compatClusterNameRemapping parent.name) command=(asUpperCamelCase name) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithExpectedValues:expectedValueIntervalMs:completion:")}}; +- (void){{asLowerCamelCase command}}WithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler {{availability cluster command=command deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithExpectedValues:expectedValueIntervalMs:completion:")}}; {{/unless}} {{/if}} +{{/inline}} +{{> commandDecl cluster=(compatClusterNameRemapping parent.name) + command=(compatCommandNameRemapping parent.name name)}} {{/chip_cluster_commands}} {{~#chip_server_cluster_attributes}} -{{~#*inline "attribute"}}Attribute{{compatAttributeNameRemapping parent.name name}}{{/inline~}} {{~#*inline "attributeDecls"}} -- (NSDictionary *)read{{>attribute}}WithParams:(MTRReadParams * _Nullable)params {{availability (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use readAttribute" (asUpperCamelCase name preserveAcronyms=true) "WithParams on MTRCluster" (asUpperCamelCase parent.name preserveAcronyms=true))}}; +{{#unless (isStrEqual attribute (asUpperCamelCase name preserveAcronyms=true))}} +- (NSDictionary *)readAttribute{{attribute}}WithParams:(MTRReadParams * _Nullable)params {{availability cluster attribute=attribute deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use readAttribute" (asUpperCamelCase name preserveAcronyms=true) "WithParams on MTRCluster" (asUpperCamelCase parent.name preserveAcronyms=true))}}; {{#if isWritableAttribute}} -- (void)write{{>attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs {{availability (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name) deprecationMessage=(concat "Please use writeAttribute" (asUpperCamelCase name preserveAcronyms=true) "WithValue on MTRCluster" (asUpperCamelCase parent.name preserveAcronyms=true))}}; -- (void)write{{>attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params {{availability (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name) deprecationMessage=(concat "Please use writeAttribute" (asUpperCamelCase name preserveAcronyms=true) "WithValue on MTRCluster" (asUpperCamelCase parent.name preserveAcronyms=true))}}; +- (void)writeAttribute{{attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs {{availability cluster attribute=attribute deprecationMessage=(concat "Please use writeAttribute" (asUpperCamelCase name preserveAcronyms=true) "WithValue on MTRCluster" (asUpperCamelCase parent.name preserveAcronyms=true))}}; +- (void)writeAttribute{{attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params {{availability cluster attribute=attribute deprecationMessage=(concat "Please use writeAttribute" (asUpperCamelCase name preserveAcronyms=true) "WithValue on MTRCluster" (asUpperCamelCase parent.name preserveAcronyms=true))}}; {{/if}} -{{/inline~}} -{{#unless (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (compatAttributeNameRemapping parent.name name))}} - {{> attributeDecls}} {{/unless}} +{{/inline~}} +{{> attributeDecls cluster=(compatClusterNameRemapping parent.name) + attribute=(compatAttributeNameRemapping parent.name name)}} {{/chip_server_cluster_attributes}} @end diff --git a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt index c2d4fe17799d61..a52a37ccbec471 100644 --- a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt @@ -6,7 +6,9 @@ NS_ASSUME_NONNULL_BEGIN {{#zcl_clusters}} {{#zcl_commands}} -@implementation MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Params +{{#*inline "completeImpl"}} +{{#unless (wasRemoved cluster command=command)}} +@implementation MTR{{cluster}}Cluster{{command}}Params - (instancetype)init { if (self = [super init]) { @@ -14,19 +16,25 @@ NS_ASSUME_NONNULL_BEGIN {{>init_struct_member label=label type=type cluster=parent.parent.name}} {{/zcl_command_arguments}} +{{#if (or (isStrEqual source "client") + (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name)))}} _timedInvokeTimeoutMs = nil; +{{/if}} } return self; } - (id)copyWithZone:(NSZone * _Nullable)zone; { - auto other = [[MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Params alloc] init]; + auto other = [[MTR{{cluster}}Cluster{{command}}Params alloc] init]; {{#zcl_command_arguments}} other.{{asStructPropertyName label}} = self.{{asStructPropertyName label}}; {{/zcl_command_arguments}} +{{#if (or (isStrEqual source "client") + (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name)))}} other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; +{{/if}} return other; } @@ -38,18 +46,25 @@ NS_ASSUME_NONNULL_BEGIN } @end -{{#*inline "deprecatedImpl"}} +{{/unless}} +{{/inline}} +{{#*inline "oldNameImpl"}} -@implementation MTR{{compatClusterNameRemapping parent.name}}Cluster{{asUpperCamelCase name}}Params +@implementation MTR{{cluster}}Cluster{{command}}Params @end {{/inline}} -{{#unless (isStrEqual (asUpperCamelCase parent.name preserveAcronyms=true) (compatClusterNameRemapping parent.name))}} -{{> deprecatedImpl}} +{{#if (not (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true)))}} +{{> completeImpl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) + command=(asUpperCamelCase name preserveAcronyms=true)}} +{{#if (or (not (isStrEqual (asUpperCamelCase parent.name preserveAcronyms=true) (compatClusterNameRemapping parent.name))) + (not (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (compatCommandNameRemapping parent.name name))))}} +{{> oldNameImpl cluster=(compatClusterNameRemapping parent.name) + command=(compatCommandNameRemapping parent.name name)}} +{{/if}} {{else}} -{{#unless (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (asUpperCamelCase name))}} -{{> deprecatedImpl}} -{{/unless}} -{{/unless}} +{{> completeImpl cluster=(compatClusterNameRemapping parent.name) + command=(compatCommandNameRemapping parent.name name)}} +{{/if}} {{/zcl_commands}} {{/zcl_clusters}} diff --git a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt index d56d2ffd511ebb..1143ec4e55b19c 100644 --- a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt @@ -7,14 +7,16 @@ NS_ASSUME_NONNULL_BEGIN {{#zcl_clusters}} {{#zcl_commands}} +{{#*inline "completeDecl"}} +{{#unless (wasRemoved cluster command=command)}} -{{availability (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) isForCommandPayload=true}} -@interface MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Params : NSObject +{{availability cluster command=command isForCommandPayload=true deprecationMessage="This command has been removed"}} +@interface MTR{{cluster}}Cluster{{command}}Params : NSObject {{#zcl_command_arguments}} {{! Override the getter name because some of our properties start with things like "new" or "init" }} -@property (nonatomic, copy{{#unless (isStrEqual (asGetterName label) (asStructPropertyName label))}}, getter={{asGetterName label}}{{/unless}}) {{asObjectiveCType type parent.parent.name}} {{asStructPropertyName label}} {{availability (asUpperCamelCase ../../name preserveAcronyms=true) command=(asUpperCamelCase ../name preserveAcronyms=true) commandField=(asStructPropertyName label)}}; +@property (nonatomic, copy{{#unless (isStrEqual (asGetterName label) (asStructPropertyName label))}}, getter={{asGetterName label}}{{/unless}}) {{asObjectiveCType type parent.parent.name}} {{asStructPropertyName label}} {{availability ../cluster command=../command commandField=(asStructPropertyName label)}}; {{/zcl_command_arguments}} {{#if (isStrEqual source "client")}} /** @@ -34,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; {{! This is using the pre-renaming names for the isAvailableBefore test, because the pre-rename things inherit from the post-rename ones and need to have this selector.}} -{{else if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) command=(asUpperCamelCase name))}} +{{else if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name))}} /** * Controls whether the command is a timed command (using Timed Invoke). * @@ -52,20 +54,27 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs {{availability "" api="Timed Invoke for server to client commands" deprecationMessage="Timed invoke does not make sense for server to client commands"}}; {{/if}} @end -{{#*inline "deprecatedDecl"}} +{{/unless}} +{{/inline}} +{{#*inline "oldNameDecl"}} -{{availability (compatClusterNameRemapping parent.name) command=(asUpperCamelCase name) deprecationMessage=(concat "Please use MTR" (asUpperCamelCase parent.name preserveAcronyms=true) "Cluster" (asUpperCamelCase name preserveAcronyms=true) "Params")}} -@interface MTR{{compatClusterNameRemapping parent.name}}Cluster{{asUpperCamelCase name}}Params : MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name}}Params +{{availability cluster command=command deprecationMessage=(concat "Please use MTR" (asUpperCamelCase parent.name preserveAcronyms=true) "Cluster" (asUpperCamelCase name preserveAcronyms=true) "Params")}} +@interface MTR{{cluster}}Cluster{{command}}Params : MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name}}Params @end {{/inline}} -{{#unless (isStrEqual (asUpperCamelCase parent.name preserveAcronyms=true) (compatClusterNameRemapping parent.name))}} -{{> deprecatedDecl}} +{{#if (not (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true)))}} +{{> completeDecl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) + command=(asUpperCamelCase name preserveAcronyms=true)}} +{{#if (or (not (isStrEqual (asUpperCamelCase parent.name preserveAcronyms=true) (compatClusterNameRemapping parent.name))) + (not (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (compatCommandNameRemapping parent.name name))))}} +{{> oldNameDecl cluster=(compatClusterNameRemapping parent.name) + command=(compatCommandNameRemapping parent.name name)}} +{{/if}} {{else}} -{{#unless (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (asUpperCamelCase name))}} -{{> deprecatedDecl}} -{{/unless}} -{{/unless}} +{{> completeDecl cluster=(compatClusterNameRemapping parent.name) + command=(compatCommandNameRemapping parent.name name)}} +{{/if}} {{/zcl_commands}} {{/zcl_clusters}} diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index 71c0db1cdac840..003b30f58a77e4 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -38,9 +38,19 @@ # introduced/deprecated, not the construct itself. # * "global attributes": An array of names of global attributes. # * "apis": An array of API labels that codegen can use. -# * "renames": Can contain clusters, attributes, etc as described above, with -# the one difference that instead of an array the value is a hash -# with new names as keys and old names as values. +# +# * "renames": Can contain clusters, attributes, etc as described +# above for "introduced" and "deprecated", with the one +# difference that instead of an array the value is a hash +# with new names as keys and old names as values. +# +# * "removed": Can contain clusters, commands, attributes, etc as described +# above for "introduced" and "deprecated". Items can be removed +# without ever being introduced, if they are added to the XML but +# we have never shipped generated APIs for them. +# NOTE: support for "removed" may not be complete in the templates. +# Please examine codegen carefully when using "removed" to make +# sure all the things that should have been removed have been. - release: "Initial release" versions: @@ -4748,9 +4758,6 @@ ClientMonitoring: - RegisterClientMonitoring - StayAwakeRequest - BasicInformation: - # TODO: Can we avoid generating this?? - - MfgSpecificPing command fields: UnitTesting: TestSpecificResponse: @@ -5152,6 +5159,10 @@ apis: - Timed Invoke for server to client commands - Deprecated global attribute names + removed: + commands: + BasicInformation: + - MfgSpecificPing renames: clusters: UnitTesting: TestCluster diff --git a/src/darwin/Framework/CHIP/templates/partials/command_completion_type.zapt b/src/darwin/Framework/CHIP/templates/partials/command_completion_type.zapt index 6616a327a6563a..82707950af35aa 100644 --- a/src/darwin/Framework/CHIP/templates/partials/command_completion_type.zapt +++ b/src/darwin/Framework/CHIP/templates/partials/command_completion_type.zapt @@ -1,12 +1,19 @@ {{#if command.hasSpecificResponse}} {{#*inline "clusterName"}} -{{~#if compatRemapClusterName~}} +{{~#if compatRemapNames~}} {{compatClusterNameRemapping command.parent.name}} {{~else~}} {{asUpperCamelCase command.parent.name preserveAcronyms=true}} {{~/if~}} {{/inline}} -void (^)(MTR{{> clusterName}}Cluster{{asUpperCamelCase command.responseName}}Params * _Nullable data, NSError * _Nullable error) +{{#*inline "responseName"}} +{{~#if compatRemapNames~}} +{{compatCommandNameRemapping command.parent.name command.responseName}} +{{~else~}} +{{asUpperCamelCase command.responseName preserveAcronyms=true}} +{{~/if~}} +{{/inline}} +void (^)(MTR{{> clusterName}}Cluster{{> responseName}}Params * _Nullable data, NSError * _Nullable error) {{else}} MTRStatusCompletion {{/if}} diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index 49696ea0f5f879..eabcb977d98501 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -1967,15 +1967,6 @@ MTR_NEWLY_AVAILABLE endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER MTR_NEWLY_AVAILABLE; -/** - * Command MfgSpecificPing - * - * - */ -- (void)mfgSpecificPingWithParams:(MTRBasicInformationClusterMfgSpecificPingParams * _Nullable)params - completion:(MTRStatusCompletion)completion MTR_NEWLY_AVAILABLE; -- (void)mfgSpecificPingWithCompletion:(MTRStatusCompletion)completion MTR_NEWLY_AVAILABLE; - - (void)readAttributeDataModelRevisionWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; - (void)subscribeAttributeDataModelRevisionWithParams:(MTRSubscribeParams *)params diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm index eb8b4bae95da89..e71dfa07d76a21 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm @@ -12741,7 +12741,7 @@ - (void)mfgSpecificPingWithCompletion:(MTRStatusCompletion)completion { [self mfgSpecificPingWithParams:nil completion:completion]; } -- (void)mfgSpecificPingWithParams:(MTRBasicInformationClusterMfgSpecificPingParams * _Nullable)params +- (void)mfgSpecificPingWithParams:(MTRBasicClusterMfgSpecificPingParams * _Nullable)params completion:(MTRStatusCompletion)completion { // Make a copy of params before we go async. diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index c9c92bdd2729ee..495b63ae9a3c24 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -5859,7 +5859,6 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) { = 0x10020000, // Cluster BasicInformation commands - MTRCommandIDTypeClusterBasicInformationCommandMfgSpecificPingID MTR_NEWLY_AVAILABLE = 0x10020000, // Cluster OtaSoftwareUpdateProvider deprecated command id names MTRClusterOtaSoftwareUpdateProviderCommandQueryImageID API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h index feef92f3e11ec4..17144eb969ef5d 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h @@ -895,14 +895,6 @@ MTR_NEWLY_AVAILABLE endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER MTR_NEWLY_AVAILABLE; -- (void)mfgSpecificPingWithParams:(MTRBasicInformationClusterMfgSpecificPingParams * _Nullable)params - expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries - expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs - completion:(MTRStatusCompletion)completion MTR_NEWLY_AVAILABLE; -- (void)mfgSpecificPingWithExpectedValues:(NSArray *> *)expectedValues - expectedValueInterval:(NSNumber *)expectedValueIntervalMs - completion:(MTRStatusCompletion)completion MTR_NEWLY_AVAILABLE; - - (NSDictionary *)readAttributeDataModelRevisionWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; - (NSDictionary *)readAttributeVendorNameWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm index 22ab7d9a3fb404..5db9b7beaa312b 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -5135,14 +5135,13 @@ - (void)mfgSpecificPingWithExpectedValues:(NSArray expectedValueInterval:expectedValueIntervalMs completion:completion]; } -- (void)mfgSpecificPingWithParams:(MTRBasicInformationClusterMfgSpecificPingParams * _Nullable)params +- (void)mfgSpecificPingWithParams:(MTRBasicClusterMfgSpecificPingParams * _Nullable)params expectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completion:(MTRStatusCompletion)completion { NSString * logPrefix = [NSString stringWithFormat:@"MTRDevice command %u %u %u %u", self.device.deviceController.fabricIndex, - _endpoint, (unsigned int) MTRClusterIDTypeBasicInformationID, - (unsigned int) MTRCommandIDTypeClusterBasicInformationCommandMfgSpecificPingID]; + _endpoint, (unsigned int) 0x00000028, (unsigned int) 0x10020000]; // Make a copy of params before we go async. params = [params copy]; NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h index 8313f85fc775d7..60c09f8547bdf4 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h @@ -1425,8 +1425,9 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; @end -MTR_NEWLY_AVAILABLE -@interface MTRBasicInformationClusterMfgSpecificPingParams : NSObject +API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) +MTR_NEWLY_DEPRECATED("This command has been removed") +@interface MTRBasicClusterMfgSpecificPingParams : NSObject /** * Controls whether the command is a timed command (using Timed Invoke). * @@ -1444,11 +1445,6 @@ MTR_NEWLY_AVAILABLE @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; @end -API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) -MTR_NEWLY_DEPRECATED("Please use MTRBasicInformationClusterMfgSpecificPingParams") -@interface MTRBasicClusterMfgSpecificPingParams : MTRBasicInformationClusterMfgSpecificPingParams -@end - MTR_NEWLY_AVAILABLE @interface MTROTASoftwareUpdateProviderClusterQueryImageParams : NSObject diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index 6bb138ce079f35..0f925b15110406 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -1960,7 +1960,7 @@ - (NSString *)description } @end -@implementation MTRBasicInformationClusterMfgSpecificPingParams +@implementation MTRBasicClusterMfgSpecificPingParams - (instancetype)init { if (self = [super init]) { @@ -1971,7 +1971,7 @@ - (instancetype)init - (id)copyWithZone:(NSZone * _Nullable)zone; { - auto other = [[MTRBasicInformationClusterMfgSpecificPingParams alloc] init]; + auto other = [[MTRBasicClusterMfgSpecificPingParams alloc] init]; other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; @@ -1984,9 +1984,6 @@ - (NSString *)description return descriptionString; } -@end - -@implementation MTRBasicClusterMfgSpecificPingParams @end @implementation MTROTASoftwareUpdateProviderClusterQueryImageParams - (instancetype)init diff --git a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h index 86ad518b365495..934293738377f9 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -10964,49 +10964,6 @@ class SubscribeAttributeActionsClusterRevision : public SubscribeAttribute { | * ReachableChanged | 0x0003 | \*----------------------------------------------------------------------------*/ -/* - * Command MfgSpecificPing - */ -class BasicInformationMfgSpecificPing : public ClusterCommand { -public: - BasicInformationMfgSpecificPing() - : ClusterCommand("mfg-specific-ping") - { - ClusterCommand::AddArguments(); - } - - CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x00000028) command (0x00000000) on endpoint %u", endpointId); - - dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device - endpointID:@(endpointId) - queue:callbackQueue]; - __auto_type * params = [[MTRBasicInformationClusterMfgSpecificPingParams alloc] init]; - params.timedInvokeTimeoutMs - = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; - uint16_t repeatCount = mRepeatCount.ValueOr(1); - uint16_t __block responsesNeeded = repeatCount; - while (repeatCount--) { - [cluster mfgSpecificPingWithParams:params - completion:^(NSError * _Nullable error) { - responsesNeeded--; - if (error != nil) { - mError = error; - LogNSError("Error", error); - } - if (responsesNeeded == 0) { - SetCommandExitStatus(mError); - } - }]; - } - return CHIP_NO_ERROR; - } - -private: -}; - /* * Attribute DataModelRevision */ @@ -97929,7 +97886,6 @@ void registerClusterBasicInformation(Commands & commands) commands_list clusterCommands = { make_unique(Id), // - make_unique(), // make_unique(Id), // make_unique(), // make_unique(Id), //