From 16084842dfe8600902d05fe0c2eb6f21173d76da Mon Sep 17 00:00:00 2001 From: Bharat Raju Date: Wed, 2 Feb 2022 11:37:43 +0530 Subject: [PATCH] Fix for the non-determinism issue on Command handler and Outgoing Commands (#13871) * - Adding changes to the zap templates such that the incoming and outgoing commands are generated with determinism. Using the upto date helpers in the *.zapt templates Currently pointing to a zap repo which has new helpers as well. These changes have not been merged into the github zap repo gihub#342 * - Generation for outgoing commands which originate from the client side only. - All commands originating on the server sides are response commands which do not need to be generated here Github#342 * - Reverting from zcl_command_arguments to chip_cluster_command_arguments_with_structs_expanded - Applying changes to chip_cluster_command_arguments_with_structs_expanded such that it can be used within all_outgoing_commands_for_cluster block helper instead of chip_cluster_command_arguments - Github#342 * - Cleaning the templates further such that we have lesser diff to what we generated before Github#342 * Making sure that outgoing commands are generated for both mfg and non-mfg specific clusters and commands Github#342 * Generating for clusters which do not have any outgoing commands because there is code which depends on this generated code Github#342 * Using chip_client_clusters instead of all_user_clusters_with_outgoing_commands in CHIPClusters-src.zapt just like we do in CHIPClusters.zapt to maintain consistency Also reverting the changes in helper.js since those are no longer required Github#342 * Cleaning up asBlock and regening Github#342 * Regening light switch app with the right content after rebasing from upstream master Github#342 * Cleaning up the typo in helper.js Github#342 * Restore the previous asBlocks behavior * Fixing the request structs for commands in .matter generated files such that request struct should be defined for all incoming commands from client to server and outgoing commands from client to server Github#342 * Fixing the response structs for commands in .matter generated files such that response struct should be defined for all incoming commands from server to client and outgoing commands from server to client Github#342 * Regening after rebasing master Github#342 * Remove unnecessary isMfgSpecific="false" and fix rebase problem in cluster-objects.h Co-authored-by: Boris Zbarsky --- .../all-clusters-app.matter | 14 +- .../light-switch-app.matter | 19 - .../lighting-common/lighting-app.matter | 11 + .../tv-casting-common/tv-casting-app.matter | 14 +- .../im_command_handler_cluster_commands.zapt | 10 +- .../templates/app/MatterIDL.zapt | 62 +- .../app/im-cluster-command-handler.zapt | 19 +- .../zap-templates/templates/chip/helper.js | 5 +- src/controller/CommandSenderAllocator.h | 3 - .../zap-generated/CHIPClientCallbacks.cpp | 258 +++ .../zap-generated/CHIPClusters.cpp | 1657 ----------------- .../zap-generated/IMClusterCommandHandler.cpp | 9 - 12 files changed, 350 insertions(+), 1731 deletions(-) create mode 100644 zzz_generated/light-switch-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/light-switch-app/zap-generated/CHIPClusters.cpp diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 0398748aa3c1f3..370755ca70d246 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -1647,23 +1647,23 @@ server cluster IasZone = 1280 { readonly attribute int8u zoneId = 17; readonly global attribute int16u clusterRevision = 65533; - request struct ZoneEnrollRequestRequest { + request struct ZoneEnrollResponseRequest { + IasEnrollResponseCode enrollResponseCode = 0; + INT8U zoneId = 1; + } + + response struct ZoneEnrollRequest { IasZoneType zoneType = 0; INT16U manufacturerCode = 1; } - request struct ZoneStatusChangeNotificationRequest { + response struct ZoneStatusChangeNotification { IasZoneStatus zoneStatus = 0; BITMAP8 extendedStatus = 1; INT8U zoneId = 2; INT16U delay = 3; } - response struct ZoneEnrollResponse { - IasEnrollResponseCode enrollResponseCode = 0; - INT8U zoneId = 1; - } - command ZoneEnrollRequest(ZoneEnrollRequestRequest): ZoneEnrollResponse = 1; command ZoneStatusChangeNotification(ZoneStatusChangeNotificationRequest): DefaultSuccess = 0; } diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.matter b/examples/light-switch-app/light-switch-common/light-switch-app.matter index 785d948a46b03a..f0ef9cc541dee5 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.matter +++ b/examples/light-switch-app/light-switch-common/light-switch-app.matter @@ -617,13 +617,6 @@ client cluster Groups = 4 { request struct ViewGroupRequest { INT16U groupId = 0; } - - command AddGroup(AddGroupRequest): AddGroupResponse = 0; - command AddGroupIfIdentifying(AddGroupIfIdentifyingRequest): DefaultSuccess = 5; - command GetGroupMembership(GetGroupMembershipRequest): GetGroupMembershipResponse = 2; - command RemoveAllGroups(): DefaultSuccess = 4; - command RemoveGroup(RemoveGroupRequest): RemoveGroupResponse = 3; - command ViewGroup(ViewGroupRequest): ViewGroupResponse = 1; } client cluster Identify = 3 { @@ -993,10 +986,6 @@ client cluster OnOff = 6 { readonly global attribute attrib_id attributeList[] = 65531; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; - - command Off(): DefaultSuccess = 0; - command On(): DefaultSuccess = 1; - command Toggle(): DefaultSuccess = 2; } server cluster OperationalCredentials = 62 { @@ -1203,14 +1192,6 @@ client cluster Scenes = 5 { CHAR_STRING sceneName = 4; SceneExtensionFieldSet extensionFieldSets[] = 5; } - - command AddScene(AddSceneRequest): AddSceneResponse = 0; - command GetSceneMembership(GetSceneMembershipRequest): GetSceneMembershipResponse = 6; - command RecallScene(RecallSceneRequest): DefaultSuccess = 5; - command RemoveAllScenes(RemoveAllScenesRequest): RemoveAllScenesResponse = 3; - command RemoveScene(RemoveSceneRequest): RemoveSceneResponse = 2; - command StoreScene(StoreSceneRequest): StoreSceneResponse = 4; - command ViewScene(ViewSceneRequest): ViewSceneResponse = 1; } server cluster SoftwareDiagnostics = 52 { diff --git a/examples/lighting-app/lighting-common/lighting-app.matter b/examples/lighting-app/lighting-common/lighting-app.matter index ce3e592eeeac09..ad6465074240c4 100644 --- a/examples/lighting-app/lighting-common/lighting-app.matter +++ b/examples/lighting-app/lighting-common/lighting-app.matter @@ -1043,6 +1043,17 @@ client cluster OnOff = 6 { attribute enum8 startUpOnOff = 16387; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; + + request struct OffWithEffectRequest { + OnOffEffectIdentifier effectId = 0; + OnOffDelayedAllOffEffectVariant effectVariant = 1; + } + + request struct OnWithTimedOffRequest { + OnOffControl onOffControl = 0; + int16u onTime = 1; + int16u offWaitTime = 2; + } } server cluster OnOff = 6 { diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter index 5f1bf7d6883c29..e2a06c1d33e042 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter @@ -1471,23 +1471,23 @@ server cluster IasZone = 1280 { readonly attribute int8u zoneId = 17; readonly global attribute int16u clusterRevision = 65533; - request struct ZoneEnrollRequestRequest { + request struct ZoneEnrollResponseRequest { + IasEnrollResponseCode enrollResponseCode = 0; + INT8U zoneId = 1; + } + + response struct ZoneEnrollRequest { IasZoneType zoneType = 0; INT16U manufacturerCode = 1; } - request struct ZoneStatusChangeNotificationRequest { + response struct ZoneStatusChangeNotification { IasZoneStatus zoneStatus = 0; BITMAP8 extendedStatus = 1; INT8U zoneId = 2; INT16U delay = 3; } - response struct ZoneEnrollResponse { - IasEnrollResponseCode enrollResponseCode = 0; - INT8U zoneId = 1; - } - command ZoneEnrollRequest(ZoneEnrollRequestRequest): ZoneEnrollResponse = 1; command ZoneStatusChangeNotification(ZoneStatusChangeNotificationRequest): DefaultSuccess = 0; } diff --git a/src/app/zap-templates/partials/im_command_handler_cluster_commands.zapt b/src/app/zap-templates/partials/im_command_handler_cluster_commands.zapt index e4b0278cae26ca..979f01f9d06235 100644 --- a/src/app/zap-templates/partials/im_command_handler_cluster_commands.zapt +++ b/src/app/zap-templates/partials/im_command_handler_cluster_commands.zapt @@ -1,14 +1,14 @@ -{{#if (isServer parent.side)}} +{{#if (isServer parent.clusterSide)}} {{#if mustUseTimedInvoke}} if (!apCommandObj->IsTimedInvoke()) { apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::NeedsTimedInteraction); return; } {{/if}} -Commands::{{asUpperCamelCase name}}::DecodableType commandData; +Commands::{{asUpperCamelCase commandName}}::DecodableType commandData; TLVError = DataModel::Decode(aDataTlv, commandData); if (TLVError == CHIP_NO_ERROR) { -wasHandled = emberAf{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Callback(apCommandObj, aCommandPath, commandData); +wasHandled = emberAf{{asUpperCamelCase parent.clusterName}}Cluster{{asUpperCamelCase commandName}}Callback(apCommandObj, aCommandPath, commandData); } {{else}} {{#if (zcl_command_arguments_count this.id)}} @@ -18,7 +18,7 @@ expectArgumentCount = {{ zcl_command_arguments_count this.id }}; {{asUnderlyingZclType type}} {{asSymbol label}}; {{else}} {{#if_is_struct type}} - {{zapTypeToDecodableClusterObjectType type ns=parent.parent.name}} {{asSymbol label}}; + {{zapTypeToDecodableClusterObjectType type ns=parent.parent.clusterName}} {{asSymbol label}}; {{else}} {{asUnderlyingZclType type}} {{asSymbol label}}; {{/if_is_struct}} @@ -90,7 +90,7 @@ if (CHIP_END_OF_TLV == TLVError) if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && {{zcl_command_arguments_count this.id}} == validArgumentCount) { {{/if}} -wasHandled = emberAf{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Callback(aCommandPath.mEndpointId, apCommandObj{{#zcl_command_arguments}}, {{asSymbol label}}{{/zcl_command_arguments}}); +wasHandled = emberAf{{asUpperCamelCase parent.clusterName}}Cluster{{asUpperCamelCase commandName}}Callback(aCommandPath.mEndpointId, apCommandObj{{#zcl_command_arguments}}, {{asSymbol label}}{{/zcl_command_arguments}}); {{#if (zcl_command_arguments_count this.id)}} } {{/if}} diff --git a/src/app/zap-templates/templates/app/MatterIDL.zapt b/src/app/zap-templates/templates/app/MatterIDL.zapt index 6988f2f4d4f82a..09775b363c43f0 100644 --- a/src/app/zap-templates/templates/app/MatterIDL.zapt +++ b/src/app/zap-templates/templates/app/MatterIDL.zapt @@ -61,26 +61,66 @@ {{/unless}} {{asLowerCamelCase name~}} {{~#if isArray~}} [] {{~/if}} = {{code}}; {{/chip_server_cluster_attributes}} - {{#chip_cluster_commands}} - {{#if arguments}} + {{#if (is_server side)}} + {{#all_incoming_commands_for_cluster name 'server'}} + {{#zcl_command_arguments}} - request struct {{asUpperCamelCase name}}Request { - {{#chip_cluster_command_arguments}} +{{#first}} + request struct {{asUpperCamelCase parent.commandName}}Request { +{{/first}} {{> idl_structure_member}} +{{#last}} - {{/chip_cluster_command_arguments}} } +{{/last}} + {{/zcl_command_arguments}} + {{/all_incoming_commands_for_cluster}} {{/if}} - {{/chip_cluster_commands}} - {{#chip_cluster_responses}} + {{#if (is_client side)}} + {{#all_outgoing_commands_for_cluster name 'client'}} + {{#zcl_command_arguments}} + +{{#first}} + request struct {{asUpperCamelCase parent.commandName}}Request { +{{/first}} + {{> idl_structure_member}} +{{#last}} + + } +{{/last}} + {{/zcl_command_arguments}} + {{/all_outgoing_commands_for_cluster}} + {{/if}} +{{#if (is_client side)}} + {{#all_incoming_commands_for_cluster name 'client'}} + {{#zcl_command_arguments}} - response struct {{asUpperCamelCase name}} { - {{#chip_cluster_response_arguments}} +{{#first}} + response struct {{asUpperCamelCase parent.commandName}} { +{{/first}} {{> idl_structure_member}} +{{#last}} - {{/chip_cluster_response_arguments}} } - {{/chip_cluster_responses}} +{{/last}} + {{/zcl_command_arguments}} + {{/all_incoming_commands_for_cluster}} + {{/if}} + {{#if (is_server side)}} + {{#all_outgoing_commands_for_cluster name 'server'}} + {{#zcl_command_arguments}} + +{{#first}} + response struct {{asUpperCamelCase parent.commandName}} { +{{/first}} + {{> idl_structure_member}} +{{#last}} + + } +{{/last}} + {{/zcl_command_arguments}} + {{/all_outgoing_commands_for_cluster}} + {{/if}} {{#chip_cluster_commands}} {{#first}} diff --git a/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt b/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt index 4a9ebdc2c4b51e..569ae8d4c573dd 100644 --- a/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt +++ b/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt @@ -24,14 +24,13 @@ namespace app { namespace Clusters { -{{#all_user_clusters}} -{{#if (isServer side)}} -{{#if (user_cluster_has_enabled_command name side)}} -namespace {{asUpperCamelCase name}} { +{{#all_user_clusters_with_incoming_commands}} +{{#if (isServer clusterSide)}} +namespace {{asUpperCamelCase clusterName}} { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - {{#chip_available_cluster_commands}} + {{#all_incoming_commands_for_cluster clusterName clusterSide}} {{#first}} CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; @@ -39,7 +38,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP switch (aCommandPath.mCommandId) { {{/first}} - case Commands::{{asUpperCamelCase name}}::Id: { + case Commands::{{asUpperCamelCase commandName}}::Id: { {{> im_command_handler_cluster_commands}} break; } @@ -59,17 +58,13 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); } {{/last}} - {{else}} - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); - {{/chip_available_cluster_commands}} + {{/all_incoming_commands_for_cluster}} } } {{/if}} -{{/if}} -{{/all_user_clusters}} +{{/all_user_clusters_with_incoming_commands}} } // namespace Clusters diff --git a/src/app/zap-templates/templates/chip/helper.js b/src/app/zap-templates/templates/chip/helper.js index a8f513c4b6f84d..876c32bc6e651a 100644 --- a/src/app/zap-templates/templates/chip/helper.js +++ b/src/app/zap-templates/templates/chip/helper.js @@ -275,11 +275,14 @@ function chip_cluster_command_arguments(options) function chip_cluster_command_arguments_with_structs_expanded(options) { const commandId = checkIsInsideCommandBlock(this, 'chip_cluster_command_arguments'); - const commands = getCommands.call(this.parent, 'chip_cluster_commands_argments_with_structs_expanded'); + const commands = getCommands.call(this.parent, 'chip_cluster_command_arguments_with_structs_expanded'); const filter = command => command.id == commandId; return asBlocks.call(this, commands.then(items => { const item = items.find(filter); + if (item === undefined) { + return []; + } return item.expandedArguments || item.arguments; }), options); diff --git a/src/controller/CommandSenderAllocator.h b/src/controller/CommandSenderAllocator.h index 535fe2f463ec2e..7c8438e236c175 100644 --- a/src/controller/CommandSenderAllocator.h +++ b/src/controller/CommandSenderAllocator.h @@ -31,8 +31,5 @@ class CommandSenderPlatformDeleter public: void operator()(app::CommandSender * commandSender) const { chip::Platform::Delete(commandSender); } }; - -using CommandSenderHandle = std::unique_ptr; - } // namespace Controller } // namespace chip diff --git a/zzz_generated/light-switch-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/light-switch-app/zap-generated/CHIPClientCallbacks.cpp new file mode 100644 index 00000000000000..625230556c915c --- /dev/null +++ b/zzz_generated/light-switch-app/zap-generated/CHIPClientCallbacks.cpp @@ -0,0 +1,258 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// THIS FILE IS GENERATED BY ZAP + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace ::chip; +using namespace ::chip::app::DataModel; + +namespace { +[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; +} // namespace + +#define CHECK_STATUS_WITH_RETVAL(error, retval) \ + if (CHIP_NO_ERROR != error) \ + { \ + ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ + if (onFailureCallback != nullptr) \ + { \ + Callback::Callback * cb = \ + Callback::Callback::FromCancelable(onFailureCallback); \ + cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ + } \ + return retval; \ + } + +#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) +#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) + +#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ + if (!CanCastTo(value)) \ + { \ + ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ + if (onFailureCallback != nullptr) \ + { \ + Callback::Callback * cb = \ + Callback::Callback::FromCancelable(onFailureCallback); \ + cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ + } \ + return retval; \ + } \ + \ + if (messageLen < value) \ + { \ + ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ + if (onFailureCallback != nullptr) \ + { \ + Callback::Callback * cb = \ + Callback::Callback::FromCancelable(onFailureCallback); \ + cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ + } \ + return retval; \ + } \ + \ + messageLen = static_cast(messageLen - static_cast(value)); + +#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) +#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) + +#define GET_RESPONSE_CALLBACKS(name) \ + Callback::Cancelable * onSuccessCallback = nullptr; \ + Callback::Cancelable * onFailureCallback = nullptr; \ + NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ + uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ + CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ + \ + if (CHIP_NO_ERROR != err) \ + { \ + if (onSuccessCallback == nullptr) \ + { \ + ChipLogDetail(Zcl, "%s: Missing success callback", name); \ + } \ + \ + if (onFailureCallback == nullptr) \ + { \ + ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ + } \ + \ + return true; \ + } + +#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ + Callback::Cancelable * onSuccessCallback = nullptr; \ + Callback::Cancelable * onFailureCallback = nullptr; \ + NodeId sourceIdentifier = reinterpret_cast(commandObj); \ + /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ + CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ + \ + if (CHIP_NO_ERROR != err) \ + { \ + if (onSuccessCallback == nullptr) \ + { \ + ChipLogDetail(Zcl, "%s: Missing success callback", name); \ + } \ + \ + if (onFailureCallback == nullptr) \ + { \ + ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ + } \ + \ + return true; \ + } + +// Singleton instance of the callbacks manager +app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); + +void GroupsClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::DataModel::DecodableList list; + CHIP_ERROR err = Decode(*tlvData, list); + if (err != CHIP_NO_ERROR) + { + if (onFailureCallback != nullptr) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } + return; + } + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, list); +} + +void IdentifyClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::DataModel::DecodableList list; + CHIP_ERROR err = Decode(*tlvData, list); + if (err != CHIP_NO_ERROR) + { + if (onFailureCallback != nullptr) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } + return; + } + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, list); +} + +void OnOffClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::DataModel::DecodableList list; + CHIP_ERROR err = Decode(*tlvData, list); + if (err != CHIP_NO_ERROR) + { + if (onFailureCallback != nullptr) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } + return; + } + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, list); +} + +void ScenesClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::DataModel::DecodableList list; + CHIP_ERROR err = Decode(*tlvData, list); + if (err != CHIP_NO_ERROR) + { + if (onFailureCallback != nullptr) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } + return; + } + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, list); +} + +bool emberAfOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, + uint8_t action, uint32_t delayedActionTime) +{ + ChipLogProgress(Zcl, "ApplyUpdateResponse:"); + ChipLogProgress(Zcl, " action: %" PRIu8 "", action); + ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime); + + GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback"); + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, action, delayedActionTime); + return true; +} + +bool emberAfOtaSoftwareUpdateProviderClusterQueryImageResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, + uint8_t status, uint32_t delayedActionTime, + chip::CharSpan imageURI, uint32_t softwareVersion, + chip::CharSpan softwareVersionString, + chip::ByteSpan updateToken, bool userConsentNeeded, + chip::ByteSpan metadataForRequestor) +{ + ChipLogProgress(Zcl, "QueryImageResponse:"); + ChipLogProgress(Zcl, " status: %" PRIu8 "", status); + ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime); + ChipLogProgress(Zcl, " imageURI: %.*s", static_cast(imageURI.size()), imageURI.data()); + ChipLogProgress(Zcl, " softwareVersion: %" PRIu32 "", softwareVersion); + ChipLogProgress(Zcl, " softwareVersionString: %.*s", static_cast(softwareVersionString.size()), + softwareVersionString.data()); + ChipLogProgress(Zcl, " updateToken: %zu", updateToken.size()); + ChipLogProgress(Zcl, " userConsentNeeded: %d", userConsentNeeded); + ChipLogProgress(Zcl, " metadataForRequestor: %zu", metadataForRequestor.size()); + + GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterQueryImageResponseCallback"); + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, status, delayedActionTime, imageURI, softwareVersion, softwareVersionString, updateToken, + userConsentNeeded, metadataForRequestor); + return true; +} diff --git a/zzz_generated/light-switch-app/zap-generated/CHIPClusters.cpp b/zzz_generated/light-switch-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index c6f5c67dfa1fdf..00000000000000 --- a/zzz_generated/light-switch-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,1657 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// ColorControl Cluster Commands -CHIP_ERROR ColorControlCluster::ColorLoopSet(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t updateFlags, uint8_t action, uint8_t direction, uint16_t time, - uint16_t startHue, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::ColorLoopSet::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateFlags: colorLoopUpdateFlags - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateFlags)); - // action: colorLoopAction - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), action)); - // direction: colorLoopDirection - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), direction)); - // time: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), time)); - // startHue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), startHue)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedMoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint16_t rate, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::EnhancedMoveHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: hueMoveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedMoveToHue(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t enhancedHue, uint8_t direction, - uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::EnhancedMoveToHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // enhancedHue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), enhancedHue)); - // direction: hueDirection - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), direction)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedMoveToHueAndSaturation(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t enhancedHue, - uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ColorControl::Commands::EnhancedMoveToHueAndSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // enhancedHue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), enhancedHue)); - // saturation: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), saturation)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedStepHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint16_t stepSize, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::EnhancedStepHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: hueStepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - int16_t rateX, int16_t rateY, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveColor::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // rateX: int16s - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rateX)); - // rateY: int16s - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rateY)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: hueMoveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: saturationMoveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t colorX, uint16_t colorY, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveToColor::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // colorX: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), colorX)); - // colorY: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), colorY)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToColorTemperature(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t colorTemperature, - uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ColorControl::Commands::MoveToColorTemperature::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // colorTemperature: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperature)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t hue, uint8_t direction, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveToHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // hue: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hue)); - // direction: hueDirection - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), direction)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToHueAndSaturation(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t hue, uint8_t saturation, - uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ColorControl::Commands::MoveToHueAndSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // hue: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hue)); - // saturation: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), saturation)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveToSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // saturation: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), saturation)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::StepColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - int16_t stepX, int16_t stepY, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::StepColor::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepX: int16s - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepX)); - // stepY: int16s - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepY)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::StepHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::StepHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: hueStepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::StepSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::StepSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: saturationStepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// Groups Cluster Commands -CHIP_ERROR GroupsCluster::AddGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, chip::CharSpan groupName) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Groups::Commands::AddGroup::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // groupName: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), groupName)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GroupsCluster::AddGroupIfIdentifying(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, chip::CharSpan groupName) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Groups::Commands::AddGroupIfIdentifying::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // groupName: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), groupName)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GroupsCluster::GetGroupMembership(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupList) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Groups::Commands::GetGroupMembership::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupList: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupList)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GroupsCluster::RemoveAllGroups(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Groups::Commands::RemoveAllGroups::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GroupsCluster::RemoveGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Groups::Commands::RemoveGroup::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GroupsCluster::ViewGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Groups::Commands::ViewGroup::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// Identify Cluster Commands - -// OtaSoftwareUpdateProvider Cluster Commands -CHIP_ERROR OtaSoftwareUpdateProviderCluster::ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t newVersion) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateToken: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken)); - // newVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), newVersion)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OtaSoftwareUpdateProviderCluster::NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t softwareVersion) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateToken: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken)); - // softwareVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OtaSoftwareUpdateProviderCluster::QueryImage(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::VendorId vendorId, - uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported, - uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent, - chip::ByteSpan metadataForProvider) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::QueryImage::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // vendorId: vendorId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), vendorId)); - // productId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), productId)); - // softwareVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion)); - // protocolsSupported: OTADownloadProtocol - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), protocolsSupported)); - // hardwareVersion: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hardwareVersion)); - // location: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), location)); - // requestorCanConsent: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), requestorCanConsent)); - // metadataForProvider: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), metadataForProvider)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// OnOff Cluster Commands -CHIP_ERROR OnOffCluster::Off(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::Off::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::On(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::On::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::Toggle(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::Toggle::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// Scenes Cluster Commands -CHIP_ERROR ScenesCluster::AddScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, uint8_t sceneId, uint16_t transitionTime, chip::CharSpan sceneName, - chip::ClusterId clusterId, uint8_t length, uint8_t value) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::AddScene::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // sceneId: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // sceneName: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), sceneName)); - // clusterId: clusterId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), clusterId)); - // length: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), length)); - // value: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), value)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ScenesCluster::GetSceneMembership(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::GetSceneMembership::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ScenesCluster::RecallScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, uint8_t sceneId, uint16_t transitionTime) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::RecallScene::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // sceneId: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ScenesCluster::RemoveAllScenes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::RemoveAllScenes::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ScenesCluster::RemoveScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, uint8_t sceneId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::RemoveScene::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // sceneId: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ScenesCluster::StoreScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, uint8_t sceneId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::StoreScene::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // sceneId: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ScenesCluster::ViewScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, uint8_t sceneId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::ViewScene::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // sceneId: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/tv-casting-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/tv-casting-app/zap-generated/IMClusterCommandHandler.cpp index c4691a36c9a2b5..66ec5a06b55e34 100644 --- a/zzz_generated/tv-casting-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/tv-casting-app/zap-generated/IMClusterCommandHandler.cpp @@ -1275,15 +1275,6 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } break; } - case Commands::TestSpecific::Id: { - Commands::TestSpecific::DecodableType commandData; - TLVError = DataModel::Decode(aDataTlv, commandData); - if (TLVError == CHIP_NO_ERROR) - { - wasHandled = emberAfTestClusterClusterTestSpecificCallback(apCommandObj, aCommandPath, commandData); - } - break; - } default: { // Unrecognized command ID, error status will apply. apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand);