diff --git a/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp b/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp index 3860c772891b74..5ff6b6713d4ed3 100644 --- a/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp @@ -27,7 +27,7 @@ #include "CHIPDeviceManager.h" #include #include -#include +#include #include #include #include @@ -161,7 +161,7 @@ void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointI return; } -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::Command * commandObj) +bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) { emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); return true; diff --git a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp index edccd2b899e960..a32f077e21cfc0 100644 --- a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp @@ -35,7 +35,7 @@ #include "route_hook/esp_route_hook.h" #include #include -#include +#include #include #include #include @@ -254,7 +254,7 @@ void DeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpointI } #endif -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::Command * commandObj) +bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) { emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); return true; diff --git a/examples/all-clusters-app/linux/main.cpp b/examples/all-clusters-app/linux/main.cpp index 4c3048e3225a71..3c8d5faa5a8e39 100644 --- a/examples/all-clusters-app/linux/main.cpp +++ b/examples/all-clusters-app/linux/main.cpp @@ -16,13 +16,13 @@ * limitations under the License. */ -#include +#include #include #include #include "AppMain.h" -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::Command * commandObj) +bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) { emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); return true; diff --git a/examples/all-clusters-app/p6/src/ClusterManager.cpp b/examples/all-clusters-app/p6/src/ClusterManager.cpp index 9a0f2fcd8afbb8..4d550f8c4fdaf8 100644 --- a/examples/all-clusters-app/p6/src/ClusterManager.cpp +++ b/examples/all-clusters-app/p6/src/ClusterManager.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/examples/lighting-app/ameba/main/DeviceCallbacks.cpp b/examples/lighting-app/ameba/main/DeviceCallbacks.cpp index c51bfb33670e18..8f5e45b8dfc882 100755 --- a/examples/lighting-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/lighting-app/ameba/main/DeviceCallbacks.cpp @@ -27,7 +27,7 @@ #include "CHIPDeviceManager.h" #include #include -#include +#include #include #include #include diff --git a/examples/ota-provider-app/ota-provider-common/OTAProviderExample.h b/examples/ota-provider-app/ota-provider-common/OTAProviderExample.h index 64027d56420f52..3a7fdcf5c7e0c5 100644 --- a/examples/ota-provider-app/ota-provider-common/OTAProviderExample.h +++ b/examples/ota-provider-app/ota-provider-common/OTAProviderExample.h @@ -18,7 +18,7 @@ #pragma once -#include +#include #include /** diff --git a/examples/thermostat/linux/main.cpp b/examples/thermostat/linux/main.cpp index a5185b11d4f0d7..8ad5cb5033d1af 100644 --- a/examples/thermostat/linux/main.cpp +++ b/examples/thermostat/linux/main.cpp @@ -19,7 +19,7 @@ #include "AppMain.h" #include #include -#include +#include #include #include @@ -27,7 +27,7 @@ using namespace chip; using namespace chip::app; // using namespace chip::app::Clusters; -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::Command * commandObj) +bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) { emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); return true; diff --git a/examples/tv-app/android/include/account-login/AccountLoginManager.cpp b/examples/tv-app/android/include/account-login/AccountLoginManager.cpp index f599b71645b8cc..76975580ebc747 100644 --- a/examples/tv-app/android/include/account-login/AccountLoginManager.cpp +++ b/examples/tv-app/android/include/account-login/AccountLoginManager.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include using namespace std; diff --git a/examples/tv-app/android/include/application-basic/ApplicationBasicManager.cpp b/examples/tv-app/android/include/application-basic/ApplicationBasicManager.cpp index 6c6a1d7f9be7b4..5a1c21e4074268 100644 --- a/examples/tv-app/android/include/application-basic/ApplicationBasicManager.cpp +++ b/examples/tv-app/android/include/application-basic/ApplicationBasicManager.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/examples/tv-app/android/java/ContentLauncherManager.cpp b/examples/tv-app/android/java/ContentLauncherManager.cpp index c44a56e7160618..c84cbcc6a6fc75 100644 --- a/examples/tv-app/android/java/ContentLauncherManager.cpp +++ b/examples/tv-app/android/java/ContentLauncherManager.cpp @@ -25,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/examples/tv-app/linux/AppImpl.cpp b/examples/tv-app/linux/AppImpl.cpp index b652642fe1af13..6faf926dd77b17 100644 --- a/examples/tv-app/linux/AppImpl.cpp +++ b/examples/tv-app/linux/AppImpl.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/examples/tv-app/linux/include/account-login/AccountLoginManager.cpp b/examples/tv-app/linux/include/account-login/AccountLoginManager.cpp index f599b71645b8cc..76975580ebc747 100644 --- a/examples/tv-app/linux/include/account-login/AccountLoginManager.cpp +++ b/examples/tv-app/linux/include/account-login/AccountLoginManager.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include using namespace std; diff --git a/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp b/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp index 35c9f712ad4b67..0bdcc220c5dc84 100644 --- a/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp +++ b/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.cpp b/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.cpp index 7e670ddd2cd0cb..87ffd6d9a97410 100644 --- a/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.cpp +++ b/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include diff --git a/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.cpp b/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.cpp index 3146f0c3d79036..28dcf54a00c8c0 100644 --- a/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.cpp +++ b/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.cpp @@ -16,7 +16,7 @@ */ #include "MediaPlaybackManager.h" -#include +#include #include #include diff --git a/examples/tv-app/linux/main.cpp b/examples/tv-app/linux/main.cpp index 73433186f7a2b0..35ca1a8d5fabf2 100644 --- a/examples/tv-app/linux/main.cpp +++ b/examples/tv-app/linux/main.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -46,7 +46,7 @@ using namespace chip::Transport; using namespace chip::DeviceLayer; using namespace chip::AppPlatform; -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::Command * commandObj) +bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) { emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); return true; diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index 60ff26ea660c86..f159ae54470ce4 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -45,8 +45,6 @@ static_library("app") { "CASEClientPool.h", "CASESessionManager.cpp", "CASESessionManager.h", - "Command.cpp", - "Command.h", "CommandHandler.cpp", "CommandSender.cpp", "DeviceProxy.cpp", diff --git a/src/app/Command.cpp b/src/app/Command.cpp deleted file mode 100644 index b73c074c6ac8a2..00000000000000 --- a/src/app/Command.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * - * Copyright (c) 2020-2021 Project CHIP Authors - * All rights reserved. - * - * 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. - */ - -/** - * @file - * This file defines Base class for a CHIP IM Command - * - */ - -#include "Command.h" -#include -#include - -namespace chip { -namespace app { - -Command::Command() {} - -CHIP_ERROR Command::Finalize(System::PacketBufferHandle & commandPacket) -{ - VerifyOrReturnError(mState == CommandState::AddedCommand, CHIP_ERROR_INCORRECT_STATE); - return mCommandMessageWriter.Finalize(&commandPacket); -} - -void Command::Abort() -{ - // - // If the exchange context hasn't already been gracefully closed - // (signaled by setting it to null), then we need to forcibly - // tear it down. - // - if (mpExchangeCtx != nullptr) - { - // We (or more precisely our subclass) might be a delegate for this - // exchange, and we don't want the OnExchangeClosing notification in - // that case. Null out the delegate to avoid that. - // - // TODO: This makes all sorts of assumptions about what the delegate is - // (notice the "might" above!) that might not hold in practice. We - // really need a better solution here.... - mpExchangeCtx->SetDelegate(nullptr); - mpExchangeCtx->Abort(); - mpExchangeCtx = nullptr; - } -} - -void Command::Close() -{ - // - // Shortly after this call to close and when handling an inbound message, it's entirely possible - // for this object (courtesy of its derived class) to be destroyed - // *before* the call unwinds all the way back to ExchangeContext::HandleMessage. - // - // As part of tearing down the exchange, there is logic there to invoke the delegate to notify - // it of impending closure - which is this object, which just got destroyed! - // - // So prevent a use-after-free, set delegate to null. - // - // For more details, see #10344. - // - if (mpExchangeCtx != nullptr) - { - mpExchangeCtx->SetDelegate(nullptr); - } - - mpExchangeCtx = nullptr; -} - -const char * Command::GetStateStr() const -{ -#if CHIP_DETAIL_LOGGING - switch (mState) - { - case CommandState::Idle: - return "Idle"; - - case CommandState::AddingCommand: - return "AddingCommand"; - - case CommandState::AddedCommand: - return "AddedCommand"; - - case CommandState::AwaitingTimedStatus: - return "AwaitingTimedStatus"; - - case CommandState::CommandSent: - return "CommandSent"; - - case CommandState::ResponseReceived: - return "ResponseReceived"; - - case CommandState::AwaitingDestruction: - return "AwaitingDestruction"; - } -#endif // CHIP_DETAIL_LOGGING - return "N/A"; -} - -void Command::MoveToState(const CommandState aTargetState) -{ - mState = aTargetState; - ChipLogDetail(DataManagement, "ICR moving to [%10.10s]", GetStateStr()); -} - -} // namespace app -} // namespace chip diff --git a/src/app/Command.h b/src/app/Command.h deleted file mode 100644 index 9fbeff757fcc4a..00000000000000 --- a/src/app/Command.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * - * Copyright (c) 2020-2021 Project CHIP Authors - * All rights reserved. - * - * 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. - */ - -/** - * @file - * This file defines Base class for a CHIP IM Command - * - */ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace chip { -namespace app { - -class Command -{ -public: - enum class CommandState - { - Idle, ///< Default state that the object starts out in, where no work has commenced - AddingCommand, ///< In the process of adding a command. - AddedCommand, ///< A command has been completely encoded and is awaiting transmission. - AwaitingTimedStatus, ///< Sent a Timed Request and waiting for response. - CommandSent, ///< The command has been sent successfully. - ResponseReceived, ///< Received a response to our invoke and request and processing the response. - AwaitingDestruction, ///< The object has completed its work and is awaiting destruction by the application. - }; - - /* - * Destructor - as part of destruction, it will abort the exchange context - * if a valid one still exists. - * - * See Abort() for details on when that might occur. - */ - virtual ~Command() { Abort(); } - - CHIP_ERROR Finalize(System::PacketBufferHandle & commandPacket); - - virtual CHIP_ERROR AddStatus(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus) - { - return CHIP_ERROR_NOT_IMPLEMENTED; - } - - virtual CHIP_ERROR AddClusterSpecificSuccess(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus) - { - return CHIP_ERROR_NOT_IMPLEMENTED; - } - - virtual CHIP_ERROR AddClusterSpecificFailure(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus) - { - return CHIP_ERROR_NOT_IMPLEMENTED; - } - - /** - * Gets the inner exchange context object, without ownership. - * - * @return The inner exchange context, might be nullptr if no - * exchange context has been assigned or the context - * has been released. - */ - Messaging::ExchangeContext * GetExchangeContext() const { return mpExchangeCtx; } - -protected: - Command(); - - /* - * The actual closure of the exchange happens automatically in the exchange layer. - * This function just sets the internally tracked exchange pointer to null to align - * with the exchange layer so as to prevent further closure if Abort() is called later. - */ - void Close(); - - void MoveToState(const CommandState aTargetState); - const char * GetStateStr() const; - - Messaging::ExchangeContext * mpExchangeCtx = nullptr; - uint8_t mCommandIndex = 0; - CommandState mState = CommandState::Idle; - chip::System::PacketBufferTLVWriter mCommandMessageWriter; - bool mBufferAllocated = false; - -private: - /* - * This forcibly closes the exchange context if a valid one is pointed to. Such a situation does - * not arise during normal message processing flows that all normally call Close() above. This can only - * arise due to application-initiated destruction of the object when this object is handling receiving/sending - * message payloads. - */ - void Abort(); - - friend class TestCommandInteraction; -}; -} // namespace app -} // namespace chip diff --git a/src/app/CommandHandler.cpp b/src/app/CommandHandler.cpp index 913969adec9e1a..5ed3abd1f74a7e 100644 --- a/src/app/CommandHandler.cpp +++ b/src/app/CommandHandler.cpp @@ -23,8 +23,6 @@ */ #include "CommandHandler.h" -#include "Command.h" -#include "CommandSender.h" #include "InteractionModelEngine.h" #include "messaging/ExchangeContext.h" @@ -54,8 +52,6 @@ CHIP_ERROR CommandHandler::AllocateBuffer() mInvokeResponseBuilder.CreateInvokeResponses(); ReturnErrorOnFailure(mInvokeResponseBuilder.GetError()); - - mCommandIndex = 0; mBufferAllocated = true; } @@ -66,7 +62,7 @@ CHIP_ERROR CommandHandler::OnInvokeCommandRequest(Messaging::ExchangeContext * e System::PacketBufferHandle && payload, bool isTimedInvoke) { System::PacketBufferHandle response; - VerifyOrReturnError(mState == CommandState::Idle, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(mState == State::Idle, CHIP_ERROR_INCORRECT_STATE); // NOTE: we already know this is an InvokeCommand Request message because we explicitly registered with the // Exchange Manager for unsolicited InvokeCommand Requests. @@ -144,7 +140,7 @@ CHIP_ERROR CommandHandler::ProcessInvokeRequest(System::PacketBufferHandle && pa void CommandHandler::Close() { mSuppressResponse = false; - MoveToState(CommandState::AwaitingDestruction); + MoveToState(State::AwaitingDestruction); // We must finish all async work before we can shut down a CommandHandler. The actual CommandHandler MUST finish their work // in reasonable time or there is a bug. The only case for releasing CommandHandler without CommandHandler::Handle releasing its @@ -152,7 +148,24 @@ void CommandHandler::Close() VerifyOrDieWithMsg(mPendingWork == 0, DataManagement, "CommandHandler::Close() called with %zu unfinished async work items", mPendingWork); - Command::Close(); + // + // Shortly after this call to close and when handling an inbound message, it's entirely possible + // for this object (courtesy of its derived class) to be destroyed + // *before* the call unwinds all the way back to ExchangeContext::HandleMessage. + // + // As part of tearing down the exchange, there is logic there to invoke the delegate to notify + // it of impending closure - which is this object, which just got destroyed! + // + // So prevent a use-after-free, set delegate to null. + // + // For more details, see #10344. + // + if (mpExchangeCtx != nullptr) + { + mpExchangeCtx->SetDelegate(nullptr); + } + + mpExchangeCtx = nullptr; if (mpCallback) { @@ -197,7 +210,7 @@ CHIP_ERROR CommandHandler::SendCommandResponse() System::PacketBufferHandle commandPacket; VerifyOrReturnError(mPendingWork == 0, CHIP_ERROR_INCORRECT_STATE); - VerifyOrReturnError(mState == CommandState::AddedCommand, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(mState == State::AddedCommand, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(mpExchangeCtx != nullptr, CHIP_ERROR_INCORRECT_STATE); ReturnErrorOnFailure(Finalize(commandPacket)); @@ -206,7 +219,7 @@ CHIP_ERROR CommandHandler::SendCommandResponse() // The ExchangeContext is automatically freed here, and it makes mpExchangeCtx be temporarily dangling, but in // all cases, we are going to call Close immediately after this function, which nulls out mpExchangeCtx. - MoveToState(CommandState::CommandSent); + MoveToState(State::CommandSent); return CHIP_NO_ERROR; } @@ -332,7 +345,7 @@ CHIP_ERROR CommandHandler::PrepareCommand(const ConcreteCommandPath & aCommandPa // // We must not be in the middle of preparing a command, or having prepared or sent one. // - VerifyOrReturnError(mState == CommandState::Idle, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(mState == State::Idle, CHIP_ERROR_INCORRECT_STATE); InvokeResponseIBs::Builder & invokeResponses = mInvokeResponseBuilder.GetInvokeResponses(); InvokeResponseIB::Builder & invokeResponse = invokeResponses.CreateInvokeResponse(); ReturnErrorOnFailure(invokeResponses.GetError()); @@ -347,14 +360,14 @@ CHIP_ERROR CommandHandler::PrepareCommand(const ConcreteCommandPath & aCommandPa ReturnErrorOnFailure(commandData.GetWriter()->StartContainer(TLV::ContextTag(to_underlying(CommandDataIB::Tag::kData)), TLV::kTLVType_Structure, mDataElementContainerType)); } - MoveToState(CommandState::AddingCommand); + MoveToState(State::AddingCommand); return CHIP_NO_ERROR; } CHIP_ERROR CommandHandler::FinishCommand(bool aStartDataStruct) { - VerifyOrReturnError(mState == CommandState::AddingCommand, CHIP_ERROR_INCORRECT_STATE); - CommandDataIB::Builder commandData = mInvokeResponseBuilder.GetInvokeResponses().GetInvokeResponse().GetCommand(); + VerifyOrReturnError(mState == State::AddingCommand, CHIP_ERROR_INCORRECT_STATE); + CommandDataIB::Builder & commandData = mInvokeResponseBuilder.GetInvokeResponses().GetInvokeResponse().GetCommand(); if (aStartDataStruct) { ReturnErrorOnFailure(commandData.GetWriter()->EndContainer(mDataElementContainerType)); @@ -363,7 +376,7 @@ CHIP_ERROR CommandHandler::FinishCommand(bool aStartDataStruct) ReturnErrorOnFailure(mInvokeResponseBuilder.GetInvokeResponses().GetInvokeResponse().EndOfInvokeResponseIB().GetError()); ReturnErrorOnFailure(mInvokeResponseBuilder.GetInvokeResponses().EndOfInvokeResponses().GetError()); ReturnErrorOnFailure(mInvokeResponseBuilder.EndOfInvokeResponseMessage().GetError()); - MoveToState(CommandState::AddedCommand); + MoveToState(State::AddedCommand); return CHIP_NO_ERROR; } @@ -373,7 +386,7 @@ CHIP_ERROR CommandHandler::PrepareStatus(const ConcreteCommandPath & aCommandPat // // We must not be in the middle of preparing a command, or having prepared or sent one. // - VerifyOrReturnError(mState == CommandState::Idle, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(mState == State::Idle, CHIP_ERROR_INCORRECT_STATE); InvokeResponseIBs::Builder & invokeResponses = mInvokeResponseBuilder.GetInvokeResponses(); InvokeResponseIB::Builder & invokeResponse = invokeResponses.CreateInvokeResponse(); ReturnErrorOnFailure(invokeResponses.GetError()); @@ -382,25 +395,25 @@ CHIP_ERROR CommandHandler::PrepareStatus(const ConcreteCommandPath & aCommandPat CommandPathIB::Builder & path = commandStatus.CreatePath(); ReturnErrorOnFailure(commandStatus.GetError()); ReturnErrorOnFailure(path.Encode(aCommandPath)); - MoveToState(CommandState::AddingCommand); + MoveToState(State::AddingCommand); return CHIP_NO_ERROR; } CHIP_ERROR CommandHandler::FinishStatus() { - VerifyOrReturnError(mState == CommandState::AddingCommand, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(mState == State::AddingCommand, CHIP_ERROR_INCORRECT_STATE); ReturnErrorOnFailure( mInvokeResponseBuilder.GetInvokeResponses().GetInvokeResponse().GetStatus().EndOfCommandStatusIB().GetError()); ReturnErrorOnFailure(mInvokeResponseBuilder.GetInvokeResponses().GetInvokeResponse().EndOfInvokeResponseIB().GetError()); ReturnErrorOnFailure(mInvokeResponseBuilder.GetInvokeResponses().EndOfInvokeResponses().GetError()); ReturnErrorOnFailure(mInvokeResponseBuilder.EndOfInvokeResponseMessage().GetError()); - MoveToState(CommandState::AddedCommand); + MoveToState(State::AddedCommand); return CHIP_NO_ERROR; } TLV::TLVWriter * CommandHandler::GetCommandDataIBTLVWriter() { - if (mState != CommandState::AddingCommand) + if (mState != State::AddingCommand) { return nullptr; } @@ -443,6 +456,66 @@ CommandHandler::Handle::Handle(CommandHandler * handle) } } +CHIP_ERROR CommandHandler::Finalize(System::PacketBufferHandle & commandPacket) +{ + VerifyOrReturnError(mState == State::AddedCommand, CHIP_ERROR_INCORRECT_STATE); + return mCommandMessageWriter.Finalize(&commandPacket); +} + +const char * CommandHandler::GetStateStr() const +{ +#if CHIP_DETAIL_LOGGING + switch (mState) + { + case State::Idle: + return "Idle"; + + case State::AddingCommand: + return "AddingCommand"; + + case State::AddedCommand: + return "AddedCommand"; + + case State::AwaitingTimedStatus: + return "AwaitingTimedStatus"; + + case State::CommandSent: + return "CommandSent"; + + case State::AwaitingDestruction: + return "AwaitingDestruction"; + } +#endif // CHIP_DETAIL_LOGGING + return "N/A"; +} + +void CommandHandler::MoveToState(const State aTargetState) +{ + mState = aTargetState; + ChipLogDetail(DataManagement, "ICR moving to [%10.10s]", GetStateStr()); +} + +void CommandHandler::Abort() +{ + // + // If the exchange context hasn't already been gracefully closed + // (signaled by setting it to null), then we need to forcibly + // tear it down. + // + if (mpExchangeCtx != nullptr) + { + // We (or more precisely our subclass) might be a delegate for this + // exchange, and we don't want the OnExchangeClosing notification in + // that case. Null out the delegate to avoid that. + // + // TODO: This makes all sorts of assumptions about what the delegate is + // (notice the "might" above!) that might not hold in practice. We + // really need a better solution here.... + mpExchangeCtx->SetDelegate(nullptr); + mpExchangeCtx->Abort(); + mpExchangeCtx = nullptr; + } +} } // namespace app } // namespace chip diff --git a/src/app/CommandHandler.h b/src/app/CommandHandler.h index 97bb39b3fffa62..6cc3ff194e8ce6 100644 --- a/src/app/CommandHandler.h +++ b/src/app/CommandHandler.h @@ -24,12 +24,13 @@ #pragma once -#include #include +#include #include #include #include #include +#include #include #include #include @@ -37,6 +38,7 @@ #include #include #include +#include #include #include @@ -44,9 +46,16 @@ namespace chip { namespace app { -class CommandHandler : public Command +class CommandHandler { public: + /* + * Destructor - as part of destruction, it will abort the exchange context + * if a valid one still exists. + * + * See Abort() for details on when that might occur. + */ + virtual ~CommandHandler() { Abort(); } class Callback { public: @@ -135,11 +144,11 @@ class CommandHandler : public Command */ CHIP_ERROR OnInvokeCommandRequest(Messaging::ExchangeContext * ec, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload, bool isTimedInvoke); - CHIP_ERROR AddStatus(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus) override; + CHIP_ERROR AddStatus(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus); - CHIP_ERROR AddClusterSpecificSuccess(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus) override; + CHIP_ERROR AddClusterSpecificSuccess(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus); - CHIP_ERROR AddClusterSpecificFailure(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus) override; + CHIP_ERROR AddClusterSpecificFailure(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus); CHIP_ERROR ProcessInvokeRequest(System::PacketBufferHandle && payload, bool isTimedInvoke); CHIP_ERROR PrepareCommand(const ConcreteCommandPath & aCommandPath, bool aStartDataStruct = true); @@ -176,10 +185,50 @@ class CommandHandler : public Command */ bool IsTimedInvoke() const { return mTimedRequest; } + enum class CommandState + { + Idle, ///< Default state that the object starts out in, where no work has commenced + AddingCommand, ///< In the process of adding a command. + AddedCommand, ///< A command has been completely encoded and is awaiting transmission. + AwaitingTimedStatus, ///< Sent a Timed Request and waiting for response. + CommandSent, ///< The command has been sent successfully. + ResponseReceived, ///< Received a response to our invoke and request and processing the response. + AwaitingDestruction, ///< The object has completed its work and is awaiting destruction by the application. + }; + + /* + * This forcibly closes the exchange context if a valid one is pointed to. Such a situation does + * not arise during normal message processing flows that all normally call Close() above. This can only + * arise due to application-initiated destruction of the object when this object is handling receiving/sending + * message payloads. + */ + void Abort(); + + /** + * Gets the inner exchange context object, without ownership. + * + * @return The inner exchange context, might be nullptr if no + * exchange context has been assigned or the context + * has been released. + */ + Messaging::ExchangeContext * GetExchangeContext() const { return mpExchangeCtx; } + private: friend class TestCommandInteraction; friend class CommandHandler::Handle; + enum class State + { + Idle, ///< Default state that the object starts out in, where no work has commenced + AddingCommand, ///< In the process of adding a command. + AddedCommand, ///< A command has been completely encoded and is awaiting transmission. + AwaitingTimedStatus, ///< Sent a Timed Request and waiting for response. + CommandSent, ///< The command has been sent successfully. + AwaitingDestruction, ///< The object has completed its work and is awaiting destruction by the application. + }; + + void MoveToState(const State aTargetState); + const char * GetStateStr() const; /** * IncrementHoldOff will increase the inner refcount of the CommandHandler. * @@ -202,6 +251,8 @@ class CommandHandler : public Command */ CHIP_ERROR AllocateBuffer(); + CHIP_ERROR Finalize(System::PacketBufferHandle & commandPacket); + /** * Called internally to signal the completion of all work on this object, gracefully close the * exchange (by calling into the base class) and finally, signal to a registerd callback that it's @@ -214,12 +265,17 @@ class CommandHandler : public Command CHIP_ERROR AddStatusInternal(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus, const Optional & aClusterStatus); - Callback * mpCallback = nullptr; + Messaging::ExchangeContext * mpExchangeCtx = nullptr; + Callback * mpCallback = nullptr; InvokeResponseMessage::Builder mInvokeResponseBuilder; TLV::TLVType mDataElementContainerType = TLV::kTLVType_NotSpecified; size_t mPendingWork = 0; bool mSuppressResponse = false; bool mTimedRequest = false; + + State mState = State::Idle; + chip::System::PacketBufferTLVWriter mCommandMessageWriter; + bool mBufferAllocated = false; }; } // namespace app diff --git a/src/app/CommandSender.cpp b/src/app/CommandSender.cpp index 49afe08e0a8fe2..ca8ab54035ebe7 100644 --- a/src/app/CommandSender.cpp +++ b/src/app/CommandSender.cpp @@ -23,8 +23,6 @@ */ #include "CommandSender.h" -#include "Command.h" -#include "CommandHandler.h" #include "InteractionModelEngine.h" #include "StatusResponse.h" #include @@ -56,7 +54,6 @@ CHIP_ERROR CommandSender::AllocateBuffer() mInvokeRequestBuilder.CreateInvokeRequests(); ReturnErrorOnFailure(mInvokeRequestBuilder.GetError()); - mCommandIndex = 0; mBufferAllocated = true; } @@ -65,7 +62,7 @@ CHIP_ERROR CommandSender::AllocateBuffer() CHIP_ERROR CommandSender::SendCommandRequest(SessionHandle session, System::Clock::Timeout timeout) { - VerifyOrReturnError(mState == CommandState::AddedCommand, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(mState == State::AddedCommand, CHIP_ERROR_INCORRECT_STATE); ReturnErrorOnFailure(Finalize(mPendingInvokeData)); @@ -78,7 +75,7 @@ CHIP_ERROR CommandSender::SendCommandRequest(SessionHandle session, System::Cloc if (mTimedInvokeTimeoutMs.HasValue()) { ReturnErrorOnFailure(TimedRequest::Send(mpExchangeCtx, mTimedInvokeTimeoutMs.Value())); - MoveToState(CommandState::AwaitingTimedStatus); + MoveToState(State::AwaitingTimedStatus); return CHIP_NO_ERROR; } @@ -92,7 +89,7 @@ CHIP_ERROR CommandSender::SendInvokeRequest() ReturnErrorOnFailure(mpExchangeCtx->SendMessage(MsgType::InvokeCommandRequest, std::move(mPendingInvokeData), SendMessageFlags::kExpectResponse)); - MoveToState(CommandState::CommandSent); + MoveToState(State::CommandSent); return CHIP_NO_ERROR; } @@ -100,16 +97,16 @@ CHIP_ERROR CommandSender::SendInvokeRequest() CHIP_ERROR CommandSender::OnMessageReceived(Messaging::ExchangeContext * apExchangeContext, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload) { - if (mState == CommandState::CommandSent) + if (mState == State::CommandSent) { - MoveToState(CommandState::ResponseReceived); + MoveToState(State::ResponseReceived); } CHIP_ERROR err = CHIP_NO_ERROR; StatusIB status(Protocols::InteractionModel::Status::Failure); VerifyOrExit(apExchangeContext == mpExchangeCtx, err = CHIP_ERROR_INCORRECT_STATE); - if (mState == CommandState::AwaitingTimedStatus) + if (mState == State::AwaitingTimedStatus) { err = HandleTimedStatus(aPayloadHeader, std::move(aPayload), status); // Skip all other processing here (which is for the response to the @@ -142,7 +139,7 @@ CHIP_ERROR CommandSender::OnMessageReceived(Messaging::ExchangeContext * apExcha } } - if (mState != CommandState::CommandSent) + if (mState != State::CommandSent) { Close(); } @@ -207,9 +204,26 @@ void CommandSender::Close() { mSuppressResponse = false; mTimedRequest = false; - MoveToState(CommandState::AwaitingDestruction); + MoveToState(State::AwaitingDestruction); - Command::Close(); + // + // Shortly after this call to close and when handling an inbound message, it's entirely possible + // for this object (courtesy of its derived class) to be destroyed + // *before* the call unwinds all the way back to ExchangeContext::HandleMessage. + // + // As part of tearing down the exchange, there is logic there to invoke the delegate to notify + // it of impending closure - which is this object, which just got destroyed! + // + // So prevent a use-after-free, set delegate to null. + // + // For more details, see #10344. + // + if (mpExchangeCtx != nullptr) + { + mpExchangeCtx->SetDelegate(nullptr); + } + + mpExchangeCtx = nullptr; if (mpCallback) { @@ -305,7 +319,7 @@ CHIP_ERROR CommandSender::PrepareCommand(const CommandPathParams & aCommandPathP // // We must not be in the middle of preparing a command, or having prepared or sent one. // - VerifyOrReturnError(mState == CommandState::Idle, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(mState == State::Idle, CHIP_ERROR_INCORRECT_STATE); InvokeRequests::Builder & invokeRequests = mInvokeRequestBuilder.GetInvokeRequests(); CommandDataIB::Builder & invokeRequest = invokeRequests.CreateCommandData(); ReturnErrorOnFailure(invokeRequests.GetError()); @@ -319,7 +333,7 @@ CHIP_ERROR CommandSender::PrepareCommand(const CommandPathParams & aCommandPathP TLV::kTLVType_Structure, mDataElementContainerType)); } - MoveToState(CommandState::AddingCommand); + MoveToState(State::AddingCommand); return CHIP_NO_ERROR; } @@ -327,9 +341,9 @@ CHIP_ERROR CommandSender::FinishCommand(bool aEndDataStruct) { CHIP_ERROR err = CHIP_NO_ERROR; - VerifyOrReturnError(mState == CommandState::AddingCommand, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(mState == State::AddingCommand, err = CHIP_ERROR_INCORRECT_STATE); - CommandDataIB::Builder commandData = mInvokeRequestBuilder.GetInvokeRequests().GetCommandData(); + CommandDataIB::Builder & commandData = mInvokeRequestBuilder.GetInvokeRequests().GetCommandData(); if (aEndDataStruct) { @@ -340,14 +354,14 @@ CHIP_ERROR CommandSender::FinishCommand(bool aEndDataStruct) ReturnErrorOnFailure(mInvokeRequestBuilder.GetInvokeRequests().EndOfInvokeRequests().GetError()); ReturnErrorOnFailure(mInvokeRequestBuilder.EndOfInvokeRequestMessage().GetError()); - MoveToState(CommandState::AddedCommand); + MoveToState(State::AddedCommand); return CHIP_NO_ERROR; } TLV::TLVWriter * CommandSender::GetCommandDataIBTLVWriter() { - if (mState != CommandState::AddingCommand) + if (mState != State::AddingCommand) { return nullptr; } @@ -380,5 +394,69 @@ CHIP_ERROR CommandSender::FinishCommand(const Optional & aTimedInvokeT return CHIP_NO_ERROR; } +CHIP_ERROR CommandSender::Finalize(System::PacketBufferHandle & commandPacket) +{ + VerifyOrReturnError(mState == State::AddedCommand, CHIP_ERROR_INCORRECT_STATE); + return mCommandMessageWriter.Finalize(&commandPacket); +} + +const char * CommandSender::GetStateStr() const +{ +#if CHIP_DETAIL_LOGGING + switch (mState) + { + case State::Idle: + return "Idle"; + + case State::AddingCommand: + return "AddingCommand"; + + case State::AddedCommand: + return "AddedCommand"; + + case State::AwaitingTimedStatus: + return "AwaitingTimedStatus"; + + case State::CommandSent: + return "CommandSent"; + + case State::ResponseReceived: + return "ResponseReceived"; + + case State::AwaitingDestruction: + return "AwaitingDestruction"; + } +#endif // CHIP_DETAIL_LOGGING + return "N/A"; +} + +void CommandSender::MoveToState(const State aTargetState) +{ + mState = aTargetState; + ChipLogDetail(DataManagement, "ICR moving to [%10.10s]", GetStateStr()); +} + +void CommandSender::Abort() +{ + // + // If the exchange context hasn't already been gracefully closed + // (signaled by setting it to null), then we need to forcibly + // tear it down. + // + if (mpExchangeCtx != nullptr) + { + // We (or more precisely our subclass) might be a delegate for this + // exchange, and we don't want the OnExchangeClosing notification in + // that case. Null out the delegate to avoid that. + // + // TODO: This makes all sorts of assumptions about what the delegate is + // (notice the "might" above!) that might not hold in practice. We + // really need a better solution here.... + mpExchangeCtx->SetDelegate(nullptr); + mpExchangeCtx->Abort(); + mpExchangeCtx = nullptr; + } +} + } // namespace app } // namespace chip diff --git a/src/app/CommandSender.h b/src/app/CommandSender.h index 1ed1c7a9cfa05f..496e1c28cd98b3 100644 --- a/src/app/CommandSender.h +++ b/src/app/CommandSender.h @@ -26,11 +26,16 @@ #include +#include +#include +#include +#include #include #include #include #include #include +#include #include #include #include @@ -39,19 +44,33 @@ #include #include #include - -#include -#include -#include +#include #define COMMON_STATUS_SUCCESS 0 namespace chip { namespace app { -class CommandSender final : public Command, public Messaging::ExchangeDelegate +class CommandSender final : public Messaging::ExchangeDelegate { public: + /* + * Destructor - as part of destruction, it will abort the exchange context + * if a valid one still exists. + * + * See Abort() for details on when that might occur. + */ + virtual ~CommandSender() { Abort(); } + + /** + * Gets the inner exchange context object, without ownership. + * + * @return The inner exchange context, might be nullptr if no + * exchange context has been assigned or the context + * has been released. + */ + Messaging::ExchangeContext * GetExchangeContext() const { return mpExchangeCtx; } + class Callback { public: @@ -199,6 +218,20 @@ class CommandSender final : public Command, public Messaging::ExchangeDelegate private: friend class TestCommandInteraction; + enum class State + { + Idle, ///< Default state that the object starts out in, where no work has commenced + AddingCommand, ///< In the process of adding a command. + AddedCommand, ///< A command has been completely encoded and is awaiting transmission. + AwaitingTimedStatus, ///< Sent a Timed Request and waiting for response. + CommandSent, ///< The command has been sent successfully. + ResponseReceived, ///< Received a response to our invoke and request and processing the response. + AwaitingDestruction, ///< The object has completed its work and is awaiting destruction by the application. + }; + + void MoveToState(const State aTargetState); + const char * GetStateStr() const; + /* * Allocates a packet buffer used for encoding an invoke request payload. * @@ -221,6 +254,14 @@ class CommandSender final : public Command, public Messaging::ExchangeDelegate // void Close(); + /* + * This forcibly closes the exchange context if a valid one is pointed to. Such a situation does + * not arise during normal message processing flows that all normally call Close() above. This can only + * arise due to application-initiated destruction of the object when this object is handling receiving/sending + * message payloads. + */ + void Abort(); + CHIP_ERROR ProcessInvokeResponse(System::PacketBufferHandle && payload); CHIP_ERROR ProcessInvokeResponseIB(InvokeResponseIB::Parser & aInvokeResponse); @@ -239,6 +280,9 @@ class CommandSender final : public Command, public Messaging::ExchangeDelegate CHIP_ERROR FinishCommand(const Optional & aTimedInvokeTimeoutMs); + CHIP_ERROR Finalize(System::PacketBufferHandle & commandPacket); + + Messaging::ExchangeContext * mpExchangeCtx = nullptr; Callback * mpCallback = nullptr; Messaging::ExchangeManager * mpExchangeMgr = nullptr; InvokeRequestMessage::Builder mInvokeRequestBuilder; @@ -252,6 +296,10 @@ class CommandSender final : public Command, public Messaging::ExchangeDelegate TLV::TLVType mDataElementContainerType = TLV::kTLVType_NotSpecified; bool mSuppressResponse = false; bool mTimedRequest = false; + + State mState = State::Idle; + chip::System::PacketBufferTLVWriter mCommandMessageWriter; + bool mBufferAllocated = false; }; } // namespace app diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index 471ac33b2b115b..9e7110240f8c08 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -24,9 +24,6 @@ */ #include "InteractionModelEngine.h" -#include "Command.h" -#include "CommandHandler.h" -#include "CommandSender.h" #include namespace chip { diff --git a/src/app/MessageDef/Builder.h b/src/app/MessageDef/Builder.h index 1ffbb3e78afdcf..4b0ae96b203c25 100644 --- a/src/app/MessageDef/Builder.h +++ b/src/app/MessageDef/Builder.h @@ -87,6 +87,8 @@ class Builder void EndOfContainer(); + Builder(Builder &) = delete; + protected: CHIP_ERROR mError; chip::TLV::TLVWriter * mpWriter; diff --git a/src/app/MessageDef/EventDataIB.cpp b/src/app/MessageDef/EventDataIB.cpp index 8e553eeb12654f..b810c4f34249ed 100644 --- a/src/app/MessageDef/EventDataIB.cpp +++ b/src/app/MessageDef/EventDataIB.cpp @@ -485,7 +485,7 @@ EventPathIB::Builder & EventDataIB::Builder::CreatePath() return mPath; } -EventDataIB::Builder EventDataIB::Builder::Priority(const uint8_t aPriority) +EventDataIB::Builder & EventDataIB::Builder::Priority(const uint8_t aPriority) { // skip if error has already been set if (mError == CHIP_NO_ERROR) @@ -495,7 +495,7 @@ EventDataIB::Builder EventDataIB::Builder::Priority(const uint8_t aPriority) return *this; } -EventDataIB::Builder EventDataIB::Builder::EventNumber(const uint64_t aEventNumber) +EventDataIB::Builder & EventDataIB::Builder::EventNumber(const uint64_t aEventNumber) { // skip if error has already been set if (mError == CHIP_NO_ERROR) @@ -505,7 +505,7 @@ EventDataIB::Builder EventDataIB::Builder::EventNumber(const uint64_t aEventNumb return *this; } -EventDataIB::Builder EventDataIB::Builder::EpochTimestamp(const uint64_t aEpochTimestamp) +EventDataIB::Builder & EventDataIB::Builder::EpochTimestamp(const uint64_t aEpochTimestamp) { // skip if error has already been set if (mError == CHIP_NO_ERROR) @@ -515,7 +515,7 @@ EventDataIB::Builder EventDataIB::Builder::EpochTimestamp(const uint64_t aEpochT return *this; } -EventDataIB::Builder EventDataIB::Builder::SystemTimestamp(const uint64_t aSystemTimestamp) +EventDataIB::Builder & EventDataIB::Builder::SystemTimestamp(const uint64_t aSystemTimestamp) { // skip if error has already been set if (mError == CHIP_NO_ERROR) @@ -525,7 +525,7 @@ EventDataIB::Builder EventDataIB::Builder::SystemTimestamp(const uint64_t aSyste return *this; } -EventDataIB::Builder EventDataIB::Builder::DeltaEpochTimestamp(const uint64_t aDeltaEpochTimestamp) +EventDataIB::Builder & EventDataIB::Builder::DeltaEpochTimestamp(const uint64_t aDeltaEpochTimestamp) { // skip if error has already been set if (mError == CHIP_NO_ERROR) @@ -535,7 +535,7 @@ EventDataIB::Builder EventDataIB::Builder::DeltaEpochTimestamp(const uint64_t aD return *this; } -EventDataIB::Builder EventDataIB::Builder::DeltaSystemTimestamp(const uint64_t aDeltaSystemTimestamp) +EventDataIB::Builder & EventDataIB::Builder::DeltaSystemTimestamp(const uint64_t aDeltaSystemTimestamp) { // skip if error has already been set if (mError == CHIP_NO_ERROR) diff --git a/src/app/MessageDef/EventDataIB.h b/src/app/MessageDef/EventDataIB.h index 0e0f662becbeab..4e52d7d2474cc8 100644 --- a/src/app/MessageDef/EventDataIB.h +++ b/src/app/MessageDef/EventDataIB.h @@ -185,7 +185,7 @@ class Builder : public StructBuilder * * @return A reference to *this */ - EventDataIB::Builder Priority(const uint8_t aPriority); + EventDataIB::Builder & Priority(const uint8_t aPriority); /** * @brief Inject Number into the TLV stream to indicate the number associated with @@ -196,7 +196,7 @@ class Builder : public StructBuilder * * @return A reference to *this */ - EventDataIB::Builder EventNumber(const EventNumber aEventNumber); + EventDataIB::Builder & EventNumber(const EventNumber aEventNumber); /** * @brief Inject EpochTimestamp into the TLV stream. @@ -206,7 +206,7 @@ class Builder : public StructBuilder * * @return A reference to *this */ - EventDataIB::Builder EpochTimestamp(const uint64_t aEpochTimestamp); + EventDataIB::Builder & EpochTimestamp(const uint64_t aEpochTimestamp); /** * @brief Inject SystemTimestamp into the TLV stream. If Epoch time is not available, time since boot @@ -216,7 +216,7 @@ class Builder : public StructBuilder * * @return A reference to *this */ - EventDataIB::Builder SystemTimestamp(const uint64_t aSystemTimestamp); + EventDataIB::Builder & SystemTimestamp(const uint64_t aSystemTimestamp); /** * @brief Inject DeltaEpochTimestamp into the TLV stream. @@ -227,7 +227,7 @@ class Builder : public StructBuilder * * @return A reference to *this */ - EventDataIB::Builder DeltaEpochTimestamp(const uint64_t aDeltaEpochTimestamp); + EventDataIB::Builder & DeltaEpochTimestamp(const uint64_t aDeltaEpochTimestamp); /** * @brief Inject DeltaSystemTimestamp into the TLV stream. @@ -238,7 +238,7 @@ class Builder : public StructBuilder * * @return A reference to *this */ - EventDataIB::Builder DeltaSystemTimestamp(const uint64_t aDeltaSystemTimestamp); + EventDataIB::Builder & DeltaSystemTimestamp(const uint64_t aDeltaSystemTimestamp); /** * @brief Mark the end of this EventDataIB diff --git a/src/app/ReadClient.cpp b/src/app/ReadClient.cpp index 2110044bd996b3..2ad95422a844b8 100644 --- a/src/app/ReadClient.cpp +++ b/src/app/ReadClient.cpp @@ -222,7 +222,7 @@ CHIP_ERROR ReadClient::GenerateAttributePathList(AttributePathIBs::Builder & aAt for (size_t index = 0; index < aAttributePathParamsListSize; index++) { VerifyOrReturnError(apAttributePathParamsList[index].IsValidAttributePath(), CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH); - AttributePathIB::Builder path = aAttributePathIBsBuilder.CreatePath(); + AttributePathIB::Builder & path = aAttributePathIBsBuilder.CreatePath(); ReturnErrorOnFailure(aAttributePathIBsBuilder.GetError()); ReturnErrorOnFailure(path.Encode(apAttributePathParamsList[index])); } diff --git a/src/app/WriteClient.cpp b/src/app/WriteClient.cpp index a1db198e7ec326..36501ee780d35f 100644 --- a/src/app/WriteClient.cpp +++ b/src/app/WriteClient.cpp @@ -149,15 +149,11 @@ CHIP_ERROR WriteClient::PrepareAttribute(const AttributePathParams & attributePa CHIP_ERROR WriteClient::FinishAttribute() { - CHIP_ERROR err = CHIP_NO_ERROR; - - AttributeDataIB::Builder AttributeDataIB = mWriteRequestBuilder.GetWriteRequests().GetAttributeDataIBBuilder(); - AttributeDataIB.EndOfAttributeDataIB(); - SuccessOrExit(err = AttributeDataIB.GetError()); + AttributeDataIB::Builder & attributeDataIB = mWriteRequestBuilder.GetWriteRequests().GetAttributeDataIBBuilder(); + attributeDataIB.EndOfAttributeDataIB(); + ReturnErrorOnFailure(attributeDataIB.GetError()); MoveToState(State::AddAttribute); - -exit: - return err; + return CHIP_NO_ERROR; } TLV::TLVWriter * WriteClient::GetAttributeDataIBTLVWriter() @@ -167,22 +163,14 @@ TLV::TLVWriter * WriteClient::GetAttributeDataIBTLVWriter() CHIP_ERROR WriteClient::FinalizeMessage(System::PacketBufferHandle & aPacket) { - CHIP_ERROR err = CHIP_NO_ERROR; - AttributeDataIBs::Builder AttributeDataIBsBuilder; - VerifyOrExit(mState == State::AddAttribute, err = CHIP_ERROR_INCORRECT_STATE); - AttributeDataIBsBuilder = mWriteRequestBuilder.GetWriteRequests().EndOfAttributeDataIBs(); - err = AttributeDataIBsBuilder.GetError(); - SuccessOrExit(err); + VerifyOrReturnError(mState == State::AddAttribute, CHIP_ERROR_INCORRECT_STATE); + AttributeDataIBs::Builder & attributeDataIBsBuilder = mWriteRequestBuilder.GetWriteRequests().EndOfAttributeDataIBs(); + ReturnErrorOnFailure(attributeDataIBsBuilder.GetError()); mWriteRequestBuilder.IsFabricFiltered(false).EndOfWriteRequestMessage(); - err = mWriteRequestBuilder.GetError(); - SuccessOrExit(err); - - err = mMessageWriter.Finalize(&aPacket); - SuccessOrExit(err); - -exit: - return err; + ReturnErrorOnFailure(mWriteRequestBuilder.GetError()); + ReturnErrorOnFailure(mMessageWriter.Finalize(&aPacket)); + return CHIP_NO_ERROR; } const char * WriteClient::GetStateStr() const diff --git a/src/app/WriteHandler.cpp b/src/app/WriteHandler.cpp index 8b76d2ace34406..37d5b2387ff6c6 100644 --- a/src/app/WriteHandler.cpp +++ b/src/app/WriteHandler.cpp @@ -79,22 +79,13 @@ Status WriteHandler::OnWriteRequest(Messaging::ExchangeContext * apExchangeConte CHIP_ERROR WriteHandler::FinalizeMessage(System::PacketBufferHandle & packet) { - CHIP_ERROR err = CHIP_NO_ERROR; - AttributeStatusIBs::Builder attributeStatuses; - VerifyOrExit(mState == State::AddStatus, err = CHIP_ERROR_INCORRECT_STATE); - attributeStatuses = mWriteResponseBuilder.GetWriteResponses().EndOfAttributeStatuses(); - err = attributeStatuses.GetError(); - SuccessOrExit(err); - + VerifyOrReturnError(mState == State::AddStatus, CHIP_ERROR_INCORRECT_STATE); + AttributeStatusIBs::Builder & attributeStatusIBs = mWriteResponseBuilder.GetWriteResponses().EndOfAttributeStatuses(); + ReturnErrorOnFailure(attributeStatusIBs.GetError()); mWriteResponseBuilder.EndOfWriteResponseMessage(); - err = mWriteResponseBuilder.GetError(); - SuccessOrExit(err); - - err = mMessageWriter.Finalize(&packet); - SuccessOrExit(err); - -exit: - return err; + ReturnErrorOnFailure(mWriteResponseBuilder.GetError()); + ReturnErrorOnFailure(mMessageWriter.Finalize(&packet)); + return CHIP_NO_ERROR; } CHIP_ERROR WriteHandler::SendWriteResponse() diff --git a/src/app/tests/TestMessageDef.cpp b/src/app/tests/TestMessageDef.cpp index eedc42f664ca56..9451e2061de198 100644 --- a/src/app/tests/TestMessageDef.cpp +++ b/src/app/tests/TestMessageDef.cpp @@ -135,7 +135,7 @@ void ParseClusterPathIB(nlTestSuite * apSuite, chip::TLV::TLVReader & aReader) void BuildDataVersionFilterIB(nlTestSuite * apSuite, DataVersionFilterIB::Builder & aDataVersionFilterIBBuilder) { - ClusterPathIB::Builder clusterPathBuilder = aDataVersionFilterIBBuilder.CreatePath(); + ClusterPathIB::Builder & clusterPathBuilder = aDataVersionFilterIBBuilder.CreatePath(); NL_TEST_ASSERT(apSuite, clusterPathBuilder.GetError() == CHIP_NO_ERROR); BuildClusterPathIB(apSuite, clusterPathBuilder); aDataVersionFilterIBBuilder.DataVersion(2).EndOfDataVersionFilterIB(); diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp index 9af284ff9b301b..f34232c7c8adcd 100644 --- a/src/app/tests/TestReadInteraction.cpp +++ b/src/app/tests/TestReadInteraction.cpp @@ -535,7 +535,7 @@ void TestReadInteraction::TestReadHandlerInvalidAttributePath(nlTestSuite * apSu err = readRequestBuilder.Init(&writer); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - AttributePathIBs::Builder attributePathListBuilder = readRequestBuilder.CreateAttributeRequests(); + AttributePathIBs::Builder & attributePathListBuilder = readRequestBuilder.CreateAttributeRequests(); NL_TEST_ASSERT(apSuite, attributePathListBuilder.GetError() == CHIP_NO_ERROR); AttributePathIB::Builder & attributePathBuilder = attributePathListBuilder.CreatePath(); diff --git a/src/app/tests/TestReportingEngine.cpp b/src/app/tests/TestReportingEngine.cpp index dac801851cc044..6e72217447e329 100644 --- a/src/app/tests/TestReportingEngine.cpp +++ b/src/app/tests/TestReportingEngine.cpp @@ -87,20 +87,12 @@ void TestReportingEngine::TestBuildAndSendSingleReportData(nlTestSuite * apSuite NL_TEST_ASSERT(apSuite, readRequestBuilder.GetError() == CHIP_NO_ERROR); AttributePathIB::Builder & attributePathBuilder1 = attributePathListBuilder.CreatePath(); NL_TEST_ASSERT(apSuite, attributePathListBuilder.GetError() == CHIP_NO_ERROR); - attributePathBuilder1 = attributePathBuilder1.Node(1) - .Endpoint(kTestEndpointId) - .Cluster(kTestClusterId) - .Attribute(kTestFieldId1) - .EndOfAttributePathIB(); + attributePathBuilder1.Node(1).Endpoint(kTestEndpointId).Cluster(kTestClusterId).Attribute(kTestFieldId1).EndOfAttributePathIB(); NL_TEST_ASSERT(apSuite, attributePathBuilder1.GetError() == CHIP_NO_ERROR); AttributePathIB::Builder & attributePathBuilder2 = attributePathListBuilder.CreatePath(); NL_TEST_ASSERT(apSuite, attributePathListBuilder.GetError() == CHIP_NO_ERROR); - attributePathBuilder2 = attributePathBuilder2.Node(1) - .Endpoint(kTestEndpointId) - .Cluster(kTestClusterId) - .Attribute(kTestFieldId2) - .EndOfAttributePathIB(); + attributePathBuilder2.Node(1).Endpoint(kTestEndpointId).Cluster(kTestClusterId).Attribute(kTestFieldId2).EndOfAttributePathIB(); NL_TEST_ASSERT(apSuite, attributePathBuilder2.GetError() == CHIP_NO_ERROR); attributePathListBuilder.EndOfAttributePathIBs(); diff --git a/src/app/util/ContentAppPlatform.cpp b/src/app/util/ContentAppPlatform.cpp index e99e5b607ca3ac..a38e76419be029 100644 --- a/src/app/util/ContentAppPlatform.cpp +++ b/src/app/util/ContentAppPlatform.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index c7a59776b3bdd9..fda1eebdabdc91 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -22,7 +22,6 @@ */ #include -#include #include #include #include @@ -64,7 +63,7 @@ constexpr size_t kAttributeReadBufferSize = (ATTRIBUTE_LARGEST >= 8 ? ATTRIBUTE_ EmberAfClusterCommand imCompatibilityEmberAfCluster; EmberApsFrame imCompatibilityEmberApsFrame; EmberAfInterpanHeader imCompatibilityInterpanHeader; -Command * currentCommandObject; +CommandHandler * currentCommandObject; // BasicType maps the type to basic int(8|16|32|64)(s|u) types. EmberAfAttributeType BaseType(EmberAfAttributeType type) @@ -137,7 +136,30 @@ EmberAfAttributeType BaseType(EmberAfAttributeType type) } // namespace -void SetupEmberAfObjects(Command * command, const ConcreteCommandPath & commandPath) +void SetupEmberAfCommandSender(CommandSender * command, const ConcreteCommandPath & commandPath) +{ + Messaging::ExchangeContext * commandExchangeCtx = command->GetExchangeContext(); + + imCompatibilityEmberApsFrame.clusterId = commandPath.mClusterId; + imCompatibilityEmberApsFrame.destinationEndpoint = commandPath.mEndpointId; + imCompatibilityEmberApsFrame.sourceEndpoint = 1; // source endpoint is fixed to 1 for now. + imCompatibilityEmberApsFrame.sequence = + (commandExchangeCtx != nullptr ? static_cast(commandExchangeCtx->GetExchangeId() & 0xFF) : 0); + + if (commandExchangeCtx->IsGroupExchangeContext()) + { + imCompatibilityEmberAfCluster.type = EMBER_INCOMING_MULTICAST; + } + + imCompatibilityEmberAfCluster.commandId = commandPath.mCommandId; + imCompatibilityEmberAfCluster.apsFrame = &imCompatibilityEmberApsFrame; + imCompatibilityEmberAfCluster.interPanHeader = &imCompatibilityInterpanHeader; + imCompatibilityEmberAfCluster.source = commandExchangeCtx; + + emAfCurrentCommand = &imCompatibilityEmberAfCluster; +} + +void SetupEmberAfCommandHandler(CommandHandler * command, const ConcreteCommandPath & commandPath) { Messaging::ExchangeContext * commandExchangeCtx = command->GetExchangeContext(); @@ -359,7 +381,7 @@ CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const Concre if (attributeMetadata == nullptr) { - AttributeReportIB::Builder attributeReport = aAttributeReports.CreateAttributeReport(); + AttributeReportIB::Builder & attributeReport = aAttributeReports.CreateAttributeReport(); ReturnErrorOnFailure(aAttributeReports.GetError()); // This path is not actually supported. @@ -381,7 +403,7 @@ CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const Concre } } - AttributeReportIB::Builder attributeReport = aAttributeReports.CreateAttributeReport(); + AttributeReportIB::Builder & attributeReport = aAttributeReports.CreateAttributeReport(); ReturnErrorOnFailure(aAttributeReports.GetError()); TLV::TLVWriter backup; diff --git a/src/app/util/ember-compatibility-functions.h b/src/app/util/ember-compatibility-functions.h index 12f2527d8428e5..0c551121747e60 100644 --- a/src/app/util/ember-compatibility-functions.h +++ b/src/app/util/ember-compatibility-functions.h @@ -23,7 +23,7 @@ #pragma once -#include +#include #include #include #include @@ -32,7 +32,8 @@ namespace chip { namespace app { namespace Compatibility { -void SetupEmberAfObjects(Command * command, const ConcreteCommandPath & commandPath); +void SetupEmberAfCommandSender(CommandSender * command, const ConcreteCommandPath & commandPath); +void SetupEmberAfCommandHandler(CommandHandler * command, const ConcreteCommandPath & commandPath); bool IMEmberAfSendDefaultResponseWithCallback(EmberAfStatus status); void ResetEmberAfObjects(); diff --git a/src/app/util/im-client-callbacks.cpp b/src/app/util/im-client-callbacks.cpp index 7b523ea4354fb2..662064effb5675 100644 --- a/src/app/util/im-client-callbacks.cpp +++ b/src/app/util/im-client-callbacks.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -277,7 +276,7 @@ static void LogIMStatus(Protocols::InteractionModel::Status status) // Singleton instance of the callbacks manager static app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); -bool IMDefaultResponseCallback(const app::Command * commandObj, EmberAfStatus status) +bool IMDefaultResponseCallback(const app::CommandSender * commandObj, EmberAfStatus status) { ChipLogProgress(Zcl, "DefaultResponse:"); ChipLogProgress(Zcl, " Transaction: %p", commandObj); diff --git a/src/app/util/im-client-callbacks.h b/src/app/util/im-client-callbacks.h index 2a8ffb6eb58be0..631b13bef72b91 100644 --- a/src/app/util/im-client-callbacks.h +++ b/src/app/util/im-client-callbacks.h @@ -18,7 +18,7 @@ #pragma once #include -#include +#include #include #include #include @@ -29,7 +29,7 @@ // Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus // instead of IM status code. // #6308 should handle IM error code on the application side, either modify this function or remove this. -bool IMDefaultResponseCallback(const chip::app::Command * commandObj, EmberAfStatus status); +bool IMDefaultResponseCallback(const chip::app::CommandSender * commandObj, EmberAfStatus status); bool IMReadReportAttributesResponseCallback(const chip::app::ReadClient * apReadClient, const chip::app::ConcreteAttributePath * aPath, chip::TLV::TLVReader * apData, chip::Protocols::InteractionModel::Status status); diff --git a/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt b/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt index 19f059ea290694..9cb96ce81028b3 100644 --- a/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt +++ b/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt @@ -5,7 +5,6 @@ #include -#include #include #include #include diff --git a/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt b/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt index 366f132904349b..5cf6bbf433098e 100644 --- a/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt +++ b/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt @@ -3,7 +3,6 @@ {{#if (chip_has_client_clusters)}} #pragma once -#include #include #include #include diff --git a/src/app/zap-templates/templates/app/callback.zapt b/src/app/zap-templates/templates/app/callback.zapt index 4f9e0a2ca71614..adfdb0553fff5e 100644 --- a/src/app/zap-templates/templates/app/callback.zapt +++ b/src/app/zap-templates/templates/app/callback.zapt @@ -8,7 +8,6 @@ #include #include -#include #include #include #include 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 1b0f52ce202752..bb840e882179c9 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 @@ -8,7 +8,8 @@ #include #include #include -#include "app/util/util.h" +#include +#include #include #include #include @@ -19,14 +20,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -61,8 +54,11 @@ void Dispatch{{asUpperCamelCase side}}Command({{#if (isServer side)}}CommandHand } {{#last}} default: { + {{#if (isServer parent.side)}} // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + {{/if}} return; } } @@ -70,8 +66,8 @@ void Dispatch{{asUpperCamelCase side}}Command({{#if (isServer side)}}CommandHand if (CHIP_NO_ERROR != TLVError {{#unless (isServer parent.side)}}|| CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount{{/unless}} || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); {{#if (isServer parent.side)}} + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); {{else}} ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); @@ -83,7 +79,10 @@ void Dispatch{{asUpperCamelCase side}}Command({{#if (isServer side)}}CommandHand } {{/last}} {{else}} - ReportCommandUnsupported(apCommandObj, aCommandPath); + {{#if (isServer parent.side)}} + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + {{/if}} {{/chip_available_cluster_commands}} } @@ -96,7 +95,7 @@ void Dispatch{{asUpperCamelCase side}}Command({{#if (isServer side)}}CommandHand void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -121,7 +120,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -136,10 +135,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa {{/chip_client_clusters}} default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus( - aCommandPath, - Protocols::InteractionModel::Status::UnsupportedCluster - ); break; } diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 186c3cab4388a7..27e748ee29cc39 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -92,7 +92,7 @@ using namespace chip::Credentials; // For some applications those does not implement IMDelegate, the DeviceControllerInteractionModelDelegate will dispatch the // response to IMDefaultResponseCallback CHIPClientCallbacks, for the applications those implemented IMDelegate, this function will // not be used. -bool __attribute__((weak)) IMDefaultResponseCallback(const chip::app::Command * commandObj, EmberAfStatus status) +bool __attribute__((weak)) IMDefaultResponseCallback(const chip::app::CommandSender * commandObj, EmberAfStatus status) { return false; } diff --git a/src/controller/tests/data_model/TestRead.cpp b/src/controller/tests/data_model/TestRead.cpp index f5e6da67dc437c..d4ca48226397e3 100644 --- a/src/controller/tests/data_model/TestRead.cpp +++ b/src/controller/tests/data_model/TestRead.cpp @@ -65,8 +65,10 @@ CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const Concre if (responseDirective == kSendDataResponse) { - auto attributeReport = aAttributeReports.CreateAttributeReport(); - AttributeDataIB::Builder attributeData = attributeReport.CreateAttributeData(); + AttributeReportIB::Builder & attributeReport = aAttributeReports.CreateAttributeReport(); + ReturnErrorOnFailure(aAttributeReports.GetError()); + AttributeDataIB::Builder & attributeData = attributeReport.CreateAttributeData(); + ReturnErrorOnFailure(attributeReport.GetError()); TestCluster::Attributes::ListStructOctetString::TypeInfo::Type value; TestCluster::Structs::TestListStructOctet::Type valueBuf[4]; @@ -80,7 +82,7 @@ CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const Concre } attributeData.DataVersion(0); - AttributePathIB::Builder attributePath = attributeData.CreatePath(); + AttributePathIB::Builder & attributePath = attributeData.CreatePath(); attributePath.Endpoint(aPath.mEndpointId).Cluster(aPath.mClusterId).Attribute(aPath.mAttributeId).EndOfAttributePathIB(); ReturnErrorOnFailure(attributePath.GetError()); @@ -91,13 +93,15 @@ CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const Concre } else { - auto attributeReport = aAttributeReports.CreateAttributeReport(); - AttributeStatusIB::Builder attributeStatus = attributeReport.CreateAttributeStatus(); - AttributePathIB::Builder attributePath = attributeStatus.CreatePath(); + AttributeReportIB::Builder & attributeReport = aAttributeReports.CreateAttributeReport(); + ReturnErrorOnFailure(aAttributeReports.GetError()); + AttributeStatusIB::Builder & attributeStatus = attributeReport.CreateAttributeStatus(); + AttributePathIB::Builder & attributePath = attributeStatus.CreatePath(); attributePath.Endpoint(aPath.mEndpointId).Cluster(aPath.mClusterId).Attribute(aPath.mAttributeId).EndOfAttributePathIB(); ReturnErrorOnFailure(attributePath.GetError()); - StatusIB::Builder errorStatus = attributeStatus.CreateErrorStatus(); + StatusIB::Builder & errorStatus = attributeStatus.CreateErrorStatus(); + ReturnErrorOnFailure(attributeStatus.GetError()); errorStatus.EncodeStatusIB(StatusIB(Protocols::InteractionModel::Status::Busy)); attributeStatus.EndOfAttributeStatusIB(); ReturnErrorOnFailure(attributeStatus.GetError()); diff --git a/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp index 8aa5b5c517f332..19dd77a3aad51f 100644 --- a/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.h index 499a1924413099..9e7856a0222adf 100644 --- a/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.h @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp index 110214e9b8b25b..09ade7a02ec4f8 100644 --- a/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -94,7 +86,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -142,7 +136,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -161,7 +157,9 @@ namespace Basic { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); } } // namespace Basic @@ -199,7 +197,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -401,7 +401,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -440,7 +442,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -677,7 +681,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -716,7 +722,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -774,7 +782,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -858,7 +868,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -897,7 +909,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -954,7 +968,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1056,7 +1072,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1095,7 +1113,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1134,7 +1154,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1236,7 +1258,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1420,8 +1444,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -1429,7 +1451,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -1447,7 +1468,9 @@ namespace OtaSoftwareUpdateProvider { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); } } // namespace OtaSoftwareUpdateProvider @@ -1494,7 +1517,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1609,7 +1634,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1702,7 +1729,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1741,7 +1770,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1934,7 +1965,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1973,7 +2006,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -2012,7 +2047,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -2069,7 +2106,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -2088,7 +2127,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -2179,7 +2218,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -2190,7 +2229,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa break; default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/app-common/app-common/zap-generated/callback.h b/zzz_generated/app-common/app-common/zap-generated/callback.h index c0040cd82b2dfb..1f11cfb9ce36ed 100644 --- a/zzz_generated/app-common/app-common/zap-generated/callback.h +++ b/zzz_generated/app-common/app-common/zap-generated/callback.h @@ -25,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/bridge-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/bridge-app/zap-generated/IMClusterCommandHandler.cpp index b2c6ddff88e13e..c3aaf1dfcce90c 100644 --- a/zzz_generated/bridge-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/bridge-app/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -94,7 +86,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -133,7 +127,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -191,7 +187,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -293,7 +291,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -395,7 +395,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -452,7 +454,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -567,7 +571,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -586,7 +592,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -623,7 +629,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -631,7 +637,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa { default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp index c82b88c229b4bf..00bcbff4b09695 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h index e9d94f07b384f6..4fa16312e84526 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp index 7b7c8e8f806474..67d5a9260e2f86 100644 --- a/zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -126,8 +118,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -135,7 +125,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -230,8 +219,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -239,7 +226,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -397,8 +383,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -406,7 +390,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -509,8 +492,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -518,7 +499,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -1077,8 +1057,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -1086,7 +1064,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -1307,8 +1284,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -1316,7 +1291,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -1604,8 +1578,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -1613,7 +1585,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -1703,8 +1674,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -1712,7 +1681,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -1802,8 +1770,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -1811,7 +1777,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -2492,8 +2457,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -2501,7 +2464,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -3047,8 +3009,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -3056,7 +3016,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -3239,8 +3198,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -3248,7 +3205,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -3532,8 +3488,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -3541,7 +3495,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -3993,8 +3946,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -4002,7 +3953,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -4098,8 +4048,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -4107,7 +4055,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -4202,8 +4149,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -4211,7 +4156,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -4671,8 +4615,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -4680,7 +4622,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -4698,7 +4639,7 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -4714,7 +4655,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -4773,7 +4714,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa break; default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp index 8aa5b5c517f332..19dd77a3aad51f 100644 --- a/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.h index 499a1924413099..9e7856a0222adf 100644 --- a/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.h @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp index 6e9b21e99a8dd0..e4a6e20f188fad 100644 --- a/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -94,7 +86,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -296,7 +290,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -335,7 +331,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -374,7 +372,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -432,7 +432,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -489,7 +491,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -591,7 +595,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -693,7 +699,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -877,8 +885,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -886,7 +892,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -969,7 +974,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1084,7 +1091,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1123,7 +1132,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1162,7 +1173,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1201,7 +1214,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1220,7 +1235,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -1275,7 +1290,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -1286,7 +1301,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa break; default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/lock-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/lock-app/zap-generated/IMClusterCommandHandler.cpp index 96de6025e1ac59..c4fac34ec28d46 100644 --- a/zzz_generated/lock-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/lock-app/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -94,7 +86,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -133,7 +127,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -191,7 +187,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -293,7 +291,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -350,7 +350,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -465,7 +467,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -484,7 +488,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -518,7 +522,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -526,7 +530,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa { default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/ota-provider-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/ota-provider-app/zap-generated/IMClusterCommandHandler.cpp index 9ffc417766c69e..96f6ce364a037f 100644 --- a/zzz_generated/ota-provider-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/ota-provider-app/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -92,7 +84,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -194,7 +188,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -253,7 +249,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -349,7 +347,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -368,7 +368,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -396,7 +396,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -404,7 +404,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa { default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.cpp index 8aa5b5c517f332..19dd77a3aad51f 100644 --- a/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.h index 499a1924413099..9e7856a0222adf 100644 --- a/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.h @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp index 4ce300b05aac68..a15f71c4739fb6 100644 --- a/zzz_generated/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -92,7 +84,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -194,7 +188,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -378,8 +374,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -387,7 +381,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -426,7 +419,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -541,7 +536,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -560,7 +557,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -588,7 +585,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -599,7 +596,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa break; default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/placeholder/app1/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/placeholder/app1/zap-generated/IMClusterCommandHandler.cpp index f8563cc33d3aca..87de76850fcaa7 100644 --- a/zzz_generated/placeholder/app1/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/placeholder/app1/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -91,7 +83,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -149,7 +143,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -233,7 +229,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -281,7 +279,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -383,7 +383,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -440,7 +442,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -555,7 +559,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -648,7 +654,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -667,7 +675,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -707,7 +715,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -715,7 +723,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa { default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/placeholder/app2/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/placeholder/app2/zap-generated/IMClusterCommandHandler.cpp index af1309de3e2bbd..b3ebba1d16b48b 100644 --- a/zzz_generated/placeholder/app2/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/placeholder/app2/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -83,7 +75,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -167,7 +161,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -215,7 +211,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -317,7 +315,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -374,7 +374,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -489,7 +491,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -582,7 +586,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -601,7 +607,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -638,7 +644,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -646,7 +652,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa { default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.cpp index 98ee177d541321..9fa7ce3727a302 100644 --- a/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.h index fc342f8e9f5788..3d45ea2ad67826 100644 --- a/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.h @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/pump-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/pump-app/zap-generated/IMClusterCommandHandler.cpp index 73c5dc774d64ef..3456db9fddf13b 100644 --- a/zzz_generated/pump-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/pump-app/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -94,7 +86,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -113,7 +107,9 @@ namespace Basic { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); } } // namespace Basic @@ -142,7 +138,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -200,7 +198,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -302,7 +302,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -404,7 +406,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -461,7 +465,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -576,7 +582,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -595,7 +603,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -635,7 +643,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -643,7 +651,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa { default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.cpp index 98ee177d541321..9fa7ce3727a302 100644 --- a/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.h index fc342f8e9f5788..3d45ea2ad67826 100644 --- a/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.h @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/pump-controller-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/pump-controller-app/zap-generated/IMClusterCommandHandler.cpp index 199373d627dd6e..73be1238d2bc81 100644 --- a/zzz_generated/pump-controller-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/pump-controller-app/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -94,7 +86,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -113,7 +107,9 @@ namespace Basic { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); } } // namespace Basic @@ -142,7 +138,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -200,7 +198,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -302,7 +302,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -417,7 +419,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -436,7 +440,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -470,7 +474,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -478,7 +482,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa { default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/temperature-measurement-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/temperature-measurement-app/zap-generated/IMClusterCommandHandler.cpp index a47f49b3591c3f..23ad8124dc54a1 100644 --- a/zzz_generated/temperature-measurement-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/temperature-measurement-app/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -94,7 +86,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -133,7 +127,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -191,7 +187,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -275,7 +273,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -390,7 +390,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -409,7 +411,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -440,7 +442,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -448,7 +450,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa { default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.cpp index b36455f164431b..ca33113ab4ecf9 100644 --- a/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.h b/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.h index 53b3d4568ab56e..667bdbbff27e3c 100644 --- a/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.h @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/thermostat/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/thermostat/zap-generated/IMClusterCommandHandler.cpp index 22ae47395baee1..c0d77342ca5e5e 100644 --- a/zzz_generated/thermostat/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/thermostat/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -94,7 +86,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -113,7 +107,9 @@ namespace Basic { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); } } // namespace Basic @@ -151,7 +147,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -190,7 +188,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -248,7 +248,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -332,7 +334,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -423,8 +427,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -432,7 +434,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -479,7 +480,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -581,7 +584,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -640,7 +645,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -755,7 +762,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -848,7 +857,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -923,7 +934,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -942,7 +955,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -994,7 +1007,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -1005,7 +1018,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa break; default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.cpp index 1d751ad6530fab..7d36f8a2df83c5 100644 --- a/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.h index 8f342fd8e7c87f..81bf5630a3945e 100644 --- a/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.h @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/zzz_generated/tv-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/tv-app/zap-generated/IMClusterCommandHandler.cpp index 48487d87cf0693..c991cb4d79a547 100644 --- a/zzz_generated/tv-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/tv-app/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -82,7 +74,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -142,7 +136,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -181,7 +177,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -220,7 +218,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -268,7 +268,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -287,7 +289,9 @@ namespace Basic { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); } } // namespace Basic @@ -325,7 +329,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -373,7 +379,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -412,7 +420,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -634,8 +644,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -643,7 +651,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -700,7 +707,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -739,7 +748,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -841,7 +852,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -880,7 +893,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -946,7 +961,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1075,7 +1092,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1622,8 +1641,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -1631,7 +1648,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -1732,7 +1748,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1791,7 +1809,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1848,7 +1868,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -2133,8 +2155,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa break; } default: { - // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); return; } } @@ -2142,7 +2162,6 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, @@ -2256,7 +2275,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -2313,7 +2334,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -2352,7 +2375,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -2371,7 +2396,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -2450,7 +2475,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -2467,7 +2492,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa break; default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/tv-casting-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/tv-casting-app/zap-generated/IMClusterCommandHandler.cpp index 15f46f525258e3..efdf48cc266c72 100644 --- a/zzz_generated/tv-casting-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/tv-casting-app/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -94,7 +86,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -142,7 +136,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -161,7 +157,9 @@ namespace Basic { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); } } // namespace Basic @@ -199,7 +197,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -355,7 +355,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -394,7 +396,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -631,7 +635,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -689,7 +695,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -773,7 +781,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -812,7 +822,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -860,7 +872,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -962,7 +976,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1064,7 +1080,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1123,7 +1141,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1180,7 +1200,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1295,7 +1317,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1388,7 +1412,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1445,7 +1471,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -1464,7 +1492,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -1534,7 +1562,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -1542,7 +1570,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa { default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; } diff --git a/zzz_generated/window-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/window-app/zap-generated/IMClusterCommandHandler.cpp index c8011a1c54ea7a..3dac45db55a84e 100644 --- a/zzz_generated/window-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/window-app/zap-generated/IMClusterCommandHandler.cpp @@ -20,13 +20,14 @@ #include #include -#include "app/util/util.h" #include #include #include #include #include +#include #include +#include #include #include @@ -36,15 +37,6 @@ namespace chip { namespace app { -namespace { -void ReportCommandUnsupported(Command * aCommandObj, const ConcreteCommandPath & aCommandPath) -{ - aCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); -} -} // anonymous namespace - // Cluster specific command parsing namespace Clusters { @@ -94,7 +86,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -152,7 +146,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -209,7 +205,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -311,7 +309,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -426,7 +426,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -519,7 +521,9 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } default: { // Unrecognized command ID, error status will apply. - ReportCommandUnsupported(apCommandObj, aCommandPath); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); return; } } @@ -538,7 +542,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); switch (aCommandPath.mClusterId) { @@ -572,7 +576,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) { - Compatibility::SetupEmberAfObjects(apCommandObj, aCommandPath); + Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); @@ -580,7 +584,6 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa { default: ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); break; }