diff --git a/src/app/Command.h b/src/app/Command.h index a4a75d3b8df0b5..f396ad778c789d 100644 --- a/src/app/Command.h +++ b/src/app/Command.h @@ -83,12 +83,12 @@ class Command return CHIP_ERROR_NOT_IMPLEMENTED; } - virtual CHIP_ERROR AddClusterSpecificSuccess(ConcreteCommandPath & aCommandPath, uint8_t aClusterStatus) + virtual CHIP_ERROR AddClusterSpecificSuccess(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus) { return CHIP_ERROR_NOT_IMPLEMENTED; } - virtual CHIP_ERROR AddClusterSpecificFailure(ConcreteCommandPath & aCommandPath, uint8_t aClusterStatus) + virtual CHIP_ERROR AddClusterSpecificFailure(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus) { return CHIP_ERROR_NOT_IMPLEMENTED; } diff --git a/src/app/CommandHandler.cpp b/src/app/CommandHandler.cpp index 25082046ec3248..c8acb4d4da29ac 100644 --- a/src/app/CommandHandler.cpp +++ b/src/app/CommandHandler.cpp @@ -153,7 +153,9 @@ CHIP_ERROR CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommand return CHIP_NO_ERROR; } -CHIP_ERROR CommandHandler::AddStatus(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus) +CHIP_ERROR CommandHandler::AddStatusInternal(const ConcreteCommandPath & aCommandPath, + const Protocols::InteractionModel::Status aStatus, + const Optional & aClusterStatus) { CHIP_ERROR err = CHIP_NO_ERROR; StatusIB::Builder statusIBBuilder; @@ -174,7 +176,8 @@ CHIP_ERROR CommandHandler::AddStatus(const ConcreteCommandPath & aCommandPath, c // above is always an IM code. Instead of fixing all the callers (which is a fairly sizeable change), we'll embark on fixing // this more completely when we fix #9530. // - statusIB.mStatus = aStatus; + statusIB.mStatus = aStatus; + statusIB.mClusterStatus = aClusterStatus; statusIBBuilder.EncodeStatusIB(statusIB); err = statusIBBuilder.GetError(); SuccessOrExit(err); @@ -185,6 +188,24 @@ CHIP_ERROR CommandHandler::AddStatus(const ConcreteCommandPath & aCommandPath, c return err; } +CHIP_ERROR CommandHandler::AddStatus(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus) +{ + Optional clusterStatus = Optional::Missing(); + return AddStatusInternal(aCommandPath, aStatus, clusterStatus); +} + +CHIP_ERROR CommandHandler::AddClusterSpecificSuccess(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus) +{ + Optional clusterStatus(aClusterStatus); + return AddStatusInternal(aCommandPath, Protocols::InteractionModel::Status::Success, clusterStatus); +} + +CHIP_ERROR CommandHandler::AddClusterSpecificFailure(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus) +{ + Optional clusterStatus(aClusterStatus); + return AddStatusInternal(aCommandPath, Protocols::InteractionModel::Status::Failure, clusterStatus); +} + CHIP_ERROR CommandHandler::PrepareResponse(const ConcreteCommandPath & aRequestCommandPath, CommandId aResponseCommand) { CommandPathParams params = { aRequestCommandPath.mEndpointId, diff --git a/src/app/CommandHandler.h b/src/app/CommandHandler.h index 01fb11d18db23a..38837957397be0 100644 --- a/src/app/CommandHandler.h +++ b/src/app/CommandHandler.h @@ -74,6 +74,10 @@ class CommandHandler : public Command System::PacketBufferHandle && payload); CHIP_ERROR AddStatus(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus) override; + CHIP_ERROR AddClusterSpecificSuccess(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus) override; + + CHIP_ERROR AddClusterSpecificFailure(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus) override; + /** * API for adding a data response. The template parameter T is generally * expected to be a ClusterName::Commands::CommandName::Type struct, but any @@ -107,6 +111,9 @@ class CommandHandler : public Command CHIP_ERROR SendCommandResponse(); CHIP_ERROR ProcessCommandDataIB(CommandDataIB::Parser & aCommandElement) override; CHIP_ERROR PrepareResponse(const ConcreteCommandPath & aRequestCommandPath, CommandId aResponseCommand); + CHIP_ERROR AddStatusInternal(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus, + const Optional & aClusterStatus); + Callback * mpCallback = nullptr; }; } // namespace app diff --git a/src/app/CommandSender.cpp b/src/app/CommandSender.cpp index b965f495bf89bf..6c67b3c5fa787f 100644 --- a/src/app/CommandSender.cpp +++ b/src/app/CommandSender.cpp @@ -79,7 +79,9 @@ CHIP_ERROR CommandSender::OnMessageReceived(Messaging::ExchangeContext * apExcha { if (err != CHIP_NO_ERROR) { - mpCallback->OnError(this, Protocols::InteractionModel::Status::Failure, err); + StatusIB status; + status.mStatus = Protocols::InteractionModel::Status::Failure; + mpCallback->OnError(this, status, err); } } @@ -95,7 +97,9 @@ void CommandSender::OnResponseTimeout(Messaging::ExchangeContext * apExchangeCon if (mpCallback != nullptr) { - mpCallback->OnError(this, Protocols::InteractionModel::Status::Failure, CHIP_ERROR_TIMEOUT); + StatusIB status; + status.mStatus = Protocols::InteractionModel::Status::Failure; + mpCallback->OnError(this, status, CHIP_ERROR_TIMEOUT); } Close(); @@ -119,6 +123,8 @@ CHIP_ERROR CommandSender::ProcessCommandDataIB(CommandDataIB::Parser & aCommandE chip::ClusterId clusterId; chip::CommandId commandId; chip::EndpointId endpointId; + // Default to success when an invoke response is received. + StatusIB statusIB; { CommandPathIB::Parser commandPath; @@ -140,8 +146,6 @@ CHIP_ERROR CommandSender::ProcessCommandDataIB(CommandDataIB::Parser & aCommandE bool hasDataResponse = false; chip::TLV::TLVReader commandDataReader; - // Default to success when an invoke response is received. - StatusIB statusIB; StatusIB::Parser statusIBParser; err = aCommandElement.GetStatusIB(&statusIBParser); if (CHIP_NO_ERROR == err) @@ -182,12 +186,12 @@ CHIP_ERROR CommandSender::ProcessCommandDataIB(CommandDataIB::Parser & aCommandE { if (statusIB.mStatus == Protocols::InteractionModel::Status::Success) { - mpCallback->OnResponse(this, ConcreteCommandPath(endpointId, clusterId, commandId), + mpCallback->OnResponse(this, ConcreteCommandPath(endpointId, clusterId, commandId), statusIB, hasDataResponse ? &commandDataReader : nullptr); } else { - mpCallback->OnError(this, statusIB.mStatus, CHIP_ERROR_IM_STATUS_CODE_RECEIVED); + mpCallback->OnError(this, statusIB, CHIP_ERROR_IM_STATUS_CODE_RECEIVED); } } } diff --git a/src/app/CommandSender.h b/src/app/CommandSender.h index 8c3a62c6e46d8f..4049798dffede8 100644 --- a/src/app/CommandSender.h +++ b/src/app/CommandSender.h @@ -64,11 +64,16 @@ class CommandSender final : public Command, public Messaging::ExchangeDelegate * The CommandSender object MUST continue to exist after this call is completed. The application shall wait until it * receives an OnDone call to destroy the object. * - * @param[in] apCommandSender The command sender object that initiated the command transaction. - * @param[in] aPath The command path field in invoke command response. - * @param[in] aData The command data, will be nullptr if the server returns a StatusIB. + * @param[in] apCommandSender: The command sender object that initiated the command transaction. + * @param[in] aPath: The command path field in invoke command response. + * @param[in] aStatusIB: It will always have a success status. If apData is null, it can be any success status, including + * possibly a cluster-specific one. If apData is not null it aStatusIB will always be a generic + * SUCCESS status with no-cluster specific information. + * @param[in] aData: The command data, will be nullptr if the server returns a StatusIB. */ - virtual void OnResponse(CommandSender * apCommandSender, const ConcreteCommandPath & aPath, TLV::TLVReader * aData) {} + virtual void OnResponse(CommandSender * apCommandSender, const ConcreteCommandPath & aPath, const StatusIB & aStatusIB, + TLV::TLVReader * apData) + {} /** * OnError will be called when an error occurr *after* a successful call to SendCommandRequest(). The following @@ -84,14 +89,11 @@ class CommandSender final : public Command, public Messaging::ExchangeDelegate * The CommandSender object MUST continue to exist after this call is completed. The application shall wait until it * receives an OnDone call to destroy and free the object. * - * @param[in] apCommandSender The command sender object that initiated the command transaction. - * @param[in] aInteractionModelStatus Contains an IM status code. This SHALL never be IM::Success, and will contain a valid - * server-side emitted error if aProtocolError == CHIP_ERROR_IM_STATUS_CODE_RECEIVED. - * @param[in] aError A system error code that conveys the overall error code. + * @param[in] apCommandSender: The command sender object that initiated the command transaction. + * @param[in] aStatusIB: The status code including IM status code and optional cluster status code + * @param[in] aError: A system error code that conveys the overall error code. */ - virtual void OnError(const CommandSender * apCommandSender, Protocols::InteractionModel::Status aInteractionModelStatus, - CHIP_ERROR aError) - {} + virtual void OnError(const CommandSender * apCommandSender, const StatusIB & aStatusIB, CHIP_ERROR aError) {} /** * OnDone will be called when CommandSender has finished all work and is safe to destory and free the diff --git a/src/app/tests/TestCommandInteraction.cpp b/src/app/tests/TestCommandInteraction.cpp index ae9f803d8a8351..d40a0ed62529ca 100644 --- a/src/app/tests/TestCommandInteraction.cpp +++ b/src/app/tests/TestCommandInteraction.cpp @@ -116,7 +116,7 @@ class MockCommandSenderCallback : public CommandSender::Callback { public: void OnResponse(chip::app::CommandSender * apCommandSender, const chip::app::ConcreteCommandPath & aPath, - chip::TLV::TLVReader * aData) override + const chip::app::StatusIB & aStatus, chip::TLV::TLVReader * aData) override { IgnoreUnusedVariable(apCommandSender); IgnoreUnusedVariable(aData); @@ -124,10 +124,10 @@ class MockCommandSenderCallback : public CommandSender::Callback aPath.mClusterId, aPath.mCommandId, aPath.mEndpointId); onResponseCalledTimes++; } - void OnError(const chip::app::CommandSender * apCommandSender, chip::Protocols::InteractionModel::Status aStatus, - CHIP_ERROR aError) override + void OnError(const chip::app::CommandSender * apCommandSender, const chip::app::StatusIB & aStatus, CHIP_ERROR aError) override { - ChipLogError(Controller, "OnError happens with %" PRIx16 " %" CHIP_ERROR_FORMAT, to_underlying(aStatus), aError.Format()); + ChipLogError(Controller, "OnError happens with %" PRIx16 " %" CHIP_ERROR_FORMAT, to_underlying(aStatus.mStatus), + aError.Format()); onErrorCalledTimes++; } void OnDone(chip::app::CommandSender * apCommandSender) override { onFinalCalledTimes++; } diff --git a/src/app/tests/integration/chip_im_initiator.cpp b/src/app/tests/integration/chip_im_initiator.cpp index 71cf076f143083..247b294100f206 100644 --- a/src/app/tests/integration/chip_im_initiator.cpp +++ b/src/app/tests/integration/chip_im_initiator.cpp @@ -163,7 +163,7 @@ class MockInteractionModelApp : public chip::app::InteractionModelDelegate, } void OnResponse(chip::app::CommandSender * apCommandSender, const chip::app::ConcreteCommandPath & aPath, - chip::TLV::TLVReader * aData) override + const chip::app::StatusIB & aStatus, chip::TLV::TLVReader * aData) override { printf("Command Response Success with EndpointId %d, ClusterId %d, CommandId %d", aPath.mEndpointId, aPath.mClusterId, aPath.mCommandId); @@ -178,8 +178,7 @@ class MockInteractionModelApp : public chip::app::InteractionModelDelegate, static_cast(gCommandRespCount) * 100 / static_cast(gCommandCount), static_cast(transitTime) / 1000); } - void OnError(const chip::app::CommandSender * apCommandSender, chip::Protocols::InteractionModel::Status aProtocolCode, - CHIP_ERROR aError) override + void OnError(const chip::app::CommandSender * apCommandSender, const chip::app::StatusIB & aStatus, CHIP_ERROR aError) override { gCommandRespCount += (aError == CHIP_ERROR_IM_STATUS_CODE_RECEIVED); gLastCommandResult = TestCommandResult::kFailure; diff --git a/src/app/zap-templates/templates/app/CHIPClusters-src.zapt b/src/app/zap-templates/templates/app/CHIPClusters-src.zapt index 36323515d6a421..612a993d049ba8 100644 --- a/src/app/zap-templates/templates/app/CHIPClusters-src.zapt +++ b/src/app/zap-templates/templates/app/CHIPClusters-src.zapt @@ -146,12 +146,12 @@ CHIP_ERROR ClusterBase::InvokeCommand(const RequestDataT & requestData, void * c VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); ReturnErrorOnFailure(mDevice->LoadSecureSessionParametersIfNeeded()); - auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const ResponseDataT & responseData) { + auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const app::StatusIB & aStatus, const ResponseDataT & responseData) { successCb(context, responseData); }; - auto onFailureCb = [context, failureCb](Protocols::InteractionModel::Status aIMStatus, CHIP_ERROR aError) { - failureCb(context, app::ToEmberAfStatus(aIMStatus)); + auto onFailureCb = [context, failureCb](const app::StatusIB & aStatus, CHIP_ERROR aError) { + failureCb(context, app::ToEmberAfStatus(aStatus.mStatus)); }; return InvokeCommandRequest(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(), mEndpoint, diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index c5a538fd4858c4..db0c58215ebf24 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -1669,7 +1669,8 @@ void DeviceCommissioner::OnNodeDiscoveryComplete(const chip::Dnssd::DiscoveredNo #endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY void DeviceControllerInteractionModelDelegate::OnResponse(app::CommandSender * apCommandSender, - const app::ConcreteCommandPath & aPath, TLV::TLVReader * aData) + const app::ConcreteCommandPath & aPath, + const chip::app::StatusIB & aStatus, TLV::TLVReader * aData) { // Generally IM has more detailed errors than ember library, here we always use the, the actual handling of the // commands should implement full IMDelegate. @@ -1687,7 +1688,7 @@ void DeviceControllerInteractionModelDelegate::OnResponse(app::CommandSender * a } void DeviceControllerInteractionModelDelegate::OnError(const app::CommandSender * apCommandSender, - Protocols::InteractionModel::Status aClusterStatus, CHIP_ERROR aError) + const chip::app::StatusIB & aStatus, CHIP_ERROR aError) { // The IMDefaultResponseCallback started out life as an Ember function, so it only accepted // Ember status codes. Consequently, let's convert the IM code over to a meaningful Ember status before dispatching. @@ -1696,7 +1697,7 @@ void DeviceControllerInteractionModelDelegate::OnError(const app::CommandSender // well, this will be an even bigger problem. // // For now, #10331 tracks this issue. - IMDefaultResponseCallback(apCommandSender, app::ToEmberAfStatus(aClusterStatus)); + IMDefaultResponseCallback(apCommandSender, app::ToEmberAfStatus(aStatus.mStatus)); } void DeviceControllerInteractionModelDelegate::OnDone(app::CommandSender * apCommandSender) diff --git a/src/controller/DeviceControllerInteractionModelDelegate.h b/src/controller/DeviceControllerInteractionModelDelegate.h index b208e58e125eb7..8e0b7afe72098e 100644 --- a/src/controller/DeviceControllerInteractionModelDelegate.h +++ b/src/controller/DeviceControllerInteractionModelDelegate.h @@ -20,8 +20,9 @@ class DeviceControllerInteractionModelDelegate : public chip::app::InteractionMo public chip::app::WriteClient::Callback { public: - void OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommandPath & aPath, TLV::TLVReader * aData) override; - void OnError(const app::CommandSender * apCommandSender, Protocols::InteractionModel::Status aInteractionModelStatus, + void OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommandPath & aPath, + const chip::app::StatusIB & aStatus, TLV::TLVReader * aData) override; + void OnError(const app::CommandSender * apCommandSender, const chip::app::StatusIB & aStatus, CHIP_ERROR aProtocolError) override; void OnDone(app::CommandSender * apCommandSender) override; diff --git a/src/controller/TypedCommandCallback.h b/src/controller/TypedCommandCallback.h index 0318d55d3be918..2d87b3e1c86200 100644 --- a/src/controller/TypedCommandCallback.h +++ b/src/controller/TypedCommandCallback.h @@ -39,9 +39,10 @@ template class TypedCommandCallback final : public app::CommandSender::Callback { public: - using OnSuccessCallbackType = std::function; - using OnErrorCallbackType = std::function; - using OnDoneCallbackType = std::function; + using OnSuccessCallbackType = + std::function; + using OnErrorCallbackType = std::function; + using OnDoneCallbackType = std::function; /* * Constructor that takes in success, failure and onDone callbacks. @@ -58,12 +59,11 @@ class TypedCommandCallback final : public app::CommandSender::Callback private: void OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommandPath & aCommandPath, - TLV::TLVReader * aReader) override; + const app::StatusIB & aStatus, TLV::TLVReader * aReader) override; - void OnError(const app::CommandSender * apCommandSender, Protocols::InteractionModel::Status aIMStatus, - CHIP_ERROR aError) override + void OnError(const app::CommandSender * apCommandSender, const app::StatusIB & aStatus, CHIP_ERROR aError) override { - mOnError(aIMStatus, aError); + mOnError(aStatus, aError); } void OnDone(app::CommandSender * apCommandSender) override { mOnDone(apCommandSender); } @@ -81,7 +81,7 @@ class TypedCommandCallback final : public app::CommandSender::Callback template void TypedCommandCallback::OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommandPath & aCommandPath, - TLV::TLVReader * aReader) + const app::StatusIB & aStatus, TLV::TLVReader * aReader) { CommandResponseObjectT response; CHIP_ERROR err = CHIP_NO_ERROR; @@ -102,12 +102,14 @@ void TypedCommandCallback::OnResponse(app::CommandSender err = app::DataModel::Decode(*aReader, response); SuccessOrExit(err); - mOnSuccess(aCommandPath, response); + mOnSuccess(aCommandPath, aStatus, response); exit: if (err != CHIP_NO_ERROR) { - mOnError(Protocols::InteractionModel::Status::Failure, err); + app::StatusIB status; + status.mStatus = Protocols::InteractionModel::Status::Failure; + mOnError(status, err); } } @@ -120,6 +122,7 @@ void TypedCommandCallback::OnResponse(app::CommandSender template <> inline void TypedCommandCallback::OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommandPath & aCommandPath, + const app::StatusIB & aStatus, TLV::TLVReader * aReader) { // @@ -127,12 +130,14 @@ inline void TypedCommandCallback::OnResponse(app // if (aReader != nullptr) { - mOnError(Protocols::InteractionModel::Status::Failure, CHIP_ERROR_SCHEMA_MISMATCH); + app::StatusIB status; + status.mStatus = Protocols::InteractionModel::Status::Failure; + mOnError(status, CHIP_ERROR_SCHEMA_MISMATCH); return; } app::DataModel::NullObjectType nullResp; - mOnSuccess(aCommandPath, nullResp); + mOnSuccess(aCommandPath, aStatus, nullResp); } } // namespace Controller diff --git a/src/controller/python/chip/clusters/Command.py b/src/controller/python/chip/clusters/Command.py index 9348e3bd591432..906c228b1aa039 100644 --- a/src/controller/python/chip/clusters/Command.py +++ b/src/controller/python/chip/clusters/Command.py @@ -19,7 +19,7 @@ import ctypes from dataclasses import dataclass from typing import Type -from ctypes import CFUNCTYPE, c_char_p, c_size_t, c_void_p, c_uint32, c_uint16, py_object +from ctypes import CFUNCTYPE, c_char_p, c_size_t, c_void_p, c_uint32, c_uint16, c_uint8, py_object from .ClusterObjects import ClusterCommand @@ -34,27 +34,33 @@ class CommandPath: CommandId: int +@dataclass +class Status: + IMStatus: int + ClusterStatus: int + + class AsyncCommandTransaction: def __init__(self, future: Future, eventLoop, expectType: Type): self._event_loop = eventLoop self._future = future self._expect_type = expectType - def _handleResponse(self, response: bytes): + def _handleResponse(self, status: Status, response: bytes): if self._expect_type: try: self._future.set_result(self._expect_type.FromTLV(response)) except Exception as ex: self._handleError( - chip.interaction_model.Status.Failure, 0, ex) + status, 0, ex) else: self._future.set_result(None) - def handleResponse(self, path: CommandPath, response: bytes): + def handleResponse(self, path: CommandPath, status: Status, response: bytes): self._event_loop.call_soon_threadsafe( - self._handleResponse, response) + self._handleResponse, status, response) - def _handleError(self, imError: int, chipError: int, exception: Exception): + def _handleError(self, status: Status, chipError: int, exception: Exception): if exception: self._future.set_exception(exception) elif chipError != 0 and chipError != 0xCA: @@ -64,34 +70,35 @@ def _handleError(self, imError: int, chipError: int, exception: Exception): else: try: self._future.set_exception( - chip.interaction_model.InteractionModelError(chip.interaction_model.Status(imError))) + chip.interaction_model.InteractionModelError(chip.interaction_model.Status(status.IMStatus))) except: self._future.set_exception(chip.interaction_model.InteractionModelError( chip.interaction_model.Status.Failure)) - def handleError(self, imError: int, chipError: int): + def handleError(self, status: Status, chipError: int): self._event_loop.call_soon_threadsafe( - self._handleError, imError, chipError, None + self._handleError, status, chipError, None ) _OnCommandSenderResponseCallbackFunct = CFUNCTYPE( - None, py_object, c_uint16, c_uint32, c_uint32, c_void_p, c_uint32) + None, py_object, c_uint16, c_uint32, c_uint32, c_uint16, c_uint8, c_void_p, c_uint32) _OnCommandSenderErrorCallbackFunct = CFUNCTYPE( - None, py_object, c_uint16, c_uint32) + None, py_object, c_uint16, c_uint8, c_uint32) _OnCommandSenderDoneCallbackFunct = CFUNCTYPE( None, py_object) @_OnCommandSenderResponseCallbackFunct -def _OnCommandSenderResponseCallback(closure, endpoint: int, cluster: int, command: int, payload, size): +def _OnCommandSenderResponseCallback(closure, endpoint: int, cluster: int, command: int, imStatus: int, clusterStatus: int, payload, size): data = ctypes.string_at(payload, size) - closure.handleResponse(CommandPath(endpoint, cluster, command), data[:]) + closure.handleResponse(CommandPath(endpoint, cluster, command), Status( + imStatus, clusterStatus), data[:]) @_OnCommandSenderErrorCallbackFunct -def _OnCommandSenderErrorCallback(closure, imerror: int, chiperror: int): - closure.handleError(imerror, chiperror) +def _OnCommandSenderErrorCallback(closure, imStatus: int, clusterStatus: int, chiperror: int): + closure.handleError(Status(imStatus, clusterStatus), chiperror) @_OnCommandSenderDoneCallbackFunct diff --git a/src/controller/python/chip/clusters/command.cpp b/src/controller/python/chip/clusters/command.cpp index 9d9b1862dddee0..7ba28684ef1794 100644 --- a/src/controller/python/chip/clusters/command.cpp +++ b/src/controller/python/chip/clusters/command.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -40,10 +41,12 @@ namespace chip { namespace python { using OnCommandSenderResponseCallback = void (*)(PyObject appContext, chip::EndpointId endpointId, chip::ClusterId clusterId, - chip::CommandId commandId, const uint8_t * payload, uint32_t length); + chip::CommandId commandId, + std::underlying_type_t status, + chip::ClusterStatus clusterStatus, const uint8_t * payload, uint32_t length); using OnCommandSenderErrorCallback = void (*)(PyObject appContext, - std::underlying_type_t imstatus, - uint32_t chiperror); + std::underlying_type_t status, + chip::ClusterStatus clusterStatus, uint32_t chiperror); using OnCommandSenderDoneCallback = void (*)(PyObject appContext); OnCommandSenderResponseCallback gOnCommandSenderResponseCallback = nullptr; @@ -55,7 +58,8 @@ class CommandSenderCallback : public CommandSender::Callback public: CommandSenderCallback(PyObject appContext) : mAppContext(appContext) {} - void OnResponse(CommandSender * apCommandSender, const ConcreteCommandPath & aPath, TLV::TLVReader * aData) override + void OnResponse(CommandSender * apCommandSender, const ConcreteCommandPath & aPath, const app::StatusIB & aStatus, + TLV::TLVReader * aData) override { uint8_t buffer[CHIP_CONFIG_DEFAULT_UDP_MTU_SIZE]; uint32_t size = 0; @@ -69,19 +73,26 @@ class CommandSenderCallback : public CommandSender::Callback CHIP_ERROR err = writer.CopyContainer(TLV::AnonymousTag, *aData); if (err != CHIP_NO_ERROR) { - this->OnError(apCommandSender, Protocols::InteractionModel::Status::Failure, err); + app::StatusIB status; + status.mStatus = Protocols::InteractionModel::Status::Failure; + this->OnError(apCommandSender, aStatus, err); return; } size = writer.GetLengthWritten(); } - gOnCommandSenderResponseCallback(mAppContext, aPath.mEndpointId, aPath.mClusterId, aPath.mCommandId, buffer, size); + gOnCommandSenderResponseCallback( + mAppContext, aPath.mEndpointId, aPath.mClusterId, aPath.mCommandId, to_underlying(aStatus.mStatus), + aStatus.mClusterStatus.HasValue() ? aStatus.mClusterStatus.Value() : chip::python::kUndefinedClusterStatus, buffer, + size); } - void OnError(const CommandSender * apCommandSender, Protocols::InteractionModel::Status aInteractionModelStatus, - CHIP_ERROR aProtocolError) override + void OnError(const CommandSender * apCommandSender, const app::StatusIB & aStatus, CHIP_ERROR aProtocolError) override { - gOnCommandSenderErrorCallback(mAppContext, to_underlying(aInteractionModelStatus), aProtocolError.AsInteger()); + gOnCommandSenderErrorCallback(mAppContext, to_underlying(aStatus.mStatus), + aStatus.mClusterStatus.HasValue() ? aStatus.mClusterStatus.Value() + : chip::python::kUndefinedClusterStatus, + aProtocolError.AsInteger()); } void OnDone(CommandSender * apCommandSender) override diff --git a/src/controller/python/chip/interaction_model/Delegate.cpp b/src/controller/python/chip/interaction_model/Delegate.cpp index 810c6bbce3405c..6d127373b597bb 100644 --- a/src/controller/python/chip/interaction_model/Delegate.cpp +++ b/src/controller/python/chip/interaction_model/Delegate.cpp @@ -33,17 +33,23 @@ namespace Controller { PythonInteractionModelDelegate gPythonInteractionModelDelegate; void PythonInteractionModelDelegate::OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommandPath & aPath, - TLV::TLVReader * aData) + const app::StatusIB & aStatus, TLV::TLVReader * aData) { - CommandStatus status{ Protocols::InteractionModel::Status::Success, aPath.mEndpointId, aPath.mClusterId, aPath.mCommandId, - 1 }; // This indicates the index of the command if multiple command/status payloads are present in the - // message. For now, we don't support this in the IM layer, so just always set this to 1. + CommandStatus status{ + aStatus.mStatus, + aStatus.mClusterStatus.HasValue() ? aStatus.mClusterStatus.Value() : chip::python::kUndefinedClusterStatus, + aPath.mEndpointId, + aPath.mClusterId, + aPath.mCommandId, + 1 + }; // This indicates the index of the command if multiple command/status payloads are present in the + // message. For now, we don't support this in the IM layer, so just always set this to 1. if (commandResponseStatusFunct != nullptr) { commandResponseStatusFunct(reinterpret_cast(apCommandSender), &status, sizeof(status)); } - DeviceControllerInteractionModelDelegate::OnResponse(apCommandSender, aPath, aData); + DeviceControllerInteractionModelDelegate::OnResponse(apCommandSender, aPath, aStatus, aData); if (commandResponseErrorFunct != nullptr) { @@ -51,10 +57,16 @@ void PythonInteractionModelDelegate::OnResponse(app::CommandSender * apCommandSe } } -void PythonInteractionModelDelegate::OnError(const app::CommandSender * apCommandSender, - Protocols::InteractionModel::Status aStatus, CHIP_ERROR aError) +void PythonInteractionModelDelegate::OnError(const app::CommandSender * apCommandSender, const app::StatusIB & aStatus, + CHIP_ERROR aError) { - CommandStatus status{ aStatus, 0, 0, 0, 1 }; + CommandStatus status{ aStatus.mStatus, + aStatus.mClusterStatus.HasValue() ? aStatus.mClusterStatus.Value() + : chip::python::kUndefinedClusterStatus, + 0, + 0, + 0, + 1 }; if (commandResponseStatusFunct != nullptr) { diff --git a/src/controller/python/chip/interaction_model/Delegate.h b/src/controller/python/chip/interaction_model/Delegate.h index 7ff906076ab2c8..a55ddbf2222ebf 100644 --- a/src/controller/python/chip/interaction_model/Delegate.h +++ b/src/controller/python/chip/interaction_model/Delegate.h @@ -23,6 +23,9 @@ #include namespace chip { +namespace python { +static constexpr ClusterStatus kUndefinedClusterStatus = 0xFF; +} namespace Controller { // The command status will be used for python script. @@ -30,6 +33,7 @@ namespace Controller { struct __attribute__((packed)) CommandStatus { Protocols::InteractionModel::Status status; + chip::ClusterStatus clusterStatus; chip::EndpointId endpointId; chip::ClusterId clusterId; chip::CommandId commandId; @@ -39,7 +43,7 @@ struct __attribute__((packed)) CommandStatus static_assert(std::is_same::value && std::is_same::value && std::is_same::value, "Members in CommandStatus does not match interaction_model/delegate.py"); -static_assert(sizeof(CommandStatus) == 2 + 2 + 4 + 4 + 1, "Size of CommandStatus might contain padding"); +static_assert(sizeof(CommandStatus) == 2 + 1 + 2 + 4 + 4 + 1, "Size of CommandStatus might contain padding"); struct __attribute__((packed)) AttributePath { @@ -93,9 +97,9 @@ void pychip_InteractionModelDelegate_SetOnWriteResponseStatusCallback(PythonInte class PythonInteractionModelDelegate : public chip::Controller::DeviceControllerInteractionModelDelegate { public: - void OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommandPath & aPath, TLV::TLVReader * aData) override; - void OnError(const app::CommandSender * apCommandSender, Protocols::InteractionModel::Status aStatus, - CHIP_ERROR aError) override; + void OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommandPath & aPath, const app::StatusIB & aStatus, + TLV::TLVReader * aData) override; + void OnError(const app::CommandSender * apCommandSender, const app::StatusIB & aStatus, CHIP_ERROR aError) override; void OnReportData(const app::ReadClient * apReadClient, const app::ClusterInfo & aPath, TLV::TLVReader * apData, Protocols::InteractionModel::Status status) override; diff --git a/src/controller/python/chip/interaction_model/delegate.py b/src/controller/python/chip/interaction_model/delegate.py index 15ac1d04469b40..f8205dd0e7cde6 100644 --- a/src/controller/python/chip/interaction_model/delegate.py +++ b/src/controller/python/chip/interaction_model/delegate.py @@ -29,6 +29,7 @@ # CommandStatus should not contain padding IMCommandStatus = Struct( "Status" / Int16ul, + "ClusterStatus" / Int8ul, "EndpointId" / Int16ul, "ClusterId" / Int32ul, "CommandId" / Int32ul, diff --git a/src/controller/tests/data_model/TestCommands.cpp b/src/controller/tests/data_model/TestCommands.cpp index 7aebdcf41f9622..2acd3c873aaab1 100644 --- a/src/controller/tests/data_model/TestCommands.cpp +++ b/src/controller/tests/data_model/TestCommands.cpp @@ -44,8 +44,9 @@ chip::Test::LoopbackTransport gLoopback; chip::Test::IOContext gIOContext; chip::Messaging::ExchangeManager * gExchangeManager; secure_channel::MessageCounterManager gMessageCounterManager; - -using TestContext = chip::Test::MessagingContext; +chip::ClusterStatus kTestSuccessClusterStatus = 1; +chip::ClusterStatus kTestFailureClusterStatus = 2; +using TestContext = chip::Test::MessagingContext; TestContext sContext; constexpr EndpointId kTestEndpointId = 1; @@ -54,7 +55,9 @@ enum ResponseDirective { kSendDataResponse, kSendSuccessStatusCode, - kSendError + kSendError, + kSendSuccessStatusCodeWithClusterStatus, + kSendErrorWithClusterStatus, }; ResponseDirective responseDirective; @@ -111,6 +114,14 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip { apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::Failure); } + else if (responseDirective == kSendSuccessStatusCodeWithClusterStatus) + { + apCommandObj->AddClusterSpecificSuccess(aCommandPath, kTestSuccessClusterStatus); + } + else if (responseDirective == kSendErrorWithClusterStatus) + { + apCommandObj->AddClusterSpecificFailure(aCommandPath, kTestFailureClusterStatus); + } } } @@ -142,6 +153,8 @@ class TestCommandInteraction static void TestDataResponse(nlTestSuite * apSuite, void * apContext); static void TestSuccessNoDataResponse(nlTestSuite * apSuite, void * apContext); static void TestFailure(nlTestSuite * apSuite, void * apContext); + static void TestSuccessNoDataResponseWithClusterStatus(nlTestSuite * apSuite, void * apContext); + static void TestFailureWithClusterStatus(nlTestSuite * apSuite, void * apContext); private: }; @@ -159,10 +172,9 @@ void TestCommandInteraction::TestDataResponse(nlTestSuite * apSuite, void * apCo // Passing of stack variables by reference is only safe because of synchronous completion of the interaction. Otherwise, it's // not safe to do so. - auto onSuccessCb = [apSuite, &onSuccessWasCalled](const app::ConcreteCommandPath & commandPath, const auto & dataResponse) { - uint8_t i; - - i = 0; + auto onSuccessCb = [apSuite, &onSuccessWasCalled](const app::ConcreteCommandPath & commandPath, const app::StatusIB & aStatus, + const auto & dataResponse) { + uint8_t i = 0; auto iter = dataResponse.arg1.begin(); while (iter.Next()) { @@ -183,9 +195,7 @@ void TestCommandInteraction::TestDataResponse(nlTestSuite * apSuite, void * apCo // Passing of stack variables by reference is only safe because of synchronous completion of the interaction. Otherwise, it's // not safe to do so. - auto onFailureCb = [&onFailureWasCalled](Protocols::InteractionModel::Status aIMStatus, CHIP_ERROR aError) { - onFailureWasCalled = true; - }; + auto onFailureCb = [&onFailureWasCalled](const app::StatusIB & aStatus, CHIP_ERROR aError) { onFailureWasCalled = true; }; responseDirective = kSendDataResponse; @@ -204,26 +214,26 @@ void TestCommandInteraction::TestSuccessNoDataResponse(nlTestSuite * apSuite, vo bool onSuccessWasCalled = false; bool onFailureWasCalled = false; - - request.arg1 = true; + bool statusCheck = false; + request.arg1 = true; // Passing of stack variables by reference is only safe because of synchronous completion of the interaction. Otherwise, it's // not safe to do so. - auto onSuccessCb = [&onSuccessWasCalled](const app::ConcreteCommandPath & commandPath, const auto & dataResponse) { + auto onSuccessCb = [&onSuccessWasCalled, &statusCheck](const app::ConcreteCommandPath & commandPath, + const app::StatusIB & aStatus, const auto & dataResponse) { + statusCheck = (aStatus.mStatus == Protocols::InteractionModel::Status::Success); onSuccessWasCalled = true; }; // Passing of stack variables by reference is only safe because of synchronous completion of the interaction. Otherwise, it's // not safe to do so. - auto onFailureCb = [&onFailureWasCalled](Protocols::InteractionModel::Status aIMStatus, CHIP_ERROR aError) { - onFailureWasCalled = true; - }; + auto onFailureCb = [&onFailureWasCalled](const app::StatusIB & aStatus, CHIP_ERROR aError) { onFailureWasCalled = true; }; responseDirective = kSendSuccessStatusCode; chip::Controller::InvokeCommandRequest(gExchangeManager, sessionHandle, kTestEndpointId, request, onSuccessCb, onFailureCb); - NL_TEST_ASSERT(apSuite, onSuccessWasCalled && !onFailureWasCalled); + NL_TEST_ASSERT(apSuite, onSuccessWasCalled && !onFailureWasCalled && statusCheck); NL_TEST_ASSERT(apSuite, gExchangeManager->GetNumActiveExchanges() == 0); } @@ -235,26 +245,90 @@ void TestCommandInteraction::TestFailure(nlTestSuite * apSuite, void * apContext bool onSuccessWasCalled = false; bool onFailureWasCalled = false; + bool statusCheck = false; + request.arg1 = true; - request.arg1 = true; + // Passing of stack variables by reference is only safe because of synchronous completion of the interaction. Otherwise, it's + // not safe to do so. + auto onSuccessCb = [&onSuccessWasCalled](const app::ConcreteCommandPath & commandPath, const app::StatusIB & aStatus, + const auto & dataResponse) { onSuccessWasCalled = true; }; // Passing of stack variables by reference is only safe because of synchronous completion of the interaction. Otherwise, it's // not safe to do so. - auto onSuccessCb = [&onSuccessWasCalled](const app::ConcreteCommandPath & commandPath, const auto & dataResponse) { + auto onFailureCb = [&onFailureWasCalled, &statusCheck](const app::StatusIB & aStatus, CHIP_ERROR aError) { + statusCheck = (aStatus.mStatus == Protocols::InteractionModel::Status::Failure); + onFailureWasCalled = true; + }; + + responseDirective = kSendError; + + chip::Controller::InvokeCommandRequest(gExchangeManager, sessionHandle, kTestEndpointId, request, onSuccessCb, onFailureCb); + + NL_TEST_ASSERT(apSuite, !onSuccessWasCalled && onFailureWasCalled && statusCheck); + NL_TEST_ASSERT(apSuite, gExchangeManager->GetNumActiveExchanges() == 0); +} + +void TestCommandInteraction::TestSuccessNoDataResponseWithClusterStatus(nlTestSuite * apSuite, void * apContext) +{ + TestContext & ctx = *static_cast(apContext); + TestCluster::Commands::TestSimpleArgumentRequest::Type request; + auto sessionHandle = ctx.GetSessionBobToAlice(); + + bool onSuccessWasCalled = false; + bool onFailureWasCalled = false; + bool statusCheck = false; + request.arg1 = true; + + // Passing of stack variables by reference is only safe because of synchronous completion of the interaction. Otherwise, it's + // not safe to do so. + auto onSuccessCb = [&onSuccessWasCalled, &statusCheck](const app::ConcreteCommandPath & commandPath, + const app::StatusIB & aStatus, const auto & dataResponse) { + statusCheck = (aStatus.mStatus == Protocols::InteractionModel::Status::Success && + aStatus.mClusterStatus.Value() == kTestSuccessClusterStatus); onSuccessWasCalled = true; }; // Passing of stack variables by reference is only safe because of synchronous completion of the interaction. Otherwise, it's // not safe to do so. - auto onFailureCb = [&onFailureWasCalled](Protocols::InteractionModel::Status aIMStatus, CHIP_ERROR aError) { + auto onFailureCb = [&onFailureWasCalled](const app::StatusIB & aStatus, CHIP_ERROR aError) { onFailureWasCalled = true; }; + + responseDirective = kSendSuccessStatusCodeWithClusterStatus; + + chip::Controller::InvokeCommandRequest(gExchangeManager, sessionHandle, kTestEndpointId, request, onSuccessCb, onFailureCb); + + NL_TEST_ASSERT(apSuite, onSuccessWasCalled && !onFailureWasCalled && statusCheck); + NL_TEST_ASSERT(apSuite, gExchangeManager->GetNumActiveExchanges() == 0); +} + +void TestCommandInteraction::TestFailureWithClusterStatus(nlTestSuite * apSuite, void * apContext) +{ + TestContext & ctx = *static_cast(apContext); + TestCluster::Commands::TestSimpleArgumentRequest::Type request; + auto sessionHandle = ctx.GetSessionBobToAlice(); + + bool onSuccessWasCalled = false; + bool onFailureWasCalled = false; + bool statusCheck = false; + request.arg1 = true; + + // Passing of stack variables by reference is only safe because of synchronous completion of the interaction. Otherwise, it's + // not safe to do so. + auto onSuccessCb = [&onSuccessWasCalled](const app::ConcreteCommandPath & commandPath, const app::StatusIB & aStatus, + const auto & dataResponse) { onSuccessWasCalled = true; }; + + // Passing of stack variables by reference is only safe because of synchronous completion of the interaction. Otherwise, it's + // not safe to do so. + auto onFailureCb = [&onFailureWasCalled, &statusCheck](const app::StatusIB & aStatus, CHIP_ERROR aError) { + statusCheck = (aStatus.mStatus == Protocols::InteractionModel::Status::Failure && + aStatus.mClusterStatus.Value() == kTestFailureClusterStatus); onFailureWasCalled = true; }; - responseDirective = kSendError; + responseDirective = kSendErrorWithClusterStatus; chip::Controller::InvokeCommandRequest(gExchangeManager, sessionHandle, kTestEndpointId, request, onSuccessCb, onFailureCb); - NL_TEST_ASSERT(apSuite, !onSuccessWasCalled && onFailureWasCalled); + NL_TEST_ASSERT(apSuite, !onSuccessWasCalled && onFailureWasCalled && statusCheck); NL_TEST_ASSERT(apSuite, gExchangeManager->GetNumActiveExchanges() == 0); } @@ -264,6 +338,8 @@ const nlTest sTests[] = NL_TEST_DEF("TestDataResponse", TestCommandInteraction::TestDataResponse), NL_TEST_DEF("TestSuccessNoDataResponse", TestCommandInteraction::TestSuccessNoDataResponse), NL_TEST_DEF("TestFailure", TestCommandInteraction::TestFailure), + NL_TEST_DEF("TestSuccessNoDataResponseWithClusterStatus", TestCommandInteraction::TestSuccessNoDataResponseWithClusterStatus), + NL_TEST_DEF("TestFailureWithClusterStatus", TestCommandInteraction::TestFailureWithClusterStatus), NL_TEST_SENTINEL() }; // clang-format on diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp b/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp index 2d6528277b5258..9e40e4691df6b1 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp @@ -15007,12 +15007,11 @@ CHIP_ERROR ClusterBase::InvokeCommand(const RequestDataT & requestData, void * c VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); ReturnErrorOnFailure(mDevice->LoadSecureSessionParametersIfNeeded()); - auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const ResponseDataT & responseData) { - successCb(context, responseData); - }; + auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const app::StatusIB & aStatus, + const ResponseDataT & responseData) { successCb(context, responseData); }; - auto onFailureCb = [context, failureCb](Protocols::InteractionModel::Status aIMStatus, CHIP_ERROR aError) { - failureCb(context, app::ToEmberAfStatus(aIMStatus)); + auto onFailureCb = [context, failureCb](const app::StatusIB & aStatus, CHIP_ERROR aError) { + failureCb(context, app::ToEmberAfStatus(aStatus.mStatus)); }; return InvokeCommandRequest(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(), mEndpoint, diff --git a/zzz_generated/lighting-app/zap-generated/CHIPClusters.cpp b/zzz_generated/lighting-app/zap-generated/CHIPClusters.cpp index 622d7a52067884..c13ca33c3dcae8 100644 --- a/zzz_generated/lighting-app/zap-generated/CHIPClusters.cpp +++ b/zzz_generated/lighting-app/zap-generated/CHIPClusters.cpp @@ -202,12 +202,11 @@ CHIP_ERROR ClusterBase::InvokeCommand(const RequestDataT & requestData, void * c VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); ReturnErrorOnFailure(mDevice->LoadSecureSessionParametersIfNeeded()); - auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const ResponseDataT & responseData) { - successCb(context, responseData); - }; + auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const app::StatusIB & aStatus, + const ResponseDataT & responseData) { successCb(context, responseData); }; - auto onFailureCb = [context, failureCb](Protocols::InteractionModel::Status aIMStatus, CHIP_ERROR aError) { - failureCb(context, app::ToEmberAfStatus(aIMStatus)); + auto onFailureCb = [context, failureCb](const app::StatusIB & aStatus, CHIP_ERROR aError) { + failureCb(context, app::ToEmberAfStatus(aStatus.mStatus)); }; return InvokeCommandRequest(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(), mEndpoint, diff --git a/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.cpp b/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.cpp index 51ec898c3590c3..15e63e5e192389 100644 --- a/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.cpp +++ b/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.cpp @@ -240,12 +240,11 @@ CHIP_ERROR ClusterBase::InvokeCommand(const RequestDataT & requestData, void * c VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); ReturnErrorOnFailure(mDevice->LoadSecureSessionParametersIfNeeded()); - auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const ResponseDataT & responseData) { - successCb(context, responseData); - }; + auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const app::StatusIB & aStatus, + const ResponseDataT & responseData) { successCb(context, responseData); }; - auto onFailureCb = [context, failureCb](Protocols::InteractionModel::Status aIMStatus, CHIP_ERROR aError) { - failureCb(context, app::ToEmberAfStatus(aIMStatus)); + auto onFailureCb = [context, failureCb](const app::StatusIB & aStatus, CHIP_ERROR aError) { + failureCb(context, app::ToEmberAfStatus(aStatus.mStatus)); }; return InvokeCommandRequest(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(), mEndpoint, diff --git a/zzz_generated/pump-app/zap-generated/CHIPClusters.cpp b/zzz_generated/pump-app/zap-generated/CHIPClusters.cpp index f871d4d0f0c12f..68ac3f7958f044 100644 --- a/zzz_generated/pump-app/zap-generated/CHIPClusters.cpp +++ b/zzz_generated/pump-app/zap-generated/CHIPClusters.cpp @@ -261,12 +261,11 @@ CHIP_ERROR ClusterBase::InvokeCommand(const RequestDataT & requestData, void * c VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); ReturnErrorOnFailure(mDevice->LoadSecureSessionParametersIfNeeded()); - auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const ResponseDataT & responseData) { - successCb(context, responseData); - }; + auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const app::StatusIB & aStatus, + const ResponseDataT & responseData) { successCb(context, responseData); }; - auto onFailureCb = [context, failureCb](Protocols::InteractionModel::Status aIMStatus, CHIP_ERROR aError) { - failureCb(context, app::ToEmberAfStatus(aIMStatus)); + auto onFailureCb = [context, failureCb](const app::StatusIB & aStatus, CHIP_ERROR aError) { + failureCb(context, app::ToEmberAfStatus(aStatus.mStatus)); }; return InvokeCommandRequest(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(), mEndpoint, diff --git a/zzz_generated/pump-controller-app/zap-generated/CHIPClusters.cpp b/zzz_generated/pump-controller-app/zap-generated/CHIPClusters.cpp index e4cb936c833b0c..c4c7eb956204e3 100644 --- a/zzz_generated/pump-controller-app/zap-generated/CHIPClusters.cpp +++ b/zzz_generated/pump-controller-app/zap-generated/CHIPClusters.cpp @@ -988,12 +988,11 @@ CHIP_ERROR ClusterBase::InvokeCommand(const RequestDataT & requestData, void * c VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); ReturnErrorOnFailure(mDevice->LoadSecureSessionParametersIfNeeded()); - auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const ResponseDataT & responseData) { - successCb(context, responseData); - }; + auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const app::StatusIB & aStatus, + const ResponseDataT & responseData) { successCb(context, responseData); }; - auto onFailureCb = [context, failureCb](Protocols::InteractionModel::Status aIMStatus, CHIP_ERROR aError) { - failureCb(context, app::ToEmberAfStatus(aIMStatus)); + auto onFailureCb = [context, failureCb](const app::StatusIB & aStatus, CHIP_ERROR aError) { + failureCb(context, app::ToEmberAfStatus(aStatus.mStatus)); }; return InvokeCommandRequest(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(), mEndpoint, diff --git a/zzz_generated/tv-app/zap-generated/CHIPClusters.cpp b/zzz_generated/tv-app/zap-generated/CHIPClusters.cpp index e653ac9c64179b..6469e16bbb1655 100644 --- a/zzz_generated/tv-app/zap-generated/CHIPClusters.cpp +++ b/zzz_generated/tv-app/zap-generated/CHIPClusters.cpp @@ -953,12 +953,11 @@ CHIP_ERROR ClusterBase::InvokeCommand(const RequestDataT & requestData, void * c VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); ReturnErrorOnFailure(mDevice->LoadSecureSessionParametersIfNeeded()); - auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const ResponseDataT & responseData) { - successCb(context, responseData); - }; + auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const app::StatusIB & aStatus, + const ResponseDataT & responseData) { successCb(context, responseData); }; - auto onFailureCb = [context, failureCb](Protocols::InteractionModel::Status aIMStatus, CHIP_ERROR aError) { - failureCb(context, app::ToEmberAfStatus(aIMStatus)); + auto onFailureCb = [context, failureCb](const app::StatusIB & aStatus, CHIP_ERROR aError) { + failureCb(context, app::ToEmberAfStatus(aStatus.mStatus)); }; return InvokeCommandRequest(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(), mEndpoint,