diff --git a/examples/all-clusters-app/all-clusters-common/include/static-supported-modes-manager.h b/examples/all-clusters-app/all-clusters-common/include/static-supported-modes-manager.h index 8c9515738fa7da..a8ef29863e9f0f 100644 --- a/examples/all-clusters-app/all-clusters-common/include/static-supported-modes-manager.h +++ b/examples/all-clusters-app/all-clusters-common/include/static-supported-modes-manager.h @@ -56,7 +56,8 @@ class StaticSupportedModesManager : public chip::app::Clusters::ModeSelect::Supp SupportedModesManager::ModeOptionsProvider getModeOptionsProvider(EndpointId endpointId) const override; - EmberAfStatus getModeOptionByMode(EndpointId endpointId, uint8_t mode, const ModeOptionStructType ** dataPtr) const override; + Protocols::InteractionModel::Status getModeOptionByMode(EndpointId endpointId, uint8_t mode, + const ModeOptionStructType ** dataPtr) const override; ~StaticSupportedModesManager(){}; diff --git a/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp b/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp index 3bc8d9a60fdf71..416915582d48ee 100644 --- a/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp @@ -4,6 +4,7 @@ using namespace std; using namespace chip; using namespace chip::app::Clusters; using namespace chip::app::Clusters::ModeSelect; +using chip::Protocols::InteractionModel::Status; using ModeOptionStructType = Structs::ModeOptionStruct::Type; using SemanticTag = Structs::SemanticTagStruct::Type; @@ -51,13 +52,13 @@ SupportedModesManager::ModeOptionsProvider StaticSupportedModesManager::getModeO return ModeOptionsProvider(nullptr, nullptr); } -EmberAfStatus StaticSupportedModesManager::getModeOptionByMode(unsigned short endpointId, unsigned char mode, - const ModeOptionStructType ** dataPtr) const +Status StaticSupportedModesManager::getModeOptionByMode(unsigned short endpointId, unsigned char mode, + const ModeOptionStructType ** dataPtr) const { auto modeOptionsProvider = this->getModeOptionsProvider(endpointId); if (modeOptionsProvider.begin() == nullptr) { - return EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER; + return Status::UnsupportedCluster; } auto * begin = this->getModeOptionsProvider(endpointId).begin(); auto * end = this->getModeOptionsProvider(endpointId).end(); @@ -68,11 +69,11 @@ EmberAfStatus StaticSupportedModesManager::getModeOptionByMode(unsigned short en if (modeOption.mode == mode) { *dataPtr = &modeOption; - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } } emberAfPrintln(EMBER_AF_PRINT_DEBUG, "Cannot find the mode %u", mode); - return EMBER_ZCL_STATUS_INVALID_COMMAND; + return Status::InvalidCommand; } const ModeSelect::SupportedModesManager * ModeSelect::getSupportedModesManager() diff --git a/examples/placeholder/linux/include/static-supported-modes-manager.h b/examples/placeholder/linux/include/static-supported-modes-manager.h index 8c9515738fa7da..a8ef29863e9f0f 100644 --- a/examples/placeholder/linux/include/static-supported-modes-manager.h +++ b/examples/placeholder/linux/include/static-supported-modes-manager.h @@ -56,7 +56,8 @@ class StaticSupportedModesManager : public chip::app::Clusters::ModeSelect::Supp SupportedModesManager::ModeOptionsProvider getModeOptionsProvider(EndpointId endpointId) const override; - EmberAfStatus getModeOptionByMode(EndpointId endpointId, uint8_t mode, const ModeOptionStructType ** dataPtr) const override; + Protocols::InteractionModel::Status getModeOptionByMode(EndpointId endpointId, uint8_t mode, + const ModeOptionStructType ** dataPtr) const override; ~StaticSupportedModesManager(){}; diff --git a/examples/placeholder/linux/static-supported-modes-manager.cpp b/examples/placeholder/linux/static-supported-modes-manager.cpp index 3bc8d9a60fdf71..416915582d48ee 100644 --- a/examples/placeholder/linux/static-supported-modes-manager.cpp +++ b/examples/placeholder/linux/static-supported-modes-manager.cpp @@ -4,6 +4,7 @@ using namespace std; using namespace chip; using namespace chip::app::Clusters; using namespace chip::app::Clusters::ModeSelect; +using chip::Protocols::InteractionModel::Status; using ModeOptionStructType = Structs::ModeOptionStruct::Type; using SemanticTag = Structs::SemanticTagStruct::Type; @@ -51,13 +52,13 @@ SupportedModesManager::ModeOptionsProvider StaticSupportedModesManager::getModeO return ModeOptionsProvider(nullptr, nullptr); } -EmberAfStatus StaticSupportedModesManager::getModeOptionByMode(unsigned short endpointId, unsigned char mode, - const ModeOptionStructType ** dataPtr) const +Status StaticSupportedModesManager::getModeOptionByMode(unsigned short endpointId, unsigned char mode, + const ModeOptionStructType ** dataPtr) const { auto modeOptionsProvider = this->getModeOptionsProvider(endpointId); if (modeOptionsProvider.begin() == nullptr) { - return EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER; + return Status::UnsupportedCluster; } auto * begin = this->getModeOptionsProvider(endpointId).begin(); auto * end = this->getModeOptionsProvider(endpointId).end(); @@ -68,11 +69,11 @@ EmberAfStatus StaticSupportedModesManager::getModeOptionByMode(unsigned short en if (modeOption.mode == mode) { *dataPtr = &modeOption; - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } } emberAfPrintln(EMBER_AF_PRINT_DEBUG, "Cannot find the mode %u", mode); - return EMBER_ZCL_STATUS_INVALID_COMMAND; + return Status::InvalidCommand; } const ModeSelect::SupportedModesManager * ModeSelect::getSupportedModesManager() diff --git a/src/app/clusters/account-login-server/account-login-server.cpp b/src/app/clusters/account-login-server/account-login-server.cpp index da53ea15e87315..39e05d54e41909 100644 --- a/src/app/clusters/account-login-server/account-login-server.cpp +++ b/src/app/clusters/account-login-server/account-login-server.cpp @@ -41,6 +41,7 @@ using namespace chip::app::Clusters::AccountLogin; using namespace chip::AppPlatform; #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED using chip::app::Clusters::AccountLogin::Delegate; +using chip::Protocols::InteractionModel::Status; static constexpr size_t kAccountLoginDeletageTableSize = EMBER_AF_ACCOUNT_LOGIN_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; @@ -125,7 +126,7 @@ bool emberAfAccountLoginClusterGetSetupPINCallback(app::CommandHandler * command { ChipLogError(Zcl, "emberAfAccountLoginClusterGetSetupPINCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -136,7 +137,7 @@ bool emberAfAccountLoginClusterLoginCallback(app::CommandHandler * command, cons { CHIP_ERROR err = CHIP_NO_ERROR; EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; auto & tempAccountIdentifier = commandData.tempAccountIdentifier; auto & setupPin = commandData.setupPIN; @@ -145,42 +146,42 @@ bool emberAfAccountLoginClusterLoginCallback(app::CommandHandler * command, cons if (!delegate->HandleLogin(tempAccountIdentifier, setupPin)) { - status = EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS; + status = Status::UnsupportedAccess; } exit: if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfAccountLoginClusterLoginCallback error: %s", err.AsString()); - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } - emberAfSendImmediateDefaultResponse(status); + command->AddStatus(commandPath, status); return true; } bool emberAfAccountLoginClusterLogoutCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::Logout::DecodableType & commandData) { - CHIP_ERROR err = CHIP_NO_ERROR; - EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + CHIP_ERROR err = CHIP_NO_ERROR; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; Delegate * delegate = GetDelegate(endpoint); VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE); if (!delegate->HandleLogout()) { - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } exit: if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfAccountLoginClusterLogoutCallback error: %s", err.AsString()); - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } diff --git a/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp b/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp index 67ee2c831c755a..8232e5f51eb924 100644 --- a/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp +++ b/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp @@ -41,6 +41,7 @@ using namespace chip::app; using namespace chip::app::Clusters; using namespace chip::app::Clusters::AdministratorCommissioning; using namespace chip::Protocols; +using chip::Protocols::InteractionModel::Status; class AdministratorCommissioningAttrAccess : public AttributeAccessInterface { @@ -199,7 +200,7 @@ bool emberAfAdministratorCommissioningClusterRevokeCommissioningCallback( { Server::GetInstance().GetCommissioningWindowManager().CloseCommissioningWindow(); ChipLogProgress(Zcl, "Commissioning window is now closed"); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); } return true; } diff --git a/src/app/clusters/application-launcher-server/application-launcher-server.cpp b/src/app/clusters/application-launcher-server/application-launcher-server.cpp index 874ad78d013812..ed3f01102bfe1e 100644 --- a/src/app/clusters/application-launcher-server/application-launcher-server.cpp +++ b/src/app/clusters/application-launcher-server/application-launcher-server.cpp @@ -55,6 +55,7 @@ static constexpr size_t kApplicationLauncherDelegateTableSize = using chip::app::Clusters::ApplicationBasic::CatalogVendorApp; using chip::app::Clusters::ApplicationLauncher::Delegate; using ApplicationStatusEnum = app::Clusters::ApplicationBasic::ApplicationStatusEnum; +using chip::Protocols::InteractionModel::Status; namespace { @@ -301,7 +302,7 @@ bool emberAfApplicationLauncherClusterLaunchAppCallback(app::CommandHandler * co if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfApplicationLauncherClusterLaunchAppCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -390,7 +391,7 @@ bool emberAfApplicationLauncherClusterStopAppCallback(app::CommandHandler * comm if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfApplicationLauncherClusterStopAppCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -475,7 +476,7 @@ bool emberAfApplicationLauncherClusterHideAppCallback(app::CommandHandler * comm if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfApplicationLauncherClusterStopAppCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; diff --git a/src/app/clusters/audio-output-server/audio-output-server.cpp b/src/app/clusters/audio-output-server/audio-output-server.cpp index df73f6189cf7c9..c28c3811a4c997 100644 --- a/src/app/clusters/audio-output-server/audio-output-server.cpp +++ b/src/app/clusters/audio-output-server/audio-output-server.cpp @@ -35,6 +35,7 @@ using namespace chip; using namespace chip::app::Clusters::AudioOutput; +using chip::Protocols::InteractionModel::Status; static constexpr size_t kAudioOutputDelegateTableSize = EMBER_AF_AUDIO_OUTPUT_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; @@ -212,27 +213,27 @@ bool emberAfAudioOutputClusterRenameOutputCallback(app::CommandHandler * command bool emberAfAudioOutputClusterSelectOutputCallback(app::CommandHandler * command, const app::ConcreteCommandPath & commandPath, const Commands::SelectOutput::DecodableType & commandData) { - CHIP_ERROR err = CHIP_NO_ERROR; - EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - auto & index = commandData.index; + CHIP_ERROR err = CHIP_NO_ERROR; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; + auto & index = commandData.index; Delegate * delegate = GetDelegate(endpoint); VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE); if (!delegate->HandleSelectOutput(index)) { - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } exit: if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfAudioOutputClusterSelectOutputCallback error: %s", err.AsString()); - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } - emberAfSendImmediateDefaultResponse(status); + command->AddStatus(commandPath, status); return true; } diff --git a/src/app/clusters/barrier-control-server/barrier-control-server.cpp b/src/app/clusters/barrier-control-server/barrier-control-server.cpp index e310d7ba541061..94f286bed4cbc4 100644 --- a/src/app/clusters/barrier-control-server/barrier-control-server.cpp +++ b/src/app/clusters/barrier-control-server/barrier-control-server.cpp @@ -32,6 +32,7 @@ using namespace chip; using namespace chip::app::Clusters; using namespace chip::app::Clusters::BarrierControl; +using chip::Protocols::InteractionModel::Status; typedef struct { @@ -258,9 +259,9 @@ void emberAfBarrierControlClusterServerTickCallback(EndpointId endpoint) // ----------------------------------------------------------------------------- // Handling commands -static void sendDefaultResponse(EmberAfStatus status) +static void sendDefaultResponse(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, Status status) { - if (emberAfSendImmediateDefaultResponse(status) != EMBER_SUCCESS) + if (commandObj->AddStatus(commandPath, status) != CHIP_NO_ERROR) { emberAfBarrierControlClusterPrintln("Failed to send default response"); } @@ -272,21 +273,21 @@ bool emberAfBarrierControlClusterBarrierControlGoToPercentCallback( { auto & percentOpen = commandData.percentOpen; - EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; emberAfBarrierControlClusterPrintln("RX: GoToPercentCallback p=%d", percentOpen); if (isRemoteLockoutOn(endpoint)) { - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } else if (percentOpen > 100 // "100" means "100%", so greater than that is invalid || (!emAfPluginBarrierControlServerIsPartialBarrierSupported(endpoint) && percentOpen != EMBER_ZCL_BARRIER_CONTROL_BARRIER_POSITION_CLOSED && percentOpen != EMBER_ZCL_BARRIER_CONTROL_BARRIER_POSITION_OPEN)) { - status = EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + status = Status::ConstraintError; } else { @@ -307,7 +308,7 @@ bool emberAfBarrierControlClusterBarrierControlGoToPercentCallback( } } - sendDefaultResponse(status); + sendDefaultResponse(commandObj, commandPath, status); return true; } @@ -319,7 +320,7 @@ bool emberAfBarrierControlClusterBarrierControlStopCallback(app::CommandHandler EndpointId endpoint = commandPath.mEndpointId; emberAfDeactivateServerTick(endpoint, BarrierControl::Id); setMovingState(endpoint, EMBER_ZCL_BARRIER_CONTROL_MOVING_STATE_STOPPED); - sendDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + sendDefaultResponse(commandObj, commandPath, Status::Success); return true; } diff --git a/src/app/clusters/channel-server/channel-server.cpp b/src/app/clusters/channel-server/channel-server.cpp index f2f51c2deb52b3..909daad853dd56 100644 --- a/src/app/clusters/channel-server/channel-server.cpp +++ b/src/app/clusters/channel-server/channel-server.cpp @@ -34,6 +34,7 @@ using namespace chip::app::Clusters::Channel; #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED using namespace chip::AppPlatform; #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED +using chip::Protocols::InteractionModel::Status; static constexpr size_t kChannelDelegateTableSize = EMBER_AF_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; @@ -223,7 +224,7 @@ bool emberAfChannelClusterChangeChannelCallback(app::CommandHandler * command, c // If isDelegateNull, no one will call responder, so HasSentResponse will be false if (!responder.HasSentResponse()) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -232,55 +233,55 @@ bool emberAfChannelClusterChangeChannelCallback(app::CommandHandler * command, c bool emberAfChannelClusterChangeChannelByNumberCallback(app::CommandHandler * command, const app::ConcreteCommandPath & commandPath, const Commands::ChangeChannelByNumber::DecodableType & commandData) { - CHIP_ERROR err = CHIP_NO_ERROR; - EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - auto & majorNumber = commandData.majorNumber; - auto & minorNumber = commandData.minorNumber; + CHIP_ERROR err = CHIP_NO_ERROR; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; + auto & majorNumber = commandData.majorNumber; + auto & minorNumber = commandData.minorNumber; Delegate * delegate = GetDelegate(endpoint); VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE); if (!delegate->HandleChangeChannelByNumber(majorNumber, minorNumber)) { - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } exit: if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfChannelClusterChangeChannelByNumberCallback error: %s", err.AsString()); - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } - emberAfSendImmediateDefaultResponse(status); + command->AddStatus(commandPath, status); return true; } bool emberAfChannelClusterSkipChannelCallback(app::CommandHandler * command, const app::ConcreteCommandPath & commandPath, const Commands::SkipChannel::DecodableType & commandData) { - CHIP_ERROR err = CHIP_NO_ERROR; - EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - auto & count = commandData.count; + CHIP_ERROR err = CHIP_NO_ERROR; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; + auto & count = commandData.count; Delegate * delegate = GetDelegate(endpoint); VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE); if (!delegate->HandleSkipChannel(count)) { - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } exit: if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfChannelClusterSkipChannelCallback error: %s", err.AsString()); - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } - emberAfSendImmediateDefaultResponse(status); + command->AddStatus(commandPath, status); return true; } diff --git a/src/app/clusters/color-control-server/color-control-server.cpp b/src/app/clusters/color-control-server/color-control-server.cpp index 593fcb64ffaee5..2e3c485db6c82d 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -27,6 +27,7 @@ using namespace chip; using namespace chip::app::Clusters; using namespace chip::app::Clusters::ColorControl; +using chip::Protocols::InteractionModel::Status; /********************************************************** * Attributes Definition @@ -52,25 +53,27 @@ bool ColorControlServer::HasFeature(chip::EndpointId endpoint, ColorControlFeatu return success ? ((featureMap & to_underlying(feature)) != 0) : false; } -EmberAfStatus ColorControlServer::stopAllColorTransitions(EndpointId endpoint) +Status ColorControlServer::stopAllColorTransitions(EndpointId endpoint) { EmberEventControl * event = getEventControl(endpoint); - VerifyOrReturnError(event != nullptr, EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrReturnError(event != nullptr, Status::UnsupportedEndpoint); emberEventControlSetInactive(event); - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } -bool ColorControlServer::stopMoveStepCommand(EndpointId endpoint, uint8_t optionsMask, uint8_t optionsOverride) +bool ColorControlServer::stopMoveStepCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, + uint8_t optionsMask, uint8_t optionsOverride) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; if (shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { status = stopAllColorTransitions(endpoint); } - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -747,22 +750,25 @@ EmberEventControl * ColorControlServer::configureHSVEventControl(EndpointId endp * @return true Success * @return false Failed */ -bool ColorControlServer::moveHueCommand(EndpointId endpoint, uint8_t moveMode, uint16_t rate, uint8_t optionsMask, - uint8_t optionsOverride, bool isEnhanced) +bool ColorControlServer::moveHueCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, + uint8_t moveMode, uint16_t rate, uint8_t optionsMask, uint8_t optionsOverride, + bool isEnhanced) { + EndpointId endpoint = commandPath.mEndpointId; + uint8_t currentHue = 0; uint16_t currentEnhancedHue = 0; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState(endpoint); Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState(endpoint); - VerifyOrExit(colorHueTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); - VerifyOrExit(colorSaturationTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint); + VerifyOrExit(colorSaturationTransitionState != nullptr, status = Status::UnsupportedEndpoint); if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -771,7 +777,7 @@ bool ColorControlServer::moveHueCommand(EndpointId endpoint, uint8_t moveMode, u if (moveMode == EMBER_ZCL_HUE_MOVE_MODE_STOP) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -830,7 +836,7 @@ bool ColorControlServer::moveHueCommand(EndpointId endpoint, uint8_t moveMode, u } else { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_MALFORMED_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidAction); return true; } colorHueTransitionState->stepsRemaining = TRANSITION_TIME_1S; @@ -846,7 +852,7 @@ bool ColorControlServer::moveHueCommand(EndpointId endpoint, uint8_t moveMode, u emberEventControlSetDelayMS(configureHSVEventControl(endpoint), UPDATE_TIME_MS); exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -864,22 +870,25 @@ bool ColorControlServer::moveHueCommand(EndpointId endpoint, uint8_t moveMode, u * @return true Success * @return false Failed */ -bool ColorControlServer::moveToHueCommand(EndpointId endpoint, uint16_t hue, uint8_t hueMoveMode, uint16_t transitionTime, - uint8_t optionsMask, uint8_t optionsOverride, bool isEnhanced) +bool ColorControlServer::moveToHueCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, + uint16_t hue, uint8_t hueMoveMode, uint16_t transitionTime, uint8_t optionsMask, + uint8_t optionsOverride, bool isEnhanced) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - uint16_t currentHue = 0; + EndpointId endpoint = commandPath.mEndpointId; + + Status status = Status::Success; + uint16_t currentHue = 0; uint8_t direction; ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState(endpoint); Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState(endpoint); - VerifyOrExit(colorHueTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); - VerifyOrExit(colorSaturationTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint); + VerifyOrExit(colorSaturationTransitionState != nullptr, status = Status::UnsupportedEndpoint); if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -904,7 +913,7 @@ bool ColorControlServer::moveToHueCommand(EndpointId endpoint, uint16_t hue, uin // this and report a malformed packet. if (!isEnhanced && (hue > MAX_HUE_VALUE)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_MALFORMED_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidAction); return true; } @@ -942,7 +951,7 @@ bool ColorControlServer::moveToHueCommand(EndpointId endpoint, uint16_t hue, uin direction = MOVE_MODE_DOWN; break; default: - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_MALFORMED_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidAction); return true; } @@ -991,7 +1000,7 @@ bool ColorControlServer::moveToHueCommand(EndpointId endpoint, uint16_t hue, uin emberEventControlSetDelayMS(configureHSVEventControl(endpoint), UPDATE_TIME_MS); exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -1009,20 +1018,23 @@ bool ColorControlServer::moveToHueCommand(EndpointId endpoint, uint16_t hue, uin * @return true Success * @return false Failed */ -bool ColorControlServer::moveToHueAndSaturationCommand(EndpointId endpoint, uint16_t hue, uint8_t saturation, - uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride, - bool isEnhanced) +bool ColorControlServer::moveToHueAndSaturationCommand(app::CommandHandler * commandObj, + const app::ConcreteCommandPath & commandPath, uint16_t hue, + uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, + uint8_t optionsOverride, bool isEnhanced) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - uint16_t currentHue = 0; - uint16_t halfWay = isEnhanced ? HALF_MAX_UINT16T : HALF_MAX_UINT8T; + EndpointId endpoint = commandPath.mEndpointId; + + Status status = Status::Success; + uint16_t currentHue = 0; + uint16_t halfWay = isEnhanced ? HALF_MAX_UINT16T : HALF_MAX_UINT8T; bool moveUp; Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState(endpoint); ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState(endpoint); - VerifyOrExit(colorSaturationTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); - VerifyOrExit(colorHueTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrExit(colorSaturationTransitionState != nullptr, status = Status::UnsupportedEndpoint); + VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint); if (isEnhanced) { @@ -1045,13 +1057,13 @@ bool ColorControlServer::moveToHueAndSaturationCommand(EndpointId endpoint, uint // this and report a malformed packet. if ((!isEnhanced && hue > MAX_HUE_VALUE) || saturation > MAX_SATURATION_VALUE) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_MALFORMED_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidAction); return true; } if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -1116,7 +1128,7 @@ bool ColorControlServer::moveToHueAndSaturationCommand(EndpointId endpoint, uint emberEventControlSetDelayMS(configureHSVEventControl(endpoint), UPDATE_TIME_MS); exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -1134,20 +1146,23 @@ bool ColorControlServer::moveToHueAndSaturationCommand(EndpointId endpoint, uint * @return true Success * @return false Failed */ -bool ColorControlServer::stepHueCommand(EndpointId endpoint, uint8_t stepMode, uint16_t stepSize, uint16_t transitionTime, - uint8_t optionsMask, uint8_t optionsOverride, bool isEnhanced) +bool ColorControlServer::stepHueCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, + uint8_t stepMode, uint16_t stepSize, uint16_t transitionTime, uint8_t optionsMask, + uint8_t optionsOverride, bool isEnhanced) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + EndpointId endpoint = commandPath.mEndpointId; + + Status status = Status::Success; ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState(endpoint); Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState(endpoint); - VerifyOrExit(colorHueTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); - VerifyOrExit(colorSaturationTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint); + VerifyOrExit(colorSaturationTransitionState != nullptr, status = Status::UnsupportedEndpoint); if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -1161,7 +1176,7 @@ bool ColorControlServer::stepHueCommand(EndpointId endpoint, uint8_t stepMode, u if (stepMode == MOVE_MODE_STOP) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -1224,11 +1239,11 @@ bool ColorControlServer::stepHueCommand(EndpointId endpoint, uint8_t stepMode, u emberEventControlSetDelayMS(configureHSVEventControl(endpoint), UPDATE_TIME_MS); exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } -bool ColorControlServer::moveSaturationCommand(const app::ConcreteCommandPath & commandPath, +bool ColorControlServer::moveSaturationCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveSaturation::DecodableType & commandData) { auto & moveMode = commandData.moveMode; @@ -1236,17 +1251,17 @@ bool ColorControlServer::moveSaturationCommand(const app::ConcreteCommandPath & auto & optionsMask = commandData.optionsMask; auto & optionsOverride = commandData.optionsOverride; EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState(endpoint); Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState(endpoint); - VerifyOrExit(colorHueTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); - VerifyOrExit(colorSaturationTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint); + VerifyOrExit(colorSaturationTransitionState != nullptr, status = Status::UnsupportedEndpoint); if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -1257,7 +1272,7 @@ bool ColorControlServer::moveSaturationCommand(const app::ConcreteCommandPath & if (moveMode == EMBER_ZCL_SATURATION_MOVE_MODE_STOP || rate == 0) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -1294,7 +1309,7 @@ bool ColorControlServer::moveSaturationCommand(const app::ConcreteCommandPath & emberEventControlSetDelayMS(configureHSVEventControl(endpoint), UPDATE_TIME_MS); exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -1308,7 +1323,7 @@ bool ColorControlServer::moveSaturationCommand(const app::ConcreteCommandPath & * @return true * @return false */ -bool ColorControlServer::moveToSaturationCommand(const app::ConcreteCommandPath & commandPath, +bool ColorControlServer::moveToSaturationCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveToSaturation::DecodableType & commandData) { uint8_t saturation = commandData.saturation; @@ -1316,17 +1331,17 @@ bool ColorControlServer::moveToSaturationCommand(const app::ConcreteCommandPath uint8_t optionsMask = commandData.optionsMask; uint8_t optionsOverride = commandData.optionsOverride; EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState(endpoint); Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState(endpoint); - VerifyOrExit(colorHueTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); - VerifyOrExit(colorSaturationTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint); + VerifyOrExit(colorSaturationTransitionState != nullptr, status = Status::UnsupportedEndpoint); if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -1339,7 +1354,7 @@ bool ColorControlServer::moveToSaturationCommand(const app::ConcreteCommandPath // this and report a malformed packet. if (saturation > MAX_SATURATION_VALUE) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_MALFORMED_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidAction); return true; } @@ -1369,11 +1384,11 @@ bool ColorControlServer::moveToSaturationCommand(const app::ConcreteCommandPath emberEventControlSetDelayMS(configureHSVEventControl(endpoint), UPDATE_TIME_MS); exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } -bool ColorControlServer::stepSaturationCommand(const app::ConcreteCommandPath & commandPath, +bool ColorControlServer::stepSaturationCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::StepSaturation::DecodableType & commandData) { uint8_t stepMode = commandData.stepMode; @@ -1382,18 +1397,18 @@ bool ColorControlServer::stepSaturationCommand(const app::ConcreteCommandPath & uint8_t optionsMask = commandData.optionsMask; uint8_t optionsOverride = commandData.optionsOverride; EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; uint8_t currentSaturation = 0; ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState(endpoint); Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState(endpoint); - VerifyOrExit(colorHueTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); - VerifyOrExit(colorSaturationTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint); + VerifyOrExit(colorSaturationTransitionState != nullptr, status = Status::UnsupportedEndpoint); if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -1409,7 +1424,7 @@ bool ColorControlServer::stepSaturationCommand(const app::ConcreteCommandPath & if (stepMode == MOVE_MODE_STOP) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -1444,11 +1459,11 @@ bool ColorControlServer::stepSaturationCommand(const app::ConcreteCommandPath & emberEventControlSetDelayMS(configureHSVEventControl(endpoint), UPDATE_TIME_MS); exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } -bool ColorControlServer::colorLoopCommand(const app::ConcreteCommandPath & commandPath, +bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::ColorLoopSet::DecodableType & commandData) { uint8_t updateFlags = commandData.updateFlags.Raw(); @@ -1459,16 +1474,16 @@ bool ColorControlServer::colorLoopCommand(const app::ConcreteCommandPath & comma uint8_t optionsMask = commandData.optionsMask; uint8_t optionsOverride = commandData.optionsOverride; EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; uint8_t isColorLoopActive = 0; uint8_t deactiveColorLoop = 0; ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState(endpoint); - VerifyOrExit(colorHueTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint); if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -1555,13 +1570,13 @@ bool ColorControlServer::colorLoopCommand(const app::ConcreteCommandPath & comma } else { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_MALFORMED_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidAction); return true; } } exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -1695,7 +1710,7 @@ EmberEventControl * ColorControlServer::configureXYEventControl(EndpointId endpo return controller; } -bool ColorControlServer::moveToColorCommand(const app::ConcreteCommandPath & commandPath, +bool ColorControlServer::moveToColorCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveToColor::DecodableType & commandData) { uint16_t colorX = commandData.colorX; @@ -1704,17 +1719,17 @@ bool ColorControlServer::moveToColorCommand(const app::ConcreteCommandPath & com uint8_t optionsMask = commandData.optionsMask; uint8_t optionsOverride = commandData.optionsOverride; EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; Color16uTransitionState * colorXTransitionState = getXTransitionState(endpoint); Color16uTransitionState * colorYTransitionState = getYTransitionState(endpoint); - VerifyOrExit(colorXTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); - VerifyOrExit(colorYTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrExit(colorXTransitionState != nullptr, status = Status::UnsupportedEndpoint); + VerifyOrExit(colorYTransitionState != nullptr, status = Status::UnsupportedEndpoint); if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -1754,11 +1769,11 @@ bool ColorControlServer::moveToColorCommand(const app::ConcreteCommandPath & com emberEventControlSetDelayMS(configureXYEventControl(endpoint), UPDATE_TIME_MS); exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } -bool ColorControlServer::moveColorCommand(const app::ConcreteCommandPath & commandPath, +bool ColorControlServer::moveColorCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveColor::DecodableType & commandData) { int16_t rateX = commandData.rateX; @@ -1766,17 +1781,17 @@ bool ColorControlServer::moveColorCommand(const app::ConcreteCommandPath & comma uint8_t optionsMask = commandData.optionsMask; uint8_t optionsOverride = commandData.optionsOverride; EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; Color16uTransitionState * colorXTransitionState = getXTransitionState(endpoint); Color16uTransitionState * colorYTransitionState = getYTransitionState(endpoint); - VerifyOrExit(colorXTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); - VerifyOrExit(colorYTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrExit(colorXTransitionState != nullptr, status = Status::UnsupportedEndpoint); + VerifyOrExit(colorYTransitionState != nullptr, status = Status::UnsupportedEndpoint); if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -1788,7 +1803,7 @@ bool ColorControlServer::moveColorCommand(const app::ConcreteCommandPath & comma if (rateX == 0 && rateY == 0) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -1847,11 +1862,11 @@ bool ColorControlServer::moveColorCommand(const app::ConcreteCommandPath & comma emberEventControlSetDelayMS(configureXYEventControl(endpoint), UPDATE_TIME_MS); exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } -bool ColorControlServer::stepColorCommand(const app::ConcreteCommandPath & commandPath, +bool ColorControlServer::stepColorCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::StepColor::DecodableType & commandData) { int16_t stepX = commandData.stepX; @@ -1865,17 +1880,17 @@ bool ColorControlServer::stepColorCommand(const app::ConcreteCommandPath & comma uint16_t colorX = 0; uint16_t colorY = 0; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; Color16uTransitionState * colorXTransitionState = getXTransitionState(endpoint); Color16uTransitionState * colorYTransitionState = getYTransitionState(endpoint); - VerifyOrExit(colorXTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); - VerifyOrExit(colorYTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrExit(colorXTransitionState != nullptr, status = Status::UnsupportedEndpoint); + VerifyOrExit(colorYTransitionState != nullptr, status = Status::UnsupportedEndpoint); if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -1921,7 +1936,7 @@ bool ColorControlServer::stepColorCommand(const app::ConcreteCommandPath & comma emberEventControlSetDelayMS(configureXYEventControl(endpoint), UPDATE_TIME_MS); exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -1989,12 +2004,12 @@ ColorControlServer::Color16uTransitionState * ColorControlServer::getTempTransit * @param colorTemperature * @param transitionTime */ -EmberAfStatus ColorControlServer::moveToColorTemp(EndpointId aEndpoint, uint16_t colorTemperature, uint16_t transitionTime) +Status ColorControlServer::moveToColorTemp(EndpointId aEndpoint, uint16_t colorTemperature, uint16_t transitionTime) { EndpointId endpoint = aEndpoint; Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint); - VerifyOrReturnError(colorTempTransitionState != nullptr, EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrReturnError(colorTempTransitionState != nullptr, Status::UnsupportedEndpoint); uint16_t temperatureMin = MIN_TEMPERATURE_VALUE; Attributes::ColorTempPhysicalMinMireds::Get(endpoint, &temperatureMin); @@ -2036,7 +2051,7 @@ EmberAfStatus ColorControlServer::moveToColorTemp(EndpointId aEndpoint, uint16_t // kick off the state machine emberEventControlSetDelayMS(configureTempEventControl(endpoint), UPDATE_TIME_MS); - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } /** @@ -2169,7 +2184,7 @@ void ColorControlServer::updateTempCommand(EndpointId endpoint) * @return true * @return false */ -bool ColorControlServer::moveColorTempCommand(const app::ConcreteCommandPath & commandPath, +bool ColorControlServer::moveColorTempCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveColorTemperature::DecodableType & commandData) { uint8_t moveMode = commandData.moveMode; @@ -2179,17 +2194,17 @@ bool ColorControlServer::moveColorTempCommand(const app::ConcreteCommandPath & c uint8_t optionsMask = commandData.optionsMask; uint8_t optionsOverride = commandData.optionsOverride; EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE; uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE; uint16_t transitionTime; Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint); - VerifyOrExit(colorTempTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrExit(colorTempTransitionState != nullptr, status = Status::UnsupportedEndpoint); if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -2201,13 +2216,13 @@ bool ColorControlServer::moveColorTempCommand(const app::ConcreteCommandPath & c if (moveMode == MOVE_MODE_STOP) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } if (rate == 0) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return true; } @@ -2263,11 +2278,11 @@ bool ColorControlServer::moveColorTempCommand(const app::ConcreteCommandPath & c emberEventControlSetDelayMS(configureTempEventControl(endpoint), UPDATE_TIME_MS); exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } -bool ColorControlServer::moveToColorTempCommand(const app::ConcreteCommandPath & commandPath, +bool ColorControlServer::moveToColorTempCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveToColorTemperature::DecodableType & commandData) { uint16_t colorTemperature = commandData.colorTemperatureMireds; @@ -2278,17 +2293,17 @@ bool ColorControlServer::moveToColorTempCommand(const app::ConcreteCommandPath & if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } - EmberAfStatus error = moveToColorTemp(endpoint, colorTemperature, transitionTime); + Status error = moveToColorTemp(endpoint, colorTemperature, transitionTime); - emberAfSendImmediateDefaultResponse(error); + commandObj->AddStatus(commandPath, error); return true; } -bool ColorControlServer::stepColorTempCommand(const app::ConcreteCommandPath & commandPath, +bool ColorControlServer::stepColorTempCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::StepColorTemperature::DecodableType & commandData) { uint8_t stepMode = commandData.stepMode; @@ -2299,16 +2314,16 @@ bool ColorControlServer::stepColorTempCommand(const app::ConcreteCommandPath & c uint8_t optionsMask = commandData.optionsMask; uint8_t optionsOverride = commandData.optionsOverride; EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE; uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE; Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint); - VerifyOrExit(colorTempTransitionState != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); + VerifyOrExit(colorTempTransitionState != nullptr, status = Status::UnsupportedEndpoint); if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -2325,7 +2340,7 @@ bool ColorControlServer::stepColorTempCommand(const app::ConcreteCommandPath & c if (stepMode == MOVE_MODE_STOP) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -2382,7 +2397,7 @@ bool ColorControlServer::stepColorTempCommand(const app::ConcreteCommandPath & c emberEventControlSetDelayMS(configureTempEventControl(endpoint), UPDATE_TIME_MS); exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -2477,7 +2492,7 @@ void ColorControlServer::levelControlColorTempChangeCommand(EndpointId endpoint) bool emberAfColorControlClusterMoveHueCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveHue::DecodableType & commandData) { - return ColorControlServer::Instance().moveHueCommand(commandPath.mEndpointId, commandData.moveMode, commandData.rate, + return ColorControlServer::Instance().moveHueCommand(commandObj, commandPath, commandData.moveMode, commandData.rate, commandData.optionsMask, commandData.optionsOverride, false); } @@ -2486,13 +2501,13 @@ bool emberAfColorControlClusterMoveSaturationCallback(app::CommandHandler * comm const Commands::MoveSaturation::DecodableType & commandData) { - return ColorControlServer::Instance().moveSaturationCommand(commandPath, commandData); + return ColorControlServer::Instance().moveSaturationCommand(commandObj, commandPath, commandData); } bool emberAfColorControlClusterMoveToHueCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveToHue::DecodableType & commandData) { - return ColorControlServer::Instance().moveToHueCommand(commandPath.mEndpointId, commandData.hue, commandData.direction, + return ColorControlServer::Instance().moveToHueCommand(commandObj, commandPath, commandData.hue, commandData.direction, commandData.transitionTime, commandData.optionsMask, commandData.optionsOverride, false); } @@ -2501,7 +2516,7 @@ bool emberAfColorControlClusterMoveToSaturationCallback(app::CommandHandler * co const app::ConcreteCommandPath & commandPath, const Commands::MoveToSaturation::DecodableType & commandData) { - return ColorControlServer::Instance().moveToSaturationCommand(commandPath, commandData); + return ColorControlServer::Instance().moveToSaturationCommand(commandObj, commandPath, commandData); } bool emberAfColorControlClusterMoveToHueAndSaturationCallback(app::CommandHandler * commandObj, @@ -2509,14 +2524,14 @@ bool emberAfColorControlClusterMoveToHueAndSaturationCallback(app::CommandHandle const Commands::MoveToHueAndSaturation::DecodableType & commandData) { return ColorControlServer::Instance().moveToHueAndSaturationCommand( - commandPath.mEndpointId, commandData.hue, commandData.saturation, commandData.transitionTime, commandData.optionsMask, + commandObj, commandPath, commandData.hue, commandData.saturation, commandData.transitionTime, commandData.optionsMask, commandData.optionsOverride, false); } bool emberAfColorControlClusterStepHueCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::StepHue::DecodableType & commandData) { - return ColorControlServer::Instance().stepHueCommand(commandPath.mEndpointId, commandData.stepMode, commandData.stepSize, + return ColorControlServer::Instance().stepHueCommand(commandObj, commandPath, commandData.stepMode, commandData.stepSize, commandData.transitionTime, commandData.optionsMask, commandData.optionsOverride, false); } @@ -2525,14 +2540,14 @@ bool emberAfColorControlClusterStepSaturationCallback(app::CommandHandler * comm const app::ConcreteCommandPath & commandPath, const Commands::StepSaturation::DecodableType & commandData) { - return ColorControlServer::Instance().stepSaturationCommand(commandPath, commandData); + return ColorControlServer::Instance().stepSaturationCommand(commandObj, commandPath, commandData); } bool emberAfColorControlClusterEnhancedMoveHueCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::EnhancedMoveHue::DecodableType & commandData) { - return ColorControlServer::Instance().moveHueCommand(commandPath.mEndpointId, commandData.moveMode, commandData.rate, + return ColorControlServer::Instance().moveHueCommand(commandObj, commandPath, commandData.moveMode, commandData.rate, commandData.optionsMask, commandData.optionsOverride, true); } @@ -2540,7 +2555,7 @@ bool emberAfColorControlClusterEnhancedMoveToHueCallback(app::CommandHandler * c const app::ConcreteCommandPath & commandPath, const Commands::EnhancedMoveToHue::DecodableType & commandData) { - return ColorControlServer::Instance().moveToHueCommand(commandPath.mEndpointId, commandData.enhancedHue, commandData.direction, + return ColorControlServer::Instance().moveToHueCommand(commandObj, commandPath, commandData.enhancedHue, commandData.direction, commandData.transitionTime, commandData.optionsMask, commandData.optionsOverride, true); } @@ -2549,7 +2564,7 @@ bool emberAfColorControlClusterEnhancedMoveToHueAndSaturationCallback( app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::EnhancedMoveToHueAndSaturation::DecodableType & commandData) { - return ColorControlServer::Instance().moveToHueAndSaturationCommand(commandPath.mEndpointId, commandData.enhancedHue, + return ColorControlServer::Instance().moveToHueAndSaturationCommand(commandObj, commandPath, commandData.enhancedHue, commandData.saturation, commandData.transitionTime, commandData.optionsMask, commandData.optionsOverride, true); } @@ -2558,7 +2573,7 @@ bool emberAfColorControlClusterEnhancedStepHueCallback(app::CommandHandler * com const app::ConcreteCommandPath & commandPath, const Commands::EnhancedStepHue::DecodableType & commandData) { - return ColorControlServer::Instance().stepHueCommand(commandPath.mEndpointId, commandData.stepMode, commandData.stepSize, + return ColorControlServer::Instance().stepHueCommand(commandObj, commandPath, commandData.stepMode, commandData.stepSize, commandData.transitionTime, commandData.optionsMask, commandData.optionsOverride, true); } @@ -2566,7 +2581,7 @@ bool emberAfColorControlClusterEnhancedStepHueCallback(app::CommandHandler * com bool emberAfColorControlClusterColorLoopSetCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::ColorLoopSet::DecodableType & commandData) { - return ColorControlServer::Instance().colorLoopCommand(commandPath, commandData); + return ColorControlServer::Instance().colorLoopCommand(commandObj, commandPath, commandData); } #endif // EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_HSV @@ -2576,19 +2591,19 @@ bool emberAfColorControlClusterColorLoopSetCallback(app::CommandHandler * comman bool emberAfColorControlClusterMoveToColorCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveToColor::DecodableType & commandData) { - return ColorControlServer::Instance().moveToColorCommand(commandPath, commandData); + return ColorControlServer::Instance().moveToColorCommand(commandObj, commandPath, commandData); } bool emberAfColorControlClusterMoveColorCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveColor::DecodableType & commandData) { - return ColorControlServer::Instance().moveColorCommand(commandPath, commandData); + return ColorControlServer::Instance().moveColorCommand(commandObj, commandPath, commandData); } bool emberAfColorControlClusterStepColorCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::StepColor::DecodableType & commandData) { - return ColorControlServer::Instance().stepColorCommand(commandPath, commandData); + return ColorControlServer::Instance().stepColorCommand(commandObj, commandPath, commandData); } #endif // EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_XY @@ -2599,21 +2614,21 @@ bool emberAfColorControlClusterMoveToColorTemperatureCallback(app::CommandHandle const app::ConcreteCommandPath & commandPath, const Commands::MoveToColorTemperature::DecodableType & commandData) { - return ColorControlServer::Instance().moveToColorTempCommand(commandPath, commandData); + return ColorControlServer::Instance().moveToColorTempCommand(commandObj, commandPath, commandData); } bool emberAfColorControlClusterMoveColorTemperatureCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveColorTemperature::DecodableType & commandData) { - return ColorControlServer::Instance().moveColorTempCommand(commandPath, commandData); + return ColorControlServer::Instance().moveColorTempCommand(commandObj, commandPath, commandData); } bool emberAfColorControlClusterStepColorTemperatureCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::StepColorTemperature::DecodableType & commandData) { - return ColorControlServer::Instance().stepColorTempCommand(commandPath, commandData); + return ColorControlServer::Instance().stepColorTempCommand(commandObj, commandPath, commandData); } void emberAfPluginLevelControlCoupledColorTempChangeCallback(EndpointId endpoint) @@ -2626,7 +2641,7 @@ void emberAfPluginLevelControlCoupledColorTempChangeCallback(EndpointId endpoint bool emberAfColorControlClusterStopMoveStepCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::StopMoveStep::DecodableType & commandData) { - return ColorControlServer::Instance().stopMoveStepCommand(commandPath.mEndpointId, commandData.optionsMask, + return ColorControlServer::Instance().stopMoveStepCommand(commandObj, commandPath, commandData.optionsMask, commandData.optionsOverride); } diff --git a/src/app/clusters/color-control-server/color-control-server.h b/src/app/clusters/color-control-server/color-control-server.h index 22cb14e28f10c0..cae5d9829df301 100644 --- a/src/app/clusters/color-control-server/color-control-server.h +++ b/src/app/clusters/color-control-server/color-control-server.h @@ -18,9 +18,11 @@ #pragma once #include +#include #include #include #include +#include /********************************************************** * Defines and Macros @@ -129,46 +131,50 @@ class ColorControlServer static ColorControlServer & Instance(); bool HasFeature(chip::EndpointId endpoint, ColorControlFeature feature); - EmberAfStatus stopAllColorTransitions(chip::EndpointId endpoint); - bool stopMoveStepCommand(chip::EndpointId, uint8_t optionsMask, uint8_t optionsOverride); + chip::Protocols::InteractionModel::Status stopAllColorTransitions(chip::EndpointId endpoint); + bool stopMoveStepCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + uint8_t optionsMask, uint8_t optionsOverride); #ifdef EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_HSV - bool moveHueCommand(chip::EndpointId endpoint, uint8_t moveMode, uint16_t rate, uint8_t optionsMask, uint8_t optionsOverride, + bool moveHueCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + uint8_t moveMode, uint16_t rate, uint8_t optionsMask, uint8_t optionsOverride, bool isEnhanced); + bool moveToHueCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, uint16_t hue, + uint8_t hueMoveMode, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride, + bool isEnhanced); + bool moveToHueAndSaturationCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + uint16_t hue, uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, + uint8_t optionsOverride, bool isEnhanced); + bool stepHueCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + uint8_t stepMode, uint16_t stepSize, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride, bool isEnhanced); - bool moveToHueCommand(chip::EndpointId endpoint, uint16_t hue, uint8_t hueMoveMode, uint16_t transitionTime, - uint8_t optionsMask, uint8_t optionsOverride, bool isEnhanced); - bool moveToHueAndSaturationCommand(chip::EndpointId endpoint, uint16_t hue, uint8_t saturation, uint16_t transitionTime, - uint8_t optionsMask, uint8_t optionsOverride, bool isEnhanced); - bool stepHueCommand(chip::EndpointId endpoint, uint8_t stepMode, uint16_t stepSize, uint16_t transitionTime, - uint8_t optionsMask, uint8_t optionsOverride, bool isEnhanced); - bool moveSaturationCommand(const chip::app::ConcreteCommandPath & commandPath, + bool moveSaturationCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::ColorControl::Commands::MoveSaturation::DecodableType & commandData); - bool moveToSaturationCommand(const chip::app::ConcreteCommandPath & commandPath, + bool moveToSaturationCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::ColorControl::Commands::MoveToSaturation::DecodableType & commandData); - bool stepSaturationCommand(const chip::app::ConcreteCommandPath & commandPath, + bool stepSaturationCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::ColorControl::Commands::StepSaturation::DecodableType & commandData); - bool colorLoopCommand(const chip::app::ConcreteCommandPath & commandPath, + bool colorLoopCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::ColorControl::Commands::ColorLoopSet::DecodableType & commandData); void updateHueSatCommand(chip::EndpointId endpoint); #endif // EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_HSV #ifdef EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_XY - bool moveToColorCommand(const chip::app::ConcreteCommandPath & commandPath, + bool moveToColorCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::ColorControl::Commands::MoveToColor::DecodableType & commandData); - bool moveColorCommand(const chip::app::ConcreteCommandPath & commandPath, + bool moveColorCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::ColorControl::Commands::MoveColor::DecodableType & commandData); - bool stepColorCommand(const chip::app::ConcreteCommandPath & commandPath, + bool stepColorCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::ColorControl::Commands::StepColor::DecodableType & commandData); void updateXYCommand(chip::EndpointId endpoint); #endif // EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_XY #ifdef EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP - bool moveColorTempCommand(const chip::app::ConcreteCommandPath & commandPath, + bool moveColorTempCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::ColorControl::Commands::MoveColorTemperature::DecodableType & commandData); bool - moveToColorTempCommand(const chip::app::ConcreteCommandPath & commandPath, + moveToColorTempCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::ColorControl::Commands::MoveToColorTemperature::DecodableType & commandData); - bool stepColorTempCommand(const chip::app::ConcreteCommandPath & commandPath, + bool stepColorTempCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::ColorControl::Commands::StepColorTemperature::DecodableType & commandData); void levelControlColorTempChangeCommand(chip::EndpointId endpoint); void startUpColorTempCommand(chip::EndpointId endpoint); @@ -216,7 +222,8 @@ class ColorControlServer #ifdef EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP Color16uTransitionState * getTempTransitionState(chip::EndpointId endpoint); - EmberAfStatus moveToColorTemp(chip::EndpointId aEndpoint, uint16_t colorTemperature, uint16_t transitionTime); + chip::Protocols::InteractionModel::Status moveToColorTemp(chip::EndpointId aEndpoint, uint16_t colorTemperature, + uint16_t transitionTime); uint16_t getTemperatureCoupleToLevelMin(chip::EndpointId endpoint); EmberEventControl * configureTempEventControl(chip::EndpointId); #endif // EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP diff --git a/src/app/clusters/content-launch-server/content-launch-server.cpp b/src/app/clusters/content-launch-server/content-launch-server.cpp index e7f6ef6dbb8d34..e1cbd1af2c888c 100644 --- a/src/app/clusters/content-launch-server/content-launch-server.cpp +++ b/src/app/clusters/content-launch-server/content-launch-server.cpp @@ -39,6 +39,7 @@ using namespace chip::app::Clusters::ContentLauncher; #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED using namespace chip::AppPlatform; #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED +using chip::Protocols::InteractionModel::Status; static constexpr size_t kContentLaunchDelegateTableSize = EMBER_AF_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; @@ -220,7 +221,7 @@ bool emberAfContentLauncherClusterLaunchContentCallback(CommandHandler * command // If isDelegateNull, no one will call responder, so HasSentResponse will be false if (!responder.HasSentResponse()) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); } return true; @@ -256,7 +257,7 @@ bool emberAfContentLauncherClusterLaunchURLCallback(CommandHandler * commandObj, // If isDelegateNull, no one will call responder, so HasSentResponse will be false if (!responder.HasSentResponse()) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); } return true; diff --git a/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp b/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp index 8a7b1736ac96af..2965beff147d3b 100644 --- a/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp +++ b/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp @@ -111,9 +111,7 @@ bool emberAfDiagnosticLogsClusterRetrieveLogsRequestCallback( chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsRequest::DecodableType & commandData) { - // TODO: Shouldn't the default "no-op" impl return some sort of error? - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, chip::Protocols::InteractionModel::Status::UnsupportedCommand); return true; } diff --git a/src/app/clusters/door-lock-server/door-lock-server.cpp b/src/app/clusters/door-lock-server/door-lock-server.cpp index 4e4cf02c5e0872..197f105d13897a 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.cpp +++ b/src/app/clusters/door-lock-server/door-lock-server.cpp @@ -41,6 +41,7 @@ using namespace chip; using namespace chip::app; using namespace chip::app::DataModel; using namespace chip::app::Clusters::DoorLock; +using chip::Protocols::InteractionModel::Status; static constexpr uint8_t DOOR_LOCK_SCHEDULE_MAX_HOUR = 23; static constexpr uint8_t DOOR_LOCK_SCHEDULE_MAX_MINUTE = 59; @@ -422,7 +423,7 @@ void DoorLockServer::getUserCommandHandler(chip::app::CommandHandler * commandOb if (!SupportsUSR(commandPath.mEndpointId)) { emberAfDoorLockClusterPrintln("[GetUser] User management is not supported [endpointId=%d]", commandPath.mEndpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND); + commandObj->AddStatus(commandPath, Status::UnsupportedCommand); return; } @@ -431,7 +432,7 @@ void DoorLockServer::getUserCommandHandler(chip::app::CommandHandler * commandOb { emberAfDoorLockClusterPrintln("[GetUser] User index out of bounds [userIndex=%d,numberOfTotalUsersSupported=%d]", userIndex, maxNumberOfUsers); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -512,7 +513,7 @@ void DoorLockServer::getUserCommandHandler(chip::app::CommandHandler * commandOb { ChipLogError(Zcl, "[GetUser] Command processing failed [endpointId=%d,userIndex=%d,err=\"%s\"]", commandPath.mEndpointId, userIndex, err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); } } @@ -524,7 +525,7 @@ void DoorLockServer::clearUserCommandHandler(chip::app::CommandHandler * command if (!SupportsUSR(commandPath.mEndpointId)) { emberAfDoorLockClusterPrintln("[ClearUser] User management is not supported [endpointId=%d]", commandPath.mEndpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND); + commandObj->AddStatus(commandPath, Status::UnsupportedCommand); return; } @@ -533,7 +534,7 @@ void DoorLockServer::clearUserCommandHandler(chip::app::CommandHandler * command { ChipLogError(Zcl, "[ClearUser] Unable to get the fabric IDX [endpointId=%d,userIndex=%d]", commandPath.mEndpointId, userIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -542,7 +543,7 @@ void DoorLockServer::clearUserCommandHandler(chip::app::CommandHandler * command { ChipLogError(Zcl, "[ClearUser] Unable to get the source node index [endpointId=%d,userIndex=%d]", commandPath.mEndpointId, userIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -551,19 +552,19 @@ void DoorLockServer::clearUserCommandHandler(chip::app::CommandHandler * command { emberAfDoorLockClusterPrintln("[ClearUser] User index out of bounds [userIndex=%d,numberOfTotalUsersSupported=%d]", userIndex, maxNumberOfUsers); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } if (0xFFFE != userIndex) { auto status = clearUser(commandPath.mEndpointId, fabricIdx, sourceNodeId, userIndex, true); - if (EMBER_ZCL_STATUS_SUCCESS != status) + if (Status::Success != status) { ChipLogError(Zcl, "[ClearUser] App reported failure when resetting the user [userIndex=%d,status=0x%x]", userIndex, - status); + to_underlying(status)); } - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return; } @@ -571,11 +572,12 @@ void DoorLockServer::clearUserCommandHandler(chip::app::CommandHandler * command for (uint16_t i = 1; i <= maxNumberOfUsers; ++i) { auto status = clearUser(commandPath.mEndpointId, fabricIdx, sourceNodeId, i, false); - if (EMBER_ZCL_STATUS_SUCCESS != status) + if (Status::Success != status) { - ChipLogError(Zcl, "[ClearUser] App reported failure when resetting the user [userIndex=%d,status=0x%x]", i, status); + ChipLogError(Zcl, "[ClearUser] App reported failure when resetting the user [userIndex=%d,status=0x%x]", i, + to_underlying(status)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } } @@ -584,7 +586,7 @@ void DoorLockServer::clearUserCommandHandler(chip::app::CommandHandler * command sendRemoteLockUserChange(commandPath.mEndpointId, LockDataTypeEnum::kUserIndex, DataOperationTypeEnum::kClear, sourceNodeId, fabricIdx, 0xFFFE, 0xFFFE); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); } void DoorLockServer::setCredentialCommandHandler( @@ -597,7 +599,7 @@ void DoorLockServer::setCredentialCommandHandler( if (kUndefinedFabricIndex == fabricIdx) { ChipLogError(Zcl, "[SetCredential] Unable to get the fabric IDX [endpointId=%d]", commandPath.mEndpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -605,7 +607,7 @@ void DoorLockServer::setCredentialCommandHandler( if (chip::kUndefinedNodeId == sourceNodeId) { ChipLogError(Zcl, "[SetCredential] Unable to get the source node index [endpointId=%d]", commandPath.mEndpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -621,7 +623,7 @@ void DoorLockServer::setCredentialCommandHandler( { emberAfDoorLockClusterPrintln("[SetCredential] Credential type is not supported [endpointId=%d,credentialType=%u]", commandPath.mEndpointId, to_underlying(credentialType)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND); + commandObj->AddStatus(commandPath, Status::UnsupportedCommand); return; } @@ -757,7 +759,7 @@ void DoorLockServer::getCredentialStatusCommandHandler(chip::app::CommandHandler emberAfDoorLockClusterPrintln("[GetCredentialStatus] Credential type is not supported [endpointId=%d,credentialType=%u" "]", commandPath.mEndpointId, to_underlying(credentialType)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND); + commandObj->AddStatus(commandPath, Status::UnsupportedCommand); return; } @@ -775,7 +777,7 @@ void DoorLockServer::getCredentialStatusCommandHandler(chip::app::CommandHandler "[endpointId=%d,credentialIndex=%d,credentialType=%u,creator=%u,modifier=%u]", commandPath.mEndpointId, credentialIndex, to_underlying(credentialType), credentialInfo.createdBy, credentialInfo.lastModifiedBy); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -791,7 +793,7 @@ void DoorLockServer::getCredentialStatusCommandHandler(chip::app::CommandHandler "[GetCredentialStatus] Database possibly corrupted - credential exists without user assigned " "[endpointId=%d,credentialType=%u,credentialIndex=%d]", commandPath.mEndpointId, to_underlying(credentialType), credentialIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } } @@ -849,14 +851,14 @@ void DoorLockServer::clearCredentialCommandHandler( auto modifier = getFabricIndex(commandObj); if (kUndefinedFabricIndex == modifier) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } auto sourceNodeId = getNodeId(commandObj); if (chip::kUndefinedNodeId == sourceNodeId) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -864,7 +866,7 @@ void DoorLockServer::clearCredentialCommandHandler( if (credential.IsNull()) { emberAfDoorLockClusterPrintln("[ClearCredential] Clearing all credentials [endpointId=%d]", commandPath.mEndpointId); - emberAfSendImmediateDefaultResponse(clearCredentials(commandPath.mEndpointId, modifier, sourceNodeId)); + commandObj->AddStatus(commandPath, clearCredentials(commandPath.mEndpointId, modifier, sourceNodeId)); return; } @@ -873,12 +875,12 @@ void DoorLockServer::clearCredentialCommandHandler( auto credentialIndex = credential.Value().credentialIndex; if (0xFFFE == credentialIndex) { - emberAfSendImmediateDefaultResponse(clearCredentials(commandPath.mEndpointId, modifier, sourceNodeId, credentialType)); + commandObj->AddStatus(commandPath, clearCredentials(commandPath.mEndpointId, modifier, sourceNodeId, credentialType)); return; } - emberAfSendImmediateDefaultResponse( - clearCredential(commandPath.mEndpointId, modifier, sourceNodeId, credentialType, credentialIndex, false)); + commandObj->AddStatus(commandPath, + clearCredential(commandPath.mEndpointId, modifier, sourceNodeId, credentialType, credentialIndex, false)); } void DoorLockServer::setWeekDayScheduleCommandHandler(chip::app::CommandHandler * commandObj, @@ -890,7 +892,7 @@ void DoorLockServer::setWeekDayScheduleCommandHandler(chip::app::CommandHandler if (!SupportsWeekDaySchedules(endpointId)) { emberAfDoorLockClusterPrintln("[SetWeekDaySchedule] Ignore command (not supported) [endpointId=%d]", endpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -900,7 +902,7 @@ void DoorLockServer::setWeekDayScheduleCommandHandler(chip::app::CommandHandler if (kUndefinedFabricIndex == fabricIdx) { ChipLogError(Zcl, "[SetWeekDaySchedule] Unable to get the fabric IDX [endpointId=%d]", commandPath.mEndpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -908,7 +910,7 @@ void DoorLockServer::setWeekDayScheduleCommandHandler(chip::app::CommandHandler if (chip::kUndefinedNodeId == sourceNodeId) { ChipLogError(Zcl, "[SetWeekDaySchedule] Unable to get the source node index [endpointId=%d]", commandPath.mEndpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -917,7 +919,7 @@ void DoorLockServer::setWeekDayScheduleCommandHandler(chip::app::CommandHandler emberAfDoorLockClusterPrintln( "[SetWeekDaySchedule] Unable to add schedule - index out of range [endpointId=%d,weekDayIndex=%d,userIndex=%d]", endpointId, weekDayIndex, userIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -926,7 +928,7 @@ void DoorLockServer::setWeekDayScheduleCommandHandler(chip::app::CommandHandler emberAfDoorLockClusterPrintln("[SetWeekDaySchedule] Unable to add schedule - user does not exist " "[endpointId=%d,weekDayIndex=%d,userIndex=%d]", endpointId, weekDayIndex, userIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -945,7 +947,7 @@ void DoorLockServer::setWeekDayScheduleCommandHandler(chip::app::CommandHandler emberAfDoorLockClusterPrintln("[SetWeekDaySchedule] Unable to add schedule - daysMask is out of range " "[endpointId=%d,weekDayIndex=%d,userIndex=%d,daysMask=%x]", endpointId, weekDayIndex, userIndex, daysMask.Raw()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -955,7 +957,7 @@ void DoorLockServer::setWeekDayScheduleCommandHandler(chip::app::CommandHandler emberAfDoorLockClusterPrintln("[SetWeekDaySchedule] Unable to add schedule - start time out of range " "[endpointId=%d,weekDayIndex=%d,userIndex=%d,startTime=\"%d:%d\",endTime=\"%d:%d\"]", endpointId, weekDayIndex, userIndex, startHour, startMinute, endHour, endMinute); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -964,7 +966,7 @@ void DoorLockServer::setWeekDayScheduleCommandHandler(chip::app::CommandHandler emberAfDoorLockClusterPrintln("[SetWeekDaySchedule] Unable to add schedule - invalid time " "[endpointId=%d,weekDayIndex=%d,userIndex=%d,startTime=\"%d:%d\",endTime=\"%d:%d\"]", endpointId, weekDayIndex, userIndex, startHour, startMinute, endHour, endMinute); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -976,7 +978,7 @@ void DoorLockServer::setWeekDayScheduleCommandHandler(chip::app::CommandHandler "[SetWeekDaySchedule] Unable to add schedule - internal error " "[endpointId=%d,weekDayIndex=%d,userIndex=%d,status=%u]", endpointId, weekDayIndex, userIndex, to_underlying(status)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -987,7 +989,7 @@ void DoorLockServer::setWeekDayScheduleCommandHandler(chip::app::CommandHandler sendRemoteLockUserChange(endpointId, LockDataTypeEnum::kWeekDaySchedule, DataOperationTypeEnum::kAdd, sourceNodeId, fabricIdx, userIndex, static_cast(weekDayIndex)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); } void DoorLockServer::getWeekDayScheduleCommandHandler(chip::app::CommandHandler * commandObj, @@ -998,7 +1000,7 @@ void DoorLockServer::getWeekDayScheduleCommandHandler(chip::app::CommandHandler if (!SupportsWeekDaySchedules(endpointId)) { emberAfDoorLockClusterPrintln("[GetWeekDaySchedule] Ignore command (not supported) [endpointId=%d]", endpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -1041,7 +1043,7 @@ void DoorLockServer::clearWeekDayScheduleCommandHandler(chip::app::CommandHandle if (!SupportsWeekDaySchedules(endpointId)) { emberAfDoorLockClusterPrintln("[ClearWeekDaySchedule] Ignore command (not supported) [endpointId=%d]", endpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -1051,7 +1053,7 @@ void DoorLockServer::clearWeekDayScheduleCommandHandler(chip::app::CommandHandle if (kUndefinedFabricIndex == fabricIdx) { ChipLogError(Zcl, "[ClearWeekDaySchedule] Unable to get the fabric IDX [endpointId=%d]", commandPath.mEndpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -1059,7 +1061,7 @@ void DoorLockServer::clearWeekDayScheduleCommandHandler(chip::app::CommandHandle if (chip::kUndefinedNodeId == sourceNodeId) { ChipLogError(Zcl, "[ClearWeekDaySchedule] Unable to get the source node index [endpointId=%d]", commandPath.mEndpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -1068,7 +1070,7 @@ void DoorLockServer::clearWeekDayScheduleCommandHandler(chip::app::CommandHandle emberAfDoorLockClusterPrintln( "[ClearWeekDaySchedule] User or WeekDay index is out of range [endpointId=%d,weekDayIndex=%d,userIndex=%d]", endpointId, weekDayIndex, userIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -1076,7 +1078,7 @@ void DoorLockServer::clearWeekDayScheduleCommandHandler(chip::app::CommandHandle { emberAfDoorLockClusterPrintln("[ClearWeekDaySchedule] User does not exist [endpointId=%d,weekDayIndex=%d,userIndex=%d]", endpointId, weekDayIndex, userIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -1100,14 +1102,14 @@ void DoorLockServer::clearWeekDayScheduleCommandHandler(chip::app::CommandHandle emberAfDoorLockClusterPrintln( "[ClearWeekDaySchedule] Unable to clear the user schedules - app error [endpointId=%d,userIndex=%d,status=%u]", endpointId, userIndex, to_underlying(clearStatus)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } sendRemoteLockUserChange(endpointId, LockDataTypeEnum::kWeekDaySchedule, DataOperationTypeEnum::kClear, sourceNodeId, fabricIdx, userIndex, static_cast(weekDayIndex)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); } void DoorLockServer::setYearDayScheduleCommandHandler(chip::app::CommandHandler * commandObj, @@ -1118,7 +1120,7 @@ void DoorLockServer::setYearDayScheduleCommandHandler(chip::app::CommandHandler if (!SupportsYearDaySchedules(endpointId)) { emberAfDoorLockClusterPrintln("[SetYearDaySchedule] Ignore command (not supported) [endpointId=%d]", endpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -1128,7 +1130,7 @@ void DoorLockServer::setYearDayScheduleCommandHandler(chip::app::CommandHandler if (kUndefinedFabricIndex == fabricIdx) { ChipLogError(Zcl, "[SetYearDaySchedule] Unable to get the fabric IDX [endpointId=%d]", commandPath.mEndpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -1136,7 +1138,7 @@ void DoorLockServer::setYearDayScheduleCommandHandler(chip::app::CommandHandler if (chip::kUndefinedNodeId == sourceNodeId) { ChipLogError(Zcl, "[SetYearDaySchedule] Unable to get the source node index [endpointId=%d]", commandPath.mEndpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -1145,7 +1147,7 @@ void DoorLockServer::setYearDayScheduleCommandHandler(chip::app::CommandHandler emberAfDoorLockClusterPrintln( "[SetYearDaySchedule] Unable to add schedule - index out of range [endpointId=%d,yearDayIndex=%d,userIndex=%d]", endpointId, yearDayIndex, userIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -1154,7 +1156,7 @@ void DoorLockServer::setYearDayScheduleCommandHandler(chip::app::CommandHandler emberAfDoorLockClusterPrintln("[SetYearDaySchedule] Unable to add schedule - user does not exist " "[endpointId=%d,yearDayIndex=%d,userIndex=%d]", endpointId, yearDayIndex, userIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -1164,7 +1166,7 @@ void DoorLockServer::setYearDayScheduleCommandHandler(chip::app::CommandHandler "[endpointId=%d,yearDayIndex=%d,userIndex=%d,localStarTime=%" PRIu32 ",localEndTime=%" PRIu32 "]", endpointId, yearDayIndex, userIndex, localStartTime, localEndTime); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -1176,7 +1178,7 @@ void DoorLockServer::setYearDayScheduleCommandHandler(chip::app::CommandHandler "[SetYearDaySchedule] Unable to add schedule - internal error " "[endpointId=%d,yearDayIndex=%d,userIndex=%d,status=%u]", endpointId, yearDayIndex, userIndex, to_underlying(status)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -1187,7 +1189,7 @@ void DoorLockServer::setYearDayScheduleCommandHandler(chip::app::CommandHandler sendRemoteLockUserChange(endpointId, LockDataTypeEnum::kYearDaySchedule, DataOperationTypeEnum::kAdd, sourceNodeId, fabricIdx, userIndex, static_cast(yearDayIndex)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); } void DoorLockServer::getYearDayScheduleCommandHandler(chip::app::CommandHandler * commandObj, @@ -1198,7 +1200,7 @@ void DoorLockServer::getYearDayScheduleCommandHandler(chip::app::CommandHandler if (!SupportsYearDaySchedules(endpointId)) { emberAfDoorLockClusterPrintln("[GetYearDaySchedule] Ignore command (not supported) [endpointId=%d]", endpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } emberAfDoorLockClusterPrintln("[GetYearDaySchedule] incoming command [endpointId=%d]", endpointId); @@ -1240,7 +1242,7 @@ void DoorLockServer::clearYearDayScheduleCommandHandler(chip::app::CommandHandle if (!SupportsYearDaySchedules(endpointId)) { emberAfDoorLockClusterPrintln("[ClearYearDaySchedule] Ignore command (not supported) [endpointId=%d]", endpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } emberAfDoorLockClusterPrintln("[ClearYearDaySchedule] incoming command [endpointId=%d]", endpointId); @@ -1249,7 +1251,7 @@ void DoorLockServer::clearYearDayScheduleCommandHandler(chip::app::CommandHandle if (kUndefinedFabricIndex == fabricIdx) { ChipLogError(Zcl, "[ClearYearDaySchedule] Unable to get the fabric IDX [endpointId=%d]", commandPath.mEndpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -1257,7 +1259,7 @@ void DoorLockServer::clearYearDayScheduleCommandHandler(chip::app::CommandHandle if (chip::kUndefinedNodeId == sourceNodeId) { ChipLogError(Zcl, "[ClearYearDaySchedule] Unable to get the source node index [endpointId=%d]", commandPath.mEndpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -1266,7 +1268,7 @@ void DoorLockServer::clearYearDayScheduleCommandHandler(chip::app::CommandHandle emberAfDoorLockClusterPrintln( "[ClearYearDaySchedule] User or YearDay index is out of range [endpointId=%d,yearDayIndex=%d,userIndex=%d]", endpointId, yearDayIndex, userIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -1274,7 +1276,7 @@ void DoorLockServer::clearYearDayScheduleCommandHandler(chip::app::CommandHandle { emberAfDoorLockClusterPrintln("[ClearYearDaySchedule] User does not exist [endpointId=%d,yearDayIndex=%d,userIndex=%d]", endpointId, yearDayIndex, userIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -1298,14 +1300,14 @@ void DoorLockServer::clearYearDayScheduleCommandHandler(chip::app::CommandHandle emberAfDoorLockClusterPrintln( "[ClearYearDaySchedule] Unable to clear the user schedules - app error [endpointId=%d,userIndex=%d,status=%u]", endpointId, userIndex, to_underlying(clearStatus)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } sendRemoteLockUserChange(endpointId, LockDataTypeEnum::kYearDaySchedule, DataOperationTypeEnum::kClear, sourceNodeId, fabricIdx, userIndex, static_cast(yearDayIndex)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); } chip::BitFlags DoorLockServer::GetFeatures(chip::EndpointId endpointId) @@ -1883,20 +1885,20 @@ EmberAfStatus DoorLockServer::modifyUser(chip::EndpointId endpointId, chip::Fabr return EMBER_ZCL_STATUS_SUCCESS; } -EmberAfStatus DoorLockServer::clearUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricId, chip::NodeId sourceNodeId, - uint16_t userIndex, bool sendUserChangeEvent) +Status DoorLockServer::clearUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricId, chip::NodeId sourceNodeId, + uint16_t userIndex, bool sendUserChangeEvent) { EmberAfPluginDoorLockUserInfo user; if (!emberAfPluginDoorLockGetUser(endpointId, userIndex, user)) { - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } return clearUser(endpointId, modifierFabricId, sourceNodeId, userIndex, user, sendUserChangeEvent); } -EmberAfStatus DoorLockServer::clearUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricId, chip::NodeId sourceNodeId, - uint16_t userIndex, const EmberAfPluginDoorLockUserInfo & user, bool sendUserChangeEvent) +Status DoorLockServer::clearUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricId, chip::NodeId sourceNodeId, + uint16_t userIndex, const EmberAfPluginDoorLockUserInfo & user, bool sendUserChangeEvent) { // appclusters, 5.2.4.37: all the credentials associated with user should be cleared when clearing the user for (const auto & credential : user.credentials) @@ -1913,7 +1915,7 @@ EmberAfStatus DoorLockServer::clearUser(chip::EndpointId endpointId, chip::Fabri "[ClearUser] Unable to remove credentials associated with user - internal error " "[endpointId=%d,userIndex=%d,credentialIndex=%d,credentialType=%u]", endpointId, userIndex, credential.CredentialIndex, credential.CredentialType); - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } } @@ -1923,6 +1925,8 @@ EmberAfStatus DoorLockServer::clearUser(chip::EndpointId endpointId, chip::Fabri { ChipLogError(Zcl, "[ClearUser] Unable to delete schedules - internal error [endpointId=%d,userIndex=%d]", endpointId, userIndex); + // TODO: Figure out whether this should still clear the user even though + // schedule clearing failed? } // Remove the user entry @@ -1930,7 +1934,7 @@ EmberAfStatus DoorLockServer::clearUser(chip::EndpointId endpointId, chip::Fabri UserStatusEnum::kAvailable, UserTypeEnum::kUnrestrictedUser, CredentialRuleEnum::kSingle, nullptr, 0)) { - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } if (sendUserChangeEvent) @@ -1938,7 +1942,7 @@ EmberAfStatus DoorLockServer::clearUser(chip::EndpointId endpointId, chip::Fabri sendRemoteLockUserChange(endpointId, LockDataTypeEnum::kUserIndex, DataOperationTypeEnum::kClear, sourceNodeId, modifierFabricId, userIndex, userIndex); } - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } bool DoorLockServer::clearFabricFromUsers(chip::EndpointId endpointId, chip::FabricIndex fabricIndex) @@ -2648,15 +2652,15 @@ void DoorLockServer::sendHolidayScheduleResponse(chip::app::CommandHandler * com commandObj->AddResponse(commandPath, response); } -EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip::FabricIndex modifier, chip::NodeId sourceNodeId, - CredentialTypeEnum credentialType, uint16_t credentialIndex, bool sendUserChangeEvent) +Status DoorLockServer::clearCredential(chip::EndpointId endpointId, chip::FabricIndex modifier, chip::NodeId sourceNodeId, + CredentialTypeEnum credentialType, uint16_t credentialIndex, bool sendUserChangeEvent) { if (CredentialTypeEnum::kProgrammingPIN == credentialType) { emberAfDoorLockClusterPrintln("[clearCredential] Cannot clear programming PIN credentials " "[endpointId=%d,credentialType=%u,credentialIndex=%d,modifier=%d]", endpointId, to_underlying(credentialType), credentialIndex, modifier); - return EMBER_ZCL_STATUS_INVALID_COMMAND; + return Status::InvalidCommand; } if (!credentialIndexValid(endpointId, credentialType, credentialIndex)) @@ -2664,7 +2668,7 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip: emberAfDoorLockClusterPrintln("[clearCredential] Cannot clear credential - index out of bounds " "[endpointId=%d,credentialType=%u,credentialIndex=%d,modifier=%d]", endpointId, to_underlying(credentialType), credentialIndex, modifier); - return EMBER_ZCL_STATUS_INVALID_COMMAND; + return Status::InvalidCommand; } // 1. Fetch the credential from storage, so we know what we're deleting @@ -2675,7 +2679,7 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip: "[clearCredential] Unable to clear credential - couldn't read credential from database " "[endpointId=%d,credentialType=%u,credentialIndex=%d,modifier=%d]", endpointId, to_underlying(credentialType), credentialIndex, modifier); - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } if (DlCredentialStatus::kAvailable == credential.status) @@ -2683,7 +2687,7 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip: emberAfDoorLockClusterPrintln("[clearCredential] Ignored attempt to clear unoccupied credential slot " "[endpointId=%d,credentialType=%u,credentialIndex=%d,modifier=%d]", endpointId, to_underlying(credentialType), credentialIndex, modifier); - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } if (credentialType != credential.credentialType) @@ -2692,7 +2696,7 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip: "[endpointId=%d,credentialType=%u,credentialIndex=%d,modifier=%d,actualCredentialType=%u]", endpointId, to_underlying(credentialType), credentialIndex, modifier, to_underlying(credential.credentialType)); - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } // 2. Get the associated user and if it is the only attached credential -- delete the user. This operation will @@ -2704,7 +2708,7 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip: "[clearCredential] Unable to clear related credential user - couldn't find index of related user " "[endpointId=%d,credentialType=%u,credentialIndex=%d,modifier=%d]", endpointId, to_underlying(credentialType), credentialIndex, modifier); - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } EmberAfPluginDoorLockUserInfo relatedUser; if (!emberAfPluginDoorLockGetUser(endpointId, relatedUserIndex, relatedUser)) @@ -2714,7 +2718,7 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip: "[endpointId=%d,credentialType=%u,credentialIndex=%d,modifier=%d,userIndex=%d]", endpointId, to_underlying(credentialType), credentialIndex, modifier, relatedUserIndex); - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } if (1 == relatedUser.credentials.size()) { @@ -2722,19 +2726,20 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip: "[endpointId=%d,credentialType=%u,credentialIndex=%d,modifier=%d,userIndex=%d]", endpointId, to_underlying(credentialType), credentialIndex, modifier, relatedUserIndex); auto clearStatus = clearUser(endpointId, modifier, sourceNodeId, relatedUserIndex, relatedUser, true); - if (EMBER_ZCL_STATUS_SUCCESS != clearStatus) + if (Status::Success != clearStatus) { ChipLogError(Zcl, "[clearCredential] Unable to clear related credential user - internal error " "[endpointId=%d,credentialType=%u,credentialIndex=%d,modifier=%d,userIndex=%d,status=%d]", - endpointId, to_underlying(credentialType), credentialIndex, modifier, relatedUserIndex, clearStatus); + endpointId, to_underlying(credentialType), credentialIndex, modifier, relatedUserIndex, + to_underlying(clearStatus)); - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } emberAfDoorLockClusterPrintln("[clearCredential] Successfully clear credential and related user " "[endpointId=%d,credentialType=%u,credentialIndex=%d,modifier=%d,userIndex=%d]", endpointId, to_underlying(credentialType), credentialIndex, modifier, relatedUserIndex); - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } // 3. If the user wasn't deleted, delete the credential and adjust the list of credentials for related user in the storage @@ -2745,7 +2750,7 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip: "[clearCredential] Unable to clear credential - couldn't write new credential to database " "[endpointId=%d,credentialType=%u,credentialIndex=%d,modifier=%d]", endpointId, to_underlying(credentialType), credentialIndex, modifier); - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } uint8_t maxCredentialsPerUser; @@ -2755,7 +2760,7 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip: "[clearCredential] Unable to get the number of available credentials per user: internal error " "[endpointId=%d,credentialType=%d,credentialIndex=%d]", endpointId, to_underlying(credentialType), credentialIndex); - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } // Should never happen, only possible if the implementation of application is incorrect @@ -2767,7 +2772,7 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip: endpointId, to_underlying(credentialType), credentialIndex, modifier, relatedUserIndex, static_cast(relatedUser.credentials.size())); - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } chip::Platform::ScopedMemoryBuffer newCredentials; @@ -2778,7 +2783,7 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip: "[endpointId=%d,credentialType=%u,credentialIndex=%d,modifier=%d,userIndex=%d,credentialsCount=%u]", endpointId, to_underlying(credentialType), credentialIndex, modifier, relatedUserIndex, static_cast(relatedUser.credentials.size())); - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } size_t newCredentialsCount = 0; @@ -2801,7 +2806,7 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip: ",credentialIndex=%d,modifier=%d,userIndex=%d,newCredentialsCount=%u]", endpointId, to_underlying(credentialType), credentialIndex, modifier, relatedUserIndex, static_cast(newCredentialsCount)); - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } emberAfDoorLockClusterPrintln( @@ -2816,18 +2821,18 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip: sourceNodeId, modifier, relatedUserIndex, credentialIndex); } - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } -EmberAfStatus DoorLockServer::clearCredentials(chip::EndpointId endpointId, chip::FabricIndex modifier, chip::NodeId sourceNodeId) +Status DoorLockServer::clearCredentials(chip::EndpointId endpointId, chip::FabricIndex modifier, chip::NodeId sourceNodeId) { if (SupportsPIN(endpointId)) { auto status = clearCredentials(endpointId, modifier, sourceNodeId, CredentialTypeEnum::kPin); - if (EMBER_ZCL_STATUS_SUCCESS != status) + if (Status::Success != status) { ChipLogError(Zcl, "[clearCredentials] Unable to clear all PIN credentials [endpointId=%d,status=%d]", endpointId, - status); + to_underlying(status)); return status; } @@ -2837,10 +2842,10 @@ EmberAfStatus DoorLockServer::clearCredentials(chip::EndpointId endpointId, chip if (SupportsRFID(endpointId)) { auto status = clearCredentials(endpointId, modifier, sourceNodeId, CredentialTypeEnum::kRfid); - if (EMBER_ZCL_STATUS_SUCCESS != status) + if (Status::Success != status) { ChipLogError(Zcl, "[clearCredentials] Unable to clear all RFID credentials [endpointId=%d,status=%d]", endpointId, - status); + to_underlying(status)); return status; } emberAfDoorLockClusterPrintln("[clearCredentials] All RFID credentials were cleared [endpointId=%d]", endpointId); @@ -2849,18 +2854,18 @@ EmberAfStatus DoorLockServer::clearCredentials(chip::EndpointId endpointId, chip if (SupportsFingers(endpointId)) { auto status = clearCredentials(endpointId, modifier, sourceNodeId, CredentialTypeEnum::kFingerprint); - if (EMBER_ZCL_STATUS_SUCCESS != status) + if (Status::Success != status) { ChipLogError(Zcl, "[clearCredentials] Unable to clear all Fingerprint credentials [endpointId=%d,status=%d]", - endpointId, status); + endpointId, to_underlying(status)); return status; } status = clearCredentials(endpointId, modifier, sourceNodeId, CredentialTypeEnum::kFingerVein); - if (EMBER_ZCL_STATUS_SUCCESS != status) + if (Status::Success != status) { ChipLogError(Zcl, "[clearCredentials] Unable to clear all Finger Vein credentials [endpointId=%d,status=%d]", - endpointId, status); + endpointId, to_underlying(status)); return status; } @@ -2870,20 +2875,20 @@ EmberAfStatus DoorLockServer::clearCredentials(chip::EndpointId endpointId, chip if (SupportsFace(endpointId)) { auto status = clearCredentials(endpointId, modifier, sourceNodeId, CredentialTypeEnum::kFace); - if (EMBER_ZCL_STATUS_SUCCESS != status) + if (Status::Success != status) { ChipLogError(Zcl, "[clearCredentials] Unable to clear all face credentials [endpointId=%d,status=%d]", endpointId, - status); + to_underlying(status)); return status; } emberAfDoorLockClusterPrintln("[clearCredentials] All face credentials were cleared [endpointId=%d]", endpointId); } - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } -EmberAfStatus DoorLockServer::clearCredentials(chip::EndpointId endpointId, chip::FabricIndex modifier, chip::NodeId sourceNodeId, - CredentialTypeEnum credentialType) +Status DoorLockServer::clearCredentials(chip::EndpointId endpointId, chip::FabricIndex modifier, chip::NodeId sourceNodeId, + CredentialTypeEnum credentialType) { uint16_t maxNumberOfCredentials = 0; if (!getMaxNumberOfCredentials(endpointId, credentialType, maxNumberOfCredentials)) @@ -2892,21 +2897,21 @@ EmberAfStatus DoorLockServer::clearCredentials(chip::EndpointId endpointId, chip "[clearCredentials] Unable to get max number of credentials to clear - can't get max number of credentials " "[endpointId=%d,credentialType=%u]", endpointId, to_underlying(credentialType)); - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; bool clearedCredential = false; for (uint16_t i = 1; i < maxNumberOfCredentials; ++i) { - EmberAfStatus clearStatus = clearCredential(endpointId, modifier, sourceNodeId, credentialType, i, false); - if (EMBER_ZCL_STATUS_SUCCESS != clearStatus) + Status clearStatus = clearCredential(endpointId, modifier, sourceNodeId, credentialType, i, false); + if (Status::Success != clearStatus) { ChipLogError(Zcl, "[clearCredentials] Unable to clear the credential - internal error " "[endpointId=%d,credentialType=%u,credentialIndex=%d,status=%d]", - endpointId, to_underlying(credentialType), i, status); - if (status == EMBER_ZCL_STATUS_SUCCESS) + endpointId, to_underlying(credentialType), i, to_underlying(status)); + if (status == Status::Success) { status = clearStatus; } @@ -3098,7 +3103,7 @@ void DoorLockServer::setHolidayScheduleCommandHandler(chip::app::CommandHandler if (!SupportsHolidaySchedules(endpointId)) { emberAfDoorLockClusterPrintln("[SetHolidaySchedule] Ignore command (not supported) [endpointId=%d]", endpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -3109,7 +3114,7 @@ void DoorLockServer::setHolidayScheduleCommandHandler(chip::app::CommandHandler emberAfDoorLockClusterPrintln( "[SetHolidaySchedule] Unable to add schedule - index out of range [endpointId=%d,scheduleIndex=%d]", endpointId, holidayIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -3118,7 +3123,7 @@ void DoorLockServer::setHolidayScheduleCommandHandler(chip::app::CommandHandler emberAfDoorLockClusterPrintln("[SetHolidaySchedule] Unable to add schedule - schedule ends earlier than starts" "[endpointId=%d,scheduleIndex=%d,localStarTime=%" PRIu32 ",localEndTime=%" PRIu32 "]", endpointId, holidayIndex, localStartTime, localEndTime); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -3128,7 +3133,7 @@ void DoorLockServer::setHolidayScheduleCommandHandler(chip::app::CommandHandler "[endpointId=%d,scheduleIndex=%d,localStarTime=%" PRIu32 ",localEndTime=%" PRIu32 ", operatingMode=%d]", endpointId, holidayIndex, localStartTime, localEndTime, to_underlying(operatingMode)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -3138,7 +3143,7 @@ void DoorLockServer::setHolidayScheduleCommandHandler(chip::app::CommandHandler { ChipLogError(Zcl, "[SetHolidaySchedule] Unable to add schedule - internal error [endpointId=%d,scheduleIndex=%d,status=%u]", endpointId, holidayIndex, to_underlying(status)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } @@ -3147,7 +3152,7 @@ void DoorLockServer::setHolidayScheduleCommandHandler(chip::app::CommandHandler ",operatingMode=%d]", endpointId, holidayIndex, localStartTime, localEndTime, to_underlying(operatingMode)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); } void DoorLockServer::getHolidayScheduleCommandHandler(chip::app::CommandHandler * commandObj, @@ -3158,7 +3163,7 @@ void DoorLockServer::getHolidayScheduleCommandHandler(chip::app::CommandHandler { emberAfDoorLockClusterPrintln("[GetHolidaySchedule] Ignore command (not supported) [endpointId=%d,scheduleIndex=%d]", endpointId, holidayIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } emberAfDoorLockClusterPrintln("[GetHolidaySchedule] incoming command [endpointId=%d,scheduleIndex=%d]", endpointId, @@ -3191,7 +3196,7 @@ void DoorLockServer::clearHolidayScheduleCommandHandler(chip::app::CommandHandle if (!SupportsHolidaySchedules(endpointId)) { emberAfDoorLockClusterPrintln("[ClearHolidaySchedule] Ignore command (not supported) [endpointId=%d]", endpointId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } emberAfDoorLockClusterPrintln("[ClearHolidaySchedule] incoming command [endpointId=%d,scheduleIndex=%d]", endpointId, @@ -3201,7 +3206,7 @@ void DoorLockServer::clearHolidayScheduleCommandHandler(chip::app::CommandHandle { emberAfDoorLockClusterPrintln("[ClearHolidaySchedule] Holiday index is out of range [endpointId=%d,scheduleIndex=%d]", endpointId, holidayIndex); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return; } @@ -3225,10 +3230,10 @@ void DoorLockServer::clearHolidayScheduleCommandHandler(chip::app::CommandHandle emberAfDoorLockClusterPrintln( "[ClearHolidaySchedule] Unable to clear the user schedules - app error [endpointId=%d,scheduleIndex=%d,status=%u]", endpointId, holidayIndex, to_underlying(clearStatus)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return; } - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); } bool DoorLockServer::RemoteOperationEnabled(chip::EndpointId endpointId) const @@ -3370,7 +3375,7 @@ bool DoorLockServer::HandleRemoteLockOperation(chip::app::CommandHandler * comma } // Send command response - emberAfSendImmediateDefaultResponse(success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, success ? Status::Success : Status::Failure); // Most of the time we want to send the lock operation event but sometimes (when the lockout is active) we don't want it. if (!sendEvent) diff --git a/src/app/clusters/door-lock-server/door-lock-server.h b/src/app/clusters/door-lock-server/door-lock-server.h index 3f8fab53e8cd62..d56ef343ff43f7 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.h +++ b/src/app/clusters/door-lock-server/door-lock-server.h @@ -30,6 +30,7 @@ #include #include #include +#include #ifndef DOOR_LOCK_SERVER_ENDPOINT #define DOOR_LOCK_SERVER_ENDPOINT 1 @@ -219,10 +220,11 @@ class DoorLockServer uint16_t userIndex, const Nullable & userName, const Nullable & userUniqueId, const Nullable & userStatus, const Nullable & userType, const Nullable & credentialRule); - EmberAfStatus clearUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricId, chip::NodeId sourceNodeId, - uint16_t userIndex, bool sendUserChangeEvent); - EmberAfStatus clearUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricId, chip::NodeId sourceNodeId, - uint16_t userIndex, const EmberAfPluginDoorLockUserInfo & user, bool sendUserChangeEvent); + chip::Protocols::InteractionModel::Status clearUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricId, + chip::NodeId sourceNodeId, uint16_t userIndex, bool sendUserChangeEvent); + chip::Protocols::InteractionModel::Status clearUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricId, + chip::NodeId sourceNodeId, uint16_t userIndex, + const EmberAfPluginDoorLockUserInfo & user, bool sendUserChangeEvent); bool clearFabricFromUsers(chip::EndpointId endpointId, chip::FabricIndex fabricIndex); @@ -252,11 +254,13 @@ class DoorLockServer const EmberAfPluginDoorLockCredentialInfo & existingCredential, const chip::ByteSpan & credentialData, uint16_t userIndex, const Nullable & userStatus, Nullable userType); - EmberAfStatus clearCredential(chip::EndpointId endpointId, chip::FabricIndex modifier, chip::NodeId sourceNodeId, - CredentialTypeEnum credentialType, uint16_t credentialIndex, bool sendUserChangeEvent); - EmberAfStatus clearCredentials(chip::EndpointId endpointId, chip::FabricIndex modifier, chip::NodeId sourceNodeId); - EmberAfStatus clearCredentials(chip::EndpointId endpointId, chip::FabricIndex modifier, chip::NodeId sourceNodeId, - CredentialTypeEnum credentialType); + chip::Protocols::InteractionModel::Status clearCredential(chip::EndpointId endpointId, chip::FabricIndex modifier, + chip::NodeId sourceNodeId, CredentialTypeEnum credentialType, + uint16_t credentialIndex, bool sendUserChangeEvent); + chip::Protocols::InteractionModel::Status clearCredentials(chip::EndpointId endpointId, chip::FabricIndex modifier, + chip::NodeId sourceNodeId); + chip::Protocols::InteractionModel::Status clearCredentials(chip::EndpointId endpointId, chip::FabricIndex modifier, + chip::NodeId sourceNodeId, CredentialTypeEnum credentialType); bool clearFabricFromCredentials(chip::EndpointId endpointId, CredentialTypeEnum credentialType, chip::FabricIndex fabricToRemove); diff --git a/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp b/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp index c1ec6fdb7e8255..d3ff29f0e326b9 100644 --- a/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp +++ b/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,7 @@ using namespace chip::app; using namespace chip::Credentials; using namespace chip::app::Clusters; using namespace chip::app::Clusters::GroupKeyManagement; +using chip::Protocols::InteractionModel::Status; // // Attributes @@ -296,7 +298,7 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( if (nullptr == provider || nullptr == fabric) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return true; } @@ -305,7 +307,7 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( CHIP_ERROR err = fabric->GetCompressedFabricIdBytes(compressed_fabric_id); if (CHIP_NO_ERROR != err) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return true; } @@ -314,7 +316,7 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( { // If the EpochKey0 field is null or its associated EpochStartTime0 field is null, // then this command SHALL fail with an INVALID_COMMAND - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return true; } @@ -333,7 +335,7 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( { // If the EpochKey1 field is not null, its associated EpochStartTime1 field SHALL contain // a later epoch start time than the epoch start time found in the EpochStartTime0 field. - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return true; } keyset.epoch_keys[1].start_time = commandData.groupKeySet.epochStartTime1.Value(); @@ -352,7 +354,7 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( // * The EpochKey1 field SHALL NOT be null // * Its associated EpochStartTime1 field SHALL contain a later epoch start time // than the epoch start time found in the EpochStartTime0 field. - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + commandObj->AddStatus(commandPath, Status::InvalidCommand); return true; } keyset.epoch_keys[2].start_time = commandData.groupKeySet.epochStartTime2.Value(); @@ -373,11 +375,10 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( } // Send response - EmberStatus status = - emberAfSendImmediateDefaultResponse(CHIP_NO_ERROR == err ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); - if (EMBER_SUCCESS != status) + err = commandObj->AddStatus(commandPath, StatusIB(err).mStatus); + if (CHIP_NO_ERROR != err) { - ChipLogDetail(Zcl, "GroupKeyManagementCluster: KeySetWrite failed: 0x%x", status); + ChipLogDetail(Zcl, "GroupKeyManagementCluster: KeySetWrite failed: %" CHIP_ERROR_FORMAT, err.Format()); } return true; } @@ -391,7 +392,7 @@ bool emberAfGroupKeyManagementClusterKeySetReadCallback( if (nullptr == provider) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return true; } @@ -399,7 +400,7 @@ bool emberAfGroupKeyManagementClusterKeySetReadCallback( if (CHIP_NO_ERROR != provider->GetKeySet(fabric, commandData.groupKeySetID, keyset)) { // KeySet ID not found - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_NOT_FOUND); + commandObj->AddStatus(commandPath, Status::NotFound); return true; } @@ -450,9 +451,9 @@ bool emberAfGroupKeyManagementClusterKeySetRemoveCallback( const chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::DecodableType & commandData) { - auto fabric = commandObj->GetAccessingFabricIndex(); - auto * provider = GetGroupDataProvider(); - EmberAfStatus status = EMBER_ZCL_STATUS_FAILURE; + auto fabric = commandObj->GetAccessingFabricIndex(); + auto * provider = GetGroupDataProvider(); + Status status = Status::Failure; if (nullptr != provider) { @@ -460,19 +461,19 @@ bool emberAfGroupKeyManagementClusterKeySetRemoveCallback( CHIP_ERROR err = provider->RemoveKeySet(fabric, commandData.groupKeySetID); if (CHIP_ERROR_KEY_NOT_FOUND == err) { - status = EMBER_ZCL_STATUS_NOT_FOUND; + status = Status::NotFound; } else if (CHIP_NO_ERROR == err) { - status = EMBER_ZCL_STATUS_SUCCESS; + status = Status::Success; } } // Send response - EmberStatus send_status = emberAfSendImmediateDefaultResponse(status); - if (EMBER_SUCCESS != send_status) + CHIP_ERROR send_err = commandObj->AddStatus(commandPath, status); + if (CHIP_NO_ERROR != send_err) { - ChipLogDetail(Zcl, "GroupKeyManagementCluster: KeySetRemove failed: 0x%x", send_status); + ChipLogDetail(Zcl, "GroupKeyManagementCluster: KeySetRemove failed: %" CHIP_ERROR_FORMAT, send_err.Format()); } return true; } @@ -517,14 +518,14 @@ bool emberAfGroupKeyManagementClusterKeySetReadAllIndicesCallback( if (nullptr == provider) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return true; } auto keysIt = provider->IterateKeySets(fabric); if (nullptr == keysIt) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return true; } diff --git a/src/app/clusters/groups-client/groups-client.cpp b/src/app/clusters/groups-client/groups-client.cpp index e940096fa4f798..6983aeb7a63bee 100644 --- a/src/app/clusters/groups-client/groups-client.cpp +++ b/src/app/clusters/groups-client/groups-client.cpp @@ -23,7 +23,7 @@ using namespace chip; bool emberAfGroupsClusterAddGroupResponseCallback(app::CommandHandler * commandObj, uint8_t status, GroupId groupId) { emberAfGroupsClusterPrintln("RX: AddGroupResponse 0x%x, 0x%2x", status, groupId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -33,7 +33,7 @@ bool emberAfGroupsClusterViewGroupResponseCallback(app::CommandHandler * command emberAfGroupsClusterPrint("RX: ViewGroupResponse 0x%x, 0x%2x, \"", status, groupId); emberAfGroupsClusterPrintString(groupName); emberAfGroupsClusterPrintln("\""); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -47,13 +47,13 @@ bool emberAfGroupsClusterGetGroupMembershipResponseCallback(app::CommandHandler emberAfGroupsClusterPrint(" [0x%2x]", emberAfGetInt16u(groupList + (i << 1), 0, 2)); } emberAfGroupsClusterPrintln("%s", ""); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } bool emberAfGroupsClusterRemoveGroupResponseCallback(app::CommandHandler * commandObj, uint8_t status, GroupId groupId) { emberAfGroupsClusterPrintln("RX: RemoveGroupResponse 0x%x, 0x%2x", status, groupId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } diff --git a/src/app/clusters/groups-server/groups-server.cpp b/src/app/clusters/groups-server/groups-server.cpp index 39ba191b37b710..8e27d9783615f4 100644 --- a/src/app/clusters/groups-server/groups-server.cpp +++ b/src/app/clusters/groups-server/groups-server.cpp @@ -35,6 +35,7 @@ using namespace chip; using namespace app::Clusters; using namespace app::Clusters::Groups; using namespace chip::Credentials; +using Protocols::InteractionModel::Status; /** * @brief Checks if group-endpoint association exist for the given fabric @@ -71,13 +72,13 @@ static bool KeyExists(FabricIndex fabricIndex, GroupId groupId) return found; } -static EmberAfStatus GroupAdd(FabricIndex fabricIndex, EndpointId endpointId, GroupId groupId, const CharSpan & groupName) +static Status GroupAdd(FabricIndex fabricIndex, EndpointId endpointId, GroupId groupId, const CharSpan & groupName) { - VerifyOrReturnError(IsFabricGroupId(groupId), EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + VerifyOrReturnError(IsFabricGroupId(groupId), Status::ConstraintError); GroupDataProvider * provider = GetGroupDataProvider(); - VerifyOrReturnError(nullptr != provider, EMBER_ZCL_STATUS_NOT_FOUND); - VerifyOrReturnError(KeyExists(fabricIndex, groupId), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS); + VerifyOrReturnError(nullptr != provider, Status::NotFound); + VerifyOrReturnError(KeyExists(fabricIndex, groupId), Status::UnsupportedAccess); // Add a new entry to the GroupTable CHIP_ERROR err = provider->SetGroupInfo(fabricIndex, GroupDataProvider::GroupInfo(groupId, groupName)); @@ -87,12 +88,12 @@ static EmberAfStatus GroupAdd(FabricIndex fabricIndex, EndpointId endpointId, Gr } if (CHIP_NO_ERROR == err) { - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } ChipLogDetail(Zcl, "ERR: Failed to add mapping (end:%d, group:0x%x), err:%" CHIP_ERROR_FORMAT, endpointId, groupId, err.Format()); - return EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED; + return Status::ResourceExhausted; } static EmberAfStatus GroupRemove(FabricIndex fabricIndex, EndpointId endpointId, GroupId groupId) @@ -141,7 +142,7 @@ bool emberAfGroupsClusterAddGroupCallback(app::CommandHandler * commandObj, cons Groups::Commands::AddGroupResponse::Type response; response.groupID = commandData.groupID; - response.status = GroupAdd(fabricIndex, commandPath.mEndpointId, commandData.groupID, commandData.groupName); + response.status = to_underlying(GroupAdd(fabricIndex, commandPath.mEndpointId, commandData.groupID, commandData.groupName)); commandObj->AddResponse(commandPath, response); return true; } @@ -252,28 +253,28 @@ struct GroupMembershipResponse bool emberAfGroupsClusterGetGroupMembershipCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::GetGroupMembership::DecodableType & commandData) { - auto fabricIndex = commandObj->GetAccessingFabricIndex(); - auto * provider = GetGroupDataProvider(); - EmberAfStatus status = EMBER_ZCL_STATUS_FAILURE; + auto fabricIndex = commandObj->GetAccessingFabricIndex(); + auto * provider = GetGroupDataProvider(); + Status status = Status::Failure; - VerifyOrExit(nullptr != provider, status = EMBER_ZCL_STATUS_FAILURE); + VerifyOrExit(nullptr != provider, status = Status::Failure); { GroupDataProvider::EndpointIterator * iter = nullptr; iter = provider->IterateEndpoints(fabricIndex); - VerifyOrExit(nullptr != iter, status = EMBER_ZCL_STATUS_FAILURE); + VerifyOrExit(nullptr != iter, status = Status::Failure); commandObj->AddResponse(commandPath, GroupMembershipResponse(commandData, commandPath.mEndpointId, iter)); iter->Release(); - status = EMBER_ZCL_STATUS_SUCCESS; + status = Status::Success; } exit: - if (EMBER_ZCL_STATUS_SUCCESS != status) + if (Status::Success != status) { - ChipLogDetail(Zcl, "GroupsCluster: GetGroupMembership failed: failed: 0x%x", status); - emberAfSendImmediateDefaultResponse(status); + ChipLogDetail(Zcl, "GroupsCluster: GetGroupMembership failed: failed: 0x%x", to_underlying(status)); + commandObj->AddStatus(commandPath, status); } return true; } @@ -298,18 +299,18 @@ bool emberAfGroupsClusterRemoveGroupCallback(app::CommandHandler * commandObj, c bool emberAfGroupsClusterRemoveAllGroupsCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::RemoveAllGroups::DecodableType & commandData) { - auto fabricIndex = commandObj->GetAccessingFabricIndex(); - auto * provider = GetGroupDataProvider(); - EmberAfStatus status = EMBER_ZCL_STATUS_FAILURE; + auto fabricIndex = commandObj->GetAccessingFabricIndex(); + auto * provider = GetGroupDataProvider(); + Status status = Status::Failure; - VerifyOrExit(nullptr != provider, status = EMBER_ZCL_STATUS_FAILURE); + VerifyOrExit(nullptr != provider, status = Status::Failure); #ifdef EMBER_AF_PLUGIN_SCENES { GroupDataProvider::EndpointIterator * iter = provider->IterateEndpoints(fabricIndex); GroupDataProvider::GroupEndpoint mapping; - VerifyOrExit(nullptr != iter, status = EMBER_ZCL_STATUS_FAILURE); + VerifyOrExit(nullptr != iter, status = Status::Failure); while (iter->Next(mapping)) { if (commandPath.mEndpointId == mapping.endpoint_id) @@ -323,13 +324,13 @@ bool emberAfGroupsClusterRemoveAllGroupsCallback(app::CommandHandler * commandOb #endif provider->RemoveEndpoint(fabricIndex, commandPath.mEndpointId); - status = EMBER_ZCL_STATUS_SUCCESS; + status = Status::Success; exit: - emberAfSendImmediateDefaultResponse(status); - if (EMBER_ZCL_STATUS_SUCCESS != status) + commandObj->AddStatus(commandPath, status); + if (Status::Success != status) { - ChipLogDetail(Zcl, "GroupsCluster: RemoveAllGroups failed: 0x%x", status); + ChipLogDetail(Zcl, "GroupsCluster: RemoveAllGroups failed: 0x%x", to_underlying(status)); } return true; } @@ -343,23 +344,21 @@ bool emberAfGroupsClusterAddGroupIfIdentifyingCallback(app::CommandHandler * com auto groupName = commandData.groupName; auto endpointId = commandPath.mEndpointId; - EmberAfStatus status; - EmberStatus sendStatus = EMBER_SUCCESS; - + Status status; if (!emberAfIsDeviceIdentifying(endpointId)) { // If not identifying, ignore add group -> success; not a failure. - status = EMBER_ZCL_STATUS_SUCCESS; + status = Status::Success; } else { status = GroupAdd(fabricIndex, endpointId, groupId, groupName); } - sendStatus = emberAfSendImmediateDefaultResponse(status); - if (EMBER_SUCCESS != sendStatus) + CHIP_ERROR sendErr = commandObj->AddStatus(commandPath, status); + if (CHIP_NO_ERROR != sendErr) { - ChipLogDetail(Zcl, "Groups: failed to send %s: 0x%x", "default_response", sendStatus); + ChipLogDetail(Zcl, "Groups: failed to send %s: %" CHIP_ERROR_FORMAT, "status_response", sendErr.Format()); } return true; } diff --git a/src/app/clusters/identify-client/identify-client.cpp b/src/app/clusters/identify-client/identify-client.cpp index 05c7d7a6e7ca99..c778c77d547dc7 100644 --- a/src/app/clusters/identify-client/identify-client.cpp +++ b/src/app/clusters/identify-client/identify-client.cpp @@ -30,6 +30,6 @@ using namespace chip; bool emberAfIdentifyClusterIdentifyQueryResponseCallback(app::CommandHandler * commandObj, uint16_t timeout) { emberAfIdentifyClusterPrintln("RX: IdentifyQueryResponse 0x%4x", timeout); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } diff --git a/src/app/clusters/identify-server/identify-server.cpp b/src/app/clusters/identify-server/identify-server.cpp index 08b19f7e0183d1..15da36a48077fa 100644 --- a/src/app/clusters/identify-server/identify-server.cpp +++ b/src/app/clusters/identify-server/identify-server.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -43,6 +44,7 @@ using namespace chip; using namespace chip::app; using namespace chip::app::Clusters::Identify; +using chip::Protocols::InteractionModel::Status; static Identify * firstIdentify = nullptr; @@ -203,9 +205,9 @@ bool emberAfIdentifyClusterIdentifyCallback(CommandHandler * commandObj, const a auto & identifyTime = commandData.identifyTime; // cmd Identify - return EMBER_SUCCESS == - emberAfSendImmediateDefaultResponse( - Clusters::Identify::Attributes::IdentifyTime::Set(commandPath.mEndpointId, identifyTime)); + commandObj->AddStatus(commandPath, + ToInteractionModelStatus(Attributes::IdentifyTime::Set(commandPath.mEndpointId, identifyTime))); + return true; } bool emberAfIdentifyClusterTriggerEffectCallback(CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, @@ -239,7 +241,7 @@ bool emberAfIdentifyClusterTriggerEffectCallback(CommandHandler * commandObj, co identify->mOnEffectIdentifier(identify); } - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } diff --git a/src/app/clusters/keypad-input-server/keypad-input-server.cpp b/src/app/clusters/keypad-input-server/keypad-input-server.cpp index 2dce476b1766c5..bb90d940ba5223 100644 --- a/src/app/clusters/keypad-input-server/keypad-input-server.cpp +++ b/src/app/clusters/keypad-input-server/keypad-input-server.cpp @@ -42,6 +42,7 @@ using namespace chip::app::Clusters::KeypadInput; #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED using namespace chip::AppPlatform; #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED +using chip::Protocols::InteractionModel::Status; static constexpr size_t kKeypadInputDelegateTableSize = EMBER_AF_KEYPAD_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; @@ -183,7 +184,7 @@ bool emberAfKeypadInputClusterSendKeyCallback(app::CommandHandler * command, con if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfKeypadInputClusterSendKeyCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; } diff --git a/src/app/clusters/level-control/level-control.cpp b/src/app/clusters/level-control/level-control.cpp index d569bb1a66efb0..14f472307be272 100644 --- a/src/app/clusters/level-control/level-control.cpp +++ b/src/app/clusters/level-control/level-control.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -50,6 +51,7 @@ using namespace chip; using namespace chip::app::Clusters; using namespace chip::app::Clusters::LevelControl; +using chip::Protocols::InteractionModel::Status; #ifndef IGNORE_LEVEL_CONTROL_CLUSTER_START_UP_CURRENT_LEVEL static bool areStartUpLevelControlServerAttributesNonVolatile(EndpointId endpoint); @@ -99,18 +101,19 @@ static EmberAfLevelControlState stateTable[kLevelControlStateTableSize]; static EmberAfLevelControlState * getState(EndpointId endpoint); -static EmberAfStatus moveToLevelHandler(EndpointId endpoint, CommandId commandId, uint8_t level, - app::DataModel::Nullable transitionTimeDs, - chip::Optional> optionsMask, - chip::Optional> optionsOverride, uint16_t storedLevel); -static void moveHandler(EndpointId endpoint, CommandId commandId, uint8_t moveMode, app::DataModel::Nullable rate, - chip::Optional> optionsMask, +static Status moveToLevelHandler(EndpointId endpoint, CommandId commandId, uint8_t level, + app::DataModel::Nullable transitionTimeDs, + chip::Optional> optionsMask, + chip::Optional> optionsOverride, uint16_t storedLevel); +static void moveHandler(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, uint8_t moveMode, + app::DataModel::Nullable rate, chip::Optional> optionsMask, chip::Optional> optionsOverride); -static void stepHandler(EndpointId endpoint, CommandId commandId, uint8_t stepMode, uint8_t stepSize, - app::DataModel::Nullable transitionTimeDs, +static void stepHandler(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, uint8_t stepMode, + uint8_t stepSize, app::DataModel::Nullable transitionTimeDs, chip::Optional> optionsMask, chip::Optional> optionsOverride); -static void stopHandler(EndpointId endpoint, CommandId commandId, chip::Optional> optionsMask, +static void stopHandler(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, + chip::Optional> optionsMask, chip::Optional> optionsOverride); static void setOnOffValue(EndpointId endpoint, bool onOff); @@ -459,12 +462,12 @@ bool emberAfLevelControlClusterMoveToLevelCallback(app::CommandHandler * command optionsMask.Raw(), optionsOverride.Raw()); } - EmberAfStatus status = moveToLevelHandler(commandPath.mEndpointId, Commands::MoveToLevel::Id, level, transitionTime, - Optional>(optionsMask), - Optional>(optionsOverride), - INVALID_STORED_LEVEL); // Don't revert to the stored level + Status status = moveToLevelHandler(commandPath.mEndpointId, Commands::MoveToLevel::Id, level, transitionTime, + Optional>(optionsMask), + Optional>(optionsOverride), + INVALID_STORED_LEVEL); // Don't revert to the stored level - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -489,12 +492,12 @@ bool emberAfLevelControlClusterMoveToLevelWithOnOffCallback(app::CommandHandler transitionTime.Value(), optionsMask.Raw(), optionsOverride.Raw()); } - EmberAfStatus status = moveToLevelHandler(commandPath.mEndpointId, Commands::MoveToLevelWithOnOff::Id, level, transitionTime, - Optional>(optionsMask), - Optional>(optionsOverride), - INVALID_STORED_LEVEL); // Don't revert to the stored level + Status status = moveToLevelHandler(commandPath.mEndpointId, Commands::MoveToLevelWithOnOff::Id, level, transitionTime, + Optional>(optionsMask), + Optional>(optionsOverride), + INVALID_STORED_LEVEL); // Don't revert to the stored level - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -518,7 +521,7 @@ bool emberAfLevelControlClusterMoveCallback(app::CommandHandler * commandObj, co optionsOverride.Raw()); } - moveHandler(commandPath.mEndpointId, Commands::Move::Id, moveMode, rate, Optional>(optionsMask), + moveHandler(commandObj, commandPath, moveMode, rate, Optional>(optionsMask), Optional>(optionsOverride)); return true; } @@ -542,8 +545,8 @@ bool emberAfLevelControlClusterMoveWithOnOffCallback(app::CommandHandler * comma optionsMask.Raw(), optionsOverride.Raw()); } - moveHandler(commandPath.mEndpointId, Commands::MoveWithOnOff::Id, moveMode, rate, - Optional>(optionsMask), Optional>(optionsOverride)); + moveHandler(commandObj, commandPath, moveMode, rate, Optional>(optionsMask), + Optional>(optionsOverride)); return true; } @@ -567,8 +570,8 @@ bool emberAfLevelControlClusterStepCallback(app::CommandHandler * commandObj, co transitionTime.Value(), optionsMask.Raw(), optionsOverride.Raw()); } - stepHandler(commandPath.mEndpointId, Commands::Step::Id, stepMode, stepSize, transitionTime, - Optional>(optionsMask), Optional>(optionsOverride)); + stepHandler(commandObj, commandPath, stepMode, stepSize, transitionTime, Optional>(optionsMask), + Optional>(optionsOverride)); return true; } @@ -592,8 +595,8 @@ bool emberAfLevelControlClusterStepWithOnOffCallback(app::CommandHandler * comma transitionTime.Value(), optionsMask.Raw(), optionsOverride.Raw()); } - stepHandler(commandPath.mEndpointId, Commands::StepWithOnOff::Id, stepMode, stepSize, transitionTime, - Optional>(optionsMask), Optional>(optionsOverride)); + stepHandler(commandObj, commandPath, stepMode, stepSize, transitionTime, Optional>(optionsMask), + Optional>(optionsOverride)); return true; } @@ -604,7 +607,7 @@ bool emberAfLevelControlClusterStopCallback(app::CommandHandler * commandObj, co auto & optionsOverride = commandData.optionsOverride; emberAfLevelControlClusterPrintln("%s STOP", "RX level-control:"); - stopHandler(commandPath.mEndpointId, Commands::Stop::Id, Optional>(optionsMask), + stopHandler(commandObj, commandPath, Optional>(optionsMask), Optional>(optionsOverride)); return true; } @@ -615,50 +618,49 @@ bool emberAfLevelControlClusterStopWithOnOffCallback(app::CommandHandler * comma auto & optionsMask = commandData.optionsMask; auto & optionsOverride = commandData.optionsOverride; emberAfLevelControlClusterPrintln("%s STOP_WITH_ON_OFF", "RX level-control:"); - stopHandler(commandPath.mEndpointId, Commands::StopWithOnOff::Id, Optional>(optionsMask), + stopHandler(commandObj, commandPath, Optional>(optionsMask), Optional>(optionsOverride)); return true; } -static EmberAfStatus moveToLevelHandler(EndpointId endpoint, CommandId commandId, uint8_t level, - app::DataModel::Nullable transitionTimeDs, - chip::Optional> optionsMask, - chip::Optional> optionsOverride, uint16_t storedLevel) +static Status moveToLevelHandler(EndpointId endpoint, CommandId commandId, uint8_t level, + app::DataModel::Nullable transitionTimeDs, + chip::Optional> optionsMask, + chip::Optional> optionsOverride, uint16_t storedLevel) { EmberAfLevelControlState * state = getState(endpoint); - EmberAfStatus status; app::DataModel::Nullable currentLevel; uint8_t actualStepSize; if (state == nullptr) { - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } if (level > EMBER_AF_PLUGIN_LEVEL_CONTROL_MAXIMUM_LEVEL) { - return EMBER_ZCL_STATUS_INVALID_COMMAND; + return Status::InvalidCommand; } if (!shouldExecuteIfOff(endpoint, commandId, optionsMask, optionsOverride)) { - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } // Cancel any currently active command before fiddling with the state. deactivate(endpoint); - status = Attributes::CurrentLevel::Get(endpoint, currentLevel); + EmberAfStatus status = Attributes::CurrentLevel::Get(endpoint, currentLevel); if (status != EMBER_ZCL_STATUS_SUCCESS) { emberAfLevelControlClusterPrintln("ERR: reading current level %x", status); - return status; + return app::ToInteractionModelStatus(status); } if (currentLevel.IsNull()) { emberAfLevelControlClusterPrintln("ERR: Current Level is null"); - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } state->commandId = commandId; @@ -690,7 +692,7 @@ static EmberAfStatus moveToLevelHandler(EndpointId endpoint, CommandId commandId } if (currentLevel.Value() == state->moveToLevel) { - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } state->increasing = true; actualStepSize = static_cast(state->moveToLevel - currentLevel.Value()); @@ -717,7 +719,7 @@ static EmberAfStatus moveToLevelHandler(EndpointId endpoint, CommandId commandId if (status != EMBER_ZCL_STATUS_SUCCESS) { emberAfLevelControlClusterPrintln("ERR: reading on/off transition time %x", status); - return status; + return app::ToInteractionModelStatus(status); } // Transition time comes in (or is stored, in the case of On/Off Transition @@ -759,7 +761,6 @@ static EmberAfStatus moveToLevelHandler(EndpointId endpoint, CommandId commandId // The setup was successful, so mark the new state as active and return. schedule(endpoint, computeCallbackWaitTimeMs(state->callbackSchedule, state->eventDurationMs)); - status = EMBER_ZCL_STATUS_SUCCESS; #ifdef EMBER_AF_PLUGIN_ON_OFF // Check that the received MoveToLevelWithOnOff produces a On action and that the onoff support the lighting featuremap @@ -770,44 +771,47 @@ static EmberAfStatus moveToLevelHandler(EndpointId endpoint, CommandId commandId } #endif // EMBER_AF_PLUGIN_ON_OFF - return status; + return Status::Success; } -static void moveHandler(EndpointId endpoint, CommandId commandId, uint8_t moveMode, app::DataModel::Nullable rate, - chip::Optional> optionsMask, +static void moveHandler(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, uint8_t moveMode, + app::DataModel::Nullable rate, chip::Optional> optionsMask, chip::Optional> optionsOverride) { + EndpointId endpoint = commandPath.mEndpointId; + CommandId commandId = commandPath.mCommandId; + EmberAfLevelControlState * state = getState(endpoint); - EmberAfStatus status; + Status status; app::DataModel::Nullable currentLevel; uint8_t difference; if (state == nullptr) { - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; goto send_default_response; } if (!shouldExecuteIfOff(endpoint, commandId, optionsMask, optionsOverride)) { - status = EMBER_ZCL_STATUS_SUCCESS; + status = Status::Success; goto send_default_response; } // Cancel any currently active command before fiddling with the state. deactivate(endpoint); - status = Attributes::CurrentLevel::Get(endpoint, currentLevel); - if (status != EMBER_ZCL_STATUS_SUCCESS) + status = app::ToInteractionModelStatus(Attributes::CurrentLevel::Get(endpoint, currentLevel)); + if (status != Status::Success) { - emberAfLevelControlClusterPrintln("ERR: reading current level %x", status); + emberAfLevelControlClusterPrintln("ERR: reading current level %x", to_underlying(status)); goto send_default_response; } if (currentLevel.IsNull()) { emberAfLevelControlClusterPrintln("ERR: Current Level is null"); - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; goto send_default_response; } @@ -829,7 +833,7 @@ static void moveHandler(EndpointId endpoint, CommandId commandId, uint8_t moveMo difference = static_cast(currentLevel.Value() - state->minLevel); break; default: - status = EMBER_ZCL_STATUS_INVALID_COMMAND; + status = Status::InvalidCommand; goto send_default_response; } @@ -845,7 +849,7 @@ static void moveHandler(EndpointId endpoint, CommandId commandId, uint8_t moveMo } if (currentLevel.Value() == state->moveToLevel) { - status = EMBER_ZCL_STATUS_SUCCESS; + status = Status::Success; goto send_default_response; } } @@ -856,10 +860,10 @@ static void moveHandler(EndpointId endpoint, CommandId commandId, uint8_t moveMo if (rate.IsNull()) { app::DataModel::Nullable defaultMoveRate; - status = Attributes::DefaultMoveRate::Get(endpoint, defaultMoveRate); - if (status != EMBER_ZCL_STATUS_SUCCESS || defaultMoveRate.IsNull()) + status = app::ToInteractionModelStatus(Attributes::DefaultMoveRate::Get(endpoint, defaultMoveRate)); + if (status != Status::Success || defaultMoveRate.IsNull()) { - emberAfLevelControlClusterPrintln("ERR: reading default move rate %x", status); + emberAfLevelControlClusterPrintln("ERR: reading default move rate %x", to_underlying(status)); state->eventDurationMs = FASTEST_TRANSITION_TIME_MS; } else @@ -867,7 +871,7 @@ static void moveHandler(EndpointId endpoint, CommandId commandId, uint8_t moveMo // nonsensical case, means "don't move", so we're done if (defaultMoveRate.Value() == 0) { - status = EMBER_ZCL_STATUS_SUCCESS; + status = Status::Success; goto send_default_response; } state->eventDurationMs = MILLISECOND_TICKS_PER_SECOND / defaultMoveRate.Value(); @@ -894,48 +898,51 @@ static void moveHandler(EndpointId endpoint, CommandId commandId, uint8_t moveMo // The setup was successful, so mark the new state as active and return. schedule(endpoint, computeCallbackWaitTimeMs(state->callbackSchedule, state->eventDurationMs)); - status = EMBER_ZCL_STATUS_SUCCESS; + status = Status::Success; send_default_response: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); } -static void stepHandler(EndpointId endpoint, CommandId commandId, uint8_t stepMode, uint8_t stepSize, - app::DataModel::Nullable transitionTimeDs, +static void stepHandler(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, uint8_t stepMode, + uint8_t stepSize, app::DataModel::Nullable transitionTimeDs, chip::Optional> optionsMask, chip::Optional> optionsOverride) { + EndpointId endpoint = commandPath.mEndpointId; + CommandId commandId = commandPath.mCommandId; + EmberAfLevelControlState * state = getState(endpoint); - EmberAfStatus status; + Status status; app::DataModel::Nullable currentLevel; uint8_t actualStepSize = stepSize; if (state == nullptr) { - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; goto send_default_response; } if (!shouldExecuteIfOff(endpoint, commandId, optionsMask, optionsOverride)) { - status = EMBER_ZCL_STATUS_SUCCESS; + status = Status::Success; goto send_default_response; } // Cancel any currently active command before fiddling with the state. deactivate(endpoint); - status = Attributes::CurrentLevel::Get(endpoint, currentLevel); - if (status != EMBER_ZCL_STATUS_SUCCESS) + status = app::ToInteractionModelStatus(Attributes::CurrentLevel::Get(endpoint, currentLevel)); + if (status != Status::Success) { - emberAfLevelControlClusterPrintln("ERR: reading current level %x", status); + emberAfLevelControlClusterPrintln("ERR: reading current level %x", to_underlying(status)); goto send_default_response; } if (currentLevel.IsNull()) { emberAfLevelControlClusterPrintln("ERR: Current Level is null"); - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; goto send_default_response; } @@ -971,7 +978,7 @@ static void stepHandler(EndpointId endpoint, CommandId commandId, uint8_t stepMo } break; default: - status = EMBER_ZCL_STATUS_INVALID_COMMAND; + status = Status::InvalidCommand; goto send_default_response; } @@ -987,7 +994,7 @@ static void stepHandler(EndpointId endpoint, CommandId commandId, uint8_t stepMo } if (currentLevel.Value() == state->moveToLevel) { - status = EMBER_ZCL_STATUS_SUCCESS; + status = Status::Success; goto send_default_response; } } @@ -1031,37 +1038,41 @@ static void stepHandler(EndpointId endpoint, CommandId commandId, uint8_t stepMo // The setup was successful, so mark the new state as active and return. schedule(endpoint, computeCallbackWaitTimeMs(state->callbackSchedule, state->eventDurationMs)); - status = EMBER_ZCL_STATUS_SUCCESS; + status = Status::Success; send_default_response: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); } -static void stopHandler(EndpointId endpoint, CommandId commandId, chip::Optional> optionsMask, +static void stopHandler(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, + chip::Optional> optionsMask, chip::Optional> optionsOverride) { + EndpointId endpoint = commandPath.mEndpointId; + CommandId commandId = commandPath.mCommandId; + EmberAfLevelControlState * state = getState(endpoint); - EmberAfStatus status; + Status status; if (state == nullptr) { - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; goto send_default_response; } if (!shouldExecuteIfOff(endpoint, commandId, optionsMask, optionsOverride)) { - status = EMBER_ZCL_STATUS_SUCCESS; + status = Status::Success; goto send_default_response; } // Cancel any currently active command. deactivate(endpoint); writeRemainingTime(endpoint, 0); - status = EMBER_ZCL_STATUS_SUCCESS; + status = Status::Success; send_default_response: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); } // Follows 07-5123-04 (ZigBee Cluster Library doc), section 3.10.2.1.1. diff --git a/src/app/clusters/media-input-server/media-input-server.cpp b/src/app/clusters/media-input-server/media-input-server.cpp index cff8580c9bf186..6910d710ce3f38 100644 --- a/src/app/clusters/media-input-server/media-input-server.cpp +++ b/src/app/clusters/media-input-server/media-input-server.cpp @@ -35,6 +35,7 @@ using namespace chip; using namespace chip::app::Clusters; using namespace chip::app::Clusters::MediaInput; +using Protocols::InteractionModel::Status; static constexpr size_t kMediaInputDelegateTableSize = EMBER_AF_MEDIA_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; @@ -170,9 +171,9 @@ CHIP_ERROR MediaInputAttrAccess::ReadCurrentInputAttribute(app::AttributeValueEn bool emberAfMediaInputClusterSelectInputCallback(app::CommandHandler * command, const app::ConcreteCommandPath & commandPath, const Commands::SelectInput::DecodableType & commandData) { - CHIP_ERROR err = CHIP_NO_ERROR; - EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + CHIP_ERROR err = CHIP_NO_ERROR; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; auto & input = commandData.index; @@ -181,68 +182,68 @@ bool emberAfMediaInputClusterSelectInputCallback(app::CommandHandler * command, if (!delegate->HandleSelectInput(input)) { - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } exit: if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaInputClusterSelectInputCallback error: %s", err.AsString()); - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } - emberAfSendImmediateDefaultResponse(status); + command->AddStatus(commandPath, status); return true; } bool emberAfMediaInputClusterShowInputStatusCallback(app::CommandHandler * command, const app::ConcreteCommandPath & commandPath, const Commands::ShowInputStatus::DecodableType & commandData) { - CHIP_ERROR err = CHIP_NO_ERROR; - EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + CHIP_ERROR err = CHIP_NO_ERROR; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; Delegate * delegate = GetDelegate(endpoint); VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE); if (!delegate->HandleShowInputStatus()) { - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } exit: if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaInputClusterShowInputStatusCallback error: %s", err.AsString()); - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } - emberAfSendImmediateDefaultResponse(status); + command->AddStatus(commandPath, status); return true; } bool emberAfMediaInputClusterHideInputStatusCallback(app::CommandHandler * command, const app::ConcreteCommandPath & commandPath, const Commands::HideInputStatus::DecodableType & commandData) { - CHIP_ERROR err = CHIP_NO_ERROR; - EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + CHIP_ERROR err = CHIP_NO_ERROR; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; Delegate * delegate = GetDelegate(endpoint); VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE); if (!delegate->HandleHideInputStatus()) { - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } exit: if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaInputClusterHideInputStatusCallback error: %s", err.AsString()); - status = EMBER_ZCL_STATUS_FAILURE; + status = Status::Failure; } - emberAfSendImmediateDefaultResponse(status); + command->AddStatus(commandPath, status); return true; } diff --git a/src/app/clusters/media-playback-server/media-playback-server.cpp b/src/app/clusters/media-playback-server/media-playback-server.cpp index 8957e9b68f64cc..bc6c3d91575850 100644 --- a/src/app/clusters/media-playback-server/media-playback-server.cpp +++ b/src/app/clusters/media-playback-server/media-playback-server.cpp @@ -42,6 +42,7 @@ using namespace chip::app::Clusters::MediaPlayback; #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED using namespace chip::AppPlatform; #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED +using chip::Protocols::InteractionModel::Status; static constexpr size_t kMediaPlaybackDelegateTableSize = EMBER_AF_MEDIA_PLAYBACK_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; @@ -245,7 +246,7 @@ bool emberAfMediaPlaybackClusterPlayCallback(app::CommandHandler * command, cons if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaPlaybackClusterPlayCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -269,7 +270,7 @@ bool emberAfMediaPlaybackClusterPauseCallback(app::CommandHandler * command, con if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaPlaybackClusterPauseCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -293,7 +294,7 @@ bool emberAfMediaPlaybackClusterStopCallback(app::CommandHandler * command, cons if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaPlaybackClusterStopCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -317,7 +318,7 @@ bool emberAfMediaPlaybackClusterFastForwardCallback(app::CommandHandler * comman if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaPlaybackClusterFastForwardCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -341,7 +342,7 @@ bool emberAfMediaPlaybackClusterPreviousCallback(app::CommandHandler * command, if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaPlaybackClusterPreviousCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -365,7 +366,7 @@ bool emberAfMediaPlaybackClusterRewindCallback(app::CommandHandler * command, co if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaPlaybackClusterRewindCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -391,7 +392,7 @@ bool emberAfMediaPlaybackClusterSkipBackwardCallback(app::CommandHandler * comma if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaPlaybackClusterSkipBackwardCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -416,7 +417,7 @@ bool emberAfMediaPlaybackClusterSkipForwardCallback(app::CommandHandler * comman if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaPlaybackClusterSkipForwardCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -441,7 +442,7 @@ bool emberAfMediaPlaybackClusterSeekCallback(app::CommandHandler * command, cons if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaPlaybackClusterSeekCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -465,7 +466,7 @@ bool emberAfMediaPlaybackClusterNextCallback(app::CommandHandler * command, cons if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaPlaybackClusterNextCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; @@ -489,7 +490,7 @@ bool emberAfMediaPlaybackClusterStartOverCallback(app::CommandHandler * command, if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfMediaPlaybackClusterStartOverCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; diff --git a/src/app/clusters/mode-select-server/mode-select-server.cpp b/src/app/clusters/mode-select-server/mode-select-server.cpp index 9091d4ba286f58..bd925130aab116 100644 --- a/src/app/clusters/mode-select-server/mode-select-server.cpp +++ b/src/app/clusters/mode-select-server/mode-select-server.cpp @@ -40,6 +40,7 @@ using namespace chip::app; using namespace chip::app::Clusters; using namespace chip::app::Clusters::ModeSelect; using namespace chip::Protocols; +using chip::Protocols::InteractionModel::Status; using BootReasonType = GeneralDiagnostics::BootReasonEnum; @@ -99,18 +100,18 @@ bool emberAfModeSelectClusterChangeToModeCallback(CommandHandler * commandHandle uint8_t newMode = commandData.newMode; // Check that the newMode matches one of the supported options const ModeSelect::Structs::ModeOptionStruct::Type * modeOptionPtr; - EmberAfStatus checkSupportedModeStatus = + Status checkSupportedModeStatus = ModeSelect::getSupportedModesManager()->getModeOptionByMode(endpointId, newMode, &modeOptionPtr); - if (EMBER_ZCL_STATUS_SUCCESS != checkSupportedModeStatus) + if (Status::Success != checkSupportedModeStatus) { emberAfPrintln(EMBER_AF_PRINT_DEBUG, "ModeSelect: Failed to find the option with mode %u", newMode); - emberAfSendImmediateDefaultResponse(checkSupportedModeStatus); - return false; + commandHandler->AddStatus(commandPath, checkSupportedModeStatus); + return true; } ModeSelect::Attributes::CurrentMode::Set(endpointId, newMode); emberAfPrintln(EMBER_AF_PRINT_DEBUG, "ModeSelect: ChangeToMode successful"); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandHandler->AddStatus(commandPath, Status::Success); return true; } @@ -262,12 +263,5 @@ static InteractionModel::Status verifyModeValue(const EndpointId endpointId, con return InteractionModel::Status::Success; } const ModeSelect::Structs::ModeOptionStruct::Type * modeOptionPtr; - EmberAfStatus checkSupportedModeStatus = - ModeSelect::getSupportedModesManager()->getModeOptionByMode(endpointId, newMode, &modeOptionPtr); - if (EMBER_ZCL_STATUS_SUCCESS != checkSupportedModeStatus) - { - const InteractionModel::Status returnStatus = ToInteractionModelStatus(checkSupportedModeStatus); - return returnStatus; - } - return InteractionModel::Status::Success; + return ModeSelect::getSupportedModesManager()->getModeOptionByMode(endpointId, newMode, &modeOptionPtr); } diff --git a/src/app/clusters/mode-select-server/supported-modes-manager.h b/src/app/clusters/mode-select-server/supported-modes-manager.h index 6818d445b298f7..497a604497200a 100644 --- a/src/app/clusters/mode-select-server/supported-modes-manager.h +++ b/src/app/clusters/mode-select-server/supported-modes-manager.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace chip { namespace app { @@ -73,10 +74,11 @@ class SupportedModesManager * @param endpointId The endpoint for which to search the ModeOptionStruct. * @param mode The mode for which to search the ModeOptionStruct. * @param dataPtr The pointer to receive the ModeOptionStruct, if one is found. - * @return EMBER_ZCL_STATUS_SUCCESS if successfully found the option. Otherwise, returns appropriate status code (found in + * @return Status::Success if successfully found the option. Otherwise, returns appropriate status code (found in * ) */ - virtual EmberAfStatus getModeOptionByMode(EndpointId endpointId, uint8_t mode, const ModeOptionStructType ** dataPtr) const = 0; + virtual Protocols::InteractionModel::Status getModeOptionByMode(EndpointId endpointId, uint8_t mode, + const ModeOptionStructType ** dataPtr) const = 0; virtual ~SupportedModesManager() {} }; diff --git a/src/app/clusters/on-off-server/on-off-server.cpp b/src/app/clusters/on-off-server/on-off-server.cpp index 4fa560a30b902d..6ea1b556db2e01 100644 --- a/src/app/clusters/on-off-server/on-off-server.cpp +++ b/src/app/clusters/on-off-server/on-off-server.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #ifdef EMBER_AF_PLUGIN_SCENES @@ -35,6 +36,7 @@ using namespace chip; using namespace chip::app::Clusters; using namespace chip::app::Clusters::OnOff; +using chip::Protocols::InteractionModel::Status; /********************************************************** * Attributes Definition @@ -324,27 +326,27 @@ EmberAfStatus OnOffServer::getOnOffValueForStartUp(chip::EndpointId endpoint, bo return status; } -bool OnOffServer::offCommand(const app::ConcreteCommandPath & commandPath) +bool OnOffServer::offCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath) { EmberAfStatus status = setOnOffValue(commandPath.mEndpointId, Commands::Off::Id, false); - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, app::ToInteractionModelStatus(status)); return true; } -bool OnOffServer::onCommand(const app::ConcreteCommandPath & commandPath) +bool OnOffServer::onCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath) { EmberAfStatus status = setOnOffValue(commandPath.mEndpointId, Commands::On::Id, false); - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, app::ToInteractionModelStatus(status)); return true; } -bool OnOffServer::toggleCommand(const app::ConcreteCommandPath & commandPath) +bool OnOffServer::toggleCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath) { EmberAfStatus status = setOnOffValue(commandPath.mEndpointId, Commands::Toggle::Id, false); - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, app::ToInteractionModelStatus(status)); return true; } @@ -354,7 +356,7 @@ bool OnOffServer::offWithEffectCommand(app::CommandHandler * commandObj, const a OnOffEffectIdentifier effectId = commandData.effectIdentifier; uint8_t effectVariant = commandData.effectVariant; chip::EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; if (SupportsLightingApplications(endpoint)) { @@ -397,25 +399,24 @@ bool OnOffServer::offWithEffectCommand(app::CommandHandler * commandObj, const a } } - status = setOnOffValue(endpoint, Commands::Off::Id, false); + status = app::ToInteractionModelStatus(setOnOffValue(endpoint, Commands::Off::Id, false)); } else { - status = EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND; + status = Status::UnsupportedCommand; } - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } bool OnOffServer::OnWithRecallGlobalSceneCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath) { chip::EndpointId endpoint = commandPath.mEndpointId; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; if (!SupportsLightingApplications(endpoint)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND); + commandObj->AddStatus(commandPath, Status::UnsupportedCommand); return true; } @@ -428,7 +429,7 @@ bool OnOffServer::OnWithRecallGlobalSceneCommand(app::CommandHandler * commandOb if (globalSceneControl) { - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -445,7 +446,7 @@ bool OnOffServer::OnWithRecallGlobalSceneCommand(app::CommandHandler * commandOb OnOff::Attributes::GlobalSceneControl::Set(endpoint, true); setOnOffValue(endpoint, Commands::On::Id, false); - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -469,28 +470,28 @@ uint32_t OnOffServer::calculateNextWaitTimeMS() return (uint32_t) waitTime.count(); } -bool OnOffServer::OnWithTimedOffCommand(const app::ConcreteCommandPath & commandPath, +bool OnOffServer::OnWithTimedOffCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::OnWithTimedOff::DecodableType & commandData) { BitFlags onOffControl = commandData.onOffControl; uint16_t onTime = commandData.onTime; uint16_t offWaitTime = commandData.offWaitTime; - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; chip::EndpointId endpoint = commandPath.mEndpointId; bool isOn = false; uint16_t currentOffWaitTime = MAX_TIME_VALUE; uint16_t currentOnTime = 0; EmberEventControl * event = configureEventControl(endpoint); - VerifyOrExit(event != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); - VerifyOrExit(SupportsLightingApplications(endpoint), status = EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND); + VerifyOrExit(event != nullptr, status = Status::UnsupportedEndpoint); + VerifyOrExit(SupportsLightingApplications(endpoint), status = Status::UnsupportedCommand); OnOff::Attributes::OnOff::Get(endpoint, &isOn); // OnOff is off and the commands is only accepted if on if (onOffControl.Has(OnOffControl::kAcceptOnlyWhenOn) && !isOn) { - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -525,7 +526,7 @@ bool OnOffServer::OnWithTimedOffCommand(const app::ConcreteCommandPath & command } exit: - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -704,19 +705,19 @@ OnOffEffect::~OnOffEffect() bool emberAfOnOffClusterOffCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::Off::DecodableType & commandData) { - return OnOffServer::Instance().offCommand(commandPath); + return OnOffServer::Instance().offCommand(commandObj, commandPath); } bool emberAfOnOffClusterOnCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::On::DecodableType & commandData) { - return OnOffServer::Instance().onCommand(commandPath); + return OnOffServer::Instance().onCommand(commandObj, commandPath); } bool emberAfOnOffClusterToggleCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::Toggle::DecodableType & commandData) { - return OnOffServer::Instance().toggleCommand(commandPath); + return OnOffServer::Instance().toggleCommand(commandObj, commandPath); } bool emberAfOnOffClusterOffWithEffectCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, @@ -735,7 +736,7 @@ bool emberAfOnOffClusterOnWithRecallGlobalSceneCallback(app::CommandHandler * co bool emberAfOnOffClusterOnWithTimedOffCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::OnWithTimedOff::DecodableType & commandData) { - return OnOffServer::Instance().OnWithTimedOffCommand(commandPath, commandData); + return OnOffServer::Instance().OnWithTimedOffCommand(commandObj, commandPath, commandData); } void emberAfOnOffClusterServerInitCallback(chip::EndpointId endpoint) diff --git a/src/app/clusters/on-off-server/on-off-server.h b/src/app/clusters/on-off-server/on-off-server.h index 71c793691e741b..2bf8b091a8cc95 100644 --- a/src/app/clusters/on-off-server/on-off-server.h +++ b/src/app/clusters/on-off-server/on-off-server.h @@ -48,14 +48,14 @@ class OnOffServer static OnOffServer & Instance(); - bool offCommand(const chip::app::ConcreteCommandPath & commandPath); - bool onCommand(const chip::app::ConcreteCommandPath & commandPath); - bool toggleCommand(const chip::app::ConcreteCommandPath & commandPath); + bool offCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath); + bool onCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath); + bool toggleCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath); void initOnOffServer(chip::EndpointId endpoint); bool offWithEffectCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::OnOff::Commands::OffWithEffect::DecodableType & commandData); bool OnWithRecallGlobalSceneCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath); - bool OnWithTimedOffCommand(const chip::app::ConcreteCommandPath & commandPath, + bool OnWithTimedOffCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::OnOff::Commands::OnWithTimedOff::DecodableType & commandData); void updateOnOffTimeCommand(chip::EndpointId endpoint); EmberAfStatus getOnOffValue(chip::EndpointId endpoint, bool * currentOnOffValue); diff --git a/src/app/clusters/scenes-client/scenes-client.cpp b/src/app/clusters/scenes-client/scenes-client.cpp index de4c8954d9b0b1..899bdd148b247a 100644 --- a/src/app/clusters/scenes-client/scenes-client.cpp +++ b/src/app/clusters/scenes-client/scenes-client.cpp @@ -42,14 +42,14 @@ bool emberAfScenesClusterRemoveSceneResponseCallback(app::CommandHandler * comma uint8_t sceneId) { emberAfScenesClusterPrintln("RX: RemoveSceneResponse 0x%x, 0x%2x, 0x%x", status, groupId, sceneId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } bool emberAfScenesClusterRemoveAllScenesResponseCallback(app::CommandHandler * commandObj, uint8_t status, GroupId groupId) { emberAfScenesClusterPrintln("RX: RemoveAllScenesResponse 0x%x, 0x%2x", status, groupId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -57,7 +57,7 @@ bool emberAfScenesClusterStoreSceneResponseCallback(app::CommandHandler * comman uint8_t sceneId) { emberAfScenesClusterPrintln("RX: StoreSceneResponse 0x%x, 0x%2x, 0x%x", status, groupId, sceneId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -79,7 +79,7 @@ bool emberAfScenesClusterGetSceneMembershipResponseCallback(app::CommandHandler } emberAfScenesClusterPrintln("%s", ""); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } diff --git a/src/app/clusters/scenes/scenes.cpp b/src/app/clusters/scenes/scenes.cpp index a02095d21764a1..8cddbf754192a7 100644 --- a/src/app/clusters/scenes/scenes.cpp +++ b/src/app/clusters/scenes/scenes.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #ifdef EMBER_AF_PLUGIN_GROUPS_SERVER #include @@ -408,7 +409,6 @@ bool emberAfScenesClusterRecallSceneCallback(app::CommandHandler * commandObj, c // value of TransitionTime. EmberAfStatus status; - EmberStatus sendStatus = EMBER_SUCCESS; emberAfScenesClusterPrintln("RX: RecallScene 0x%2x, 0x%x", groupId, sceneId); status = emberAfScenesClusterRecallSavedSceneCallback(fabricIndex, emberAfCurrentEndpoint(), groupId, sceneId); #ifdef EMBER_AF_PLUGIN_ZLL_SCENES_SERVER @@ -417,10 +417,10 @@ bool emberAfScenesClusterRecallSceneCallback(app::CommandHandler * commandObj, c emberAfPluginZllScenesServerRecallSceneZllExtensions(emberAfCurrentEndpoint()); } #endif - sendStatus = emberAfSendImmediateDefaultResponse(status); - if (EMBER_SUCCESS != sendStatus) + CHIP_ERROR sendErr = commandObj->AddStatus(commandPath, app::ToInteractionModelStatus(status)); + if (CHIP_NO_ERROR != sendErr) { - emberAfScenesClusterPrintln("Scenes: failed to send %s: 0x%x", "default_response", sendStatus); + emberAfScenesClusterPrintln("Scenes: failed to send %s: %" CHIP_ERROR_FORMAT, "status_response", sendErr.Format()); } return true; } diff --git a/src/app/clusters/target-navigator-server/target-navigator-server.cpp b/src/app/clusters/target-navigator-server/target-navigator-server.cpp index b4ed629d8b3013..7d39a8c46c6d94 100644 --- a/src/app/clusters/target-navigator-server/target-navigator-server.cpp +++ b/src/app/clusters/target-navigator-server/target-navigator-server.cpp @@ -41,6 +41,7 @@ using namespace chip::app::Clusters::TargetNavigator; #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED using namespace chip::AppPlatform; #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED +using chip::Protocols::InteractionModel::Status; static constexpr size_t kTargetNavigatorDelegateTableSize = EMBER_AF_TARGET_NAVIGATOR_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; @@ -191,7 +192,7 @@ bool emberAfTargetNavigatorClusterNavigateTargetCallback(app::CommandHandler * c if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "emberAfTargetNavigatorClusterNavigateTargetCallback error: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + command->AddStatus(commandPath, Status::Failure); } return true; diff --git a/src/app/clusters/test-cluster-server/test-cluster-server.cpp b/src/app/clusters/test-cluster-server/test-cluster-server.cpp index 1c50f95dcebabb..30d1fb4a6edaa1 100644 --- a/src/app/clusters/test-cluster-server/test-cluster-server.cpp +++ b/src/app/clusters/test-cluster-server/test-cluster-server.cpp @@ -41,6 +41,7 @@ using namespace chip::app::Clusters; using namespace chip::app::Clusters::UnitTesting; using namespace chip::app::Clusters::UnitTesting::Commands; using namespace chip::app::Clusters::UnitTesting::Attributes; +using chip::Protocols::InteractionModel::Status; // The number of elements in the test attribute list constexpr uint8_t kAttributeListLength = 4; @@ -674,7 +675,7 @@ CHIP_ERROR TestAttrAccess::WriteListFabricScopedAttribute(const ConcreteDataAttr } // namespace -bool emberAfUnitTestingClusterTestCallback(app::CommandHandler *, const app::ConcreteCommandPath & commandPath, +bool emberAfUnitTestingClusterTestCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Clusters::UnitTesting::Commands::Test::DecodableType & commandData) { // Setup the test variables @@ -696,7 +697,7 @@ bool emberAfUnitTestingClusterTestCallback(app::CommandHandler *, const app::Con gNullablesAndOptionalsStruct = Structs::NullablesAndOptionalsStruct::Type(); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -720,7 +721,8 @@ bool emberAfUnitTestingClusterTestAddArgumentsCallback(CommandHandler * apComman { if (commandData.arg1 > UINT8_MAX - commandData.arg2) { - return emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND); + apCommandObj->AddStatus(commandPath, Status::InvalidCommand); + return true; } TestAddArgumentsResponse::Type responseData; @@ -766,7 +768,7 @@ bool emberAfUnitTestingClusterTestListStructArgumentRequestCallback( if (CHIP_NO_ERROR != structIterator.GetStatus()) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return true; } @@ -787,7 +789,7 @@ bool emberAfUnitTestingClusterTestEmitTestEventRequestCallback( if (CHIP_NO_ERROR != LogEvent(event, commandPath.mEndpointId, responseData.value)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return true; } commandObj->AddResponse(commandPath, responseData); @@ -803,7 +805,7 @@ bool emberAfUnitTestingClusterTestEmitTestFabricScopedEventRequestCallback( event.fabricIndex = commandData.arg1; if (CHIP_NO_ERROR != LogEvent(event, commandPath.mEndpointId, responseData.value)) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return true; } commandObj->AddResponse(commandPath, responseData); @@ -825,7 +827,7 @@ bool emberAfUnitTestingClusterTestListInt8UArgumentRequestCallback( if (CHIP_NO_ERROR != uint8Iterator.GetStatus()) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return true; } @@ -847,7 +849,7 @@ bool emberAfUnitTestingClusterTestNestedStructListArgumentRequestCallback( if (CHIP_NO_ERROR != structIterator.GetStatus()) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return true; } @@ -875,14 +877,14 @@ bool emberAfUnitTestingClusterTestListNestedStructListArgumentRequestCallback( if (CHIP_NO_ERROR != subStructIterator.GetStatus()) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return true; } } if (CHIP_NO_ERROR != structIterator.GetStatus()) { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return true; } @@ -921,7 +923,7 @@ bool emberAfUnitTestingClusterTestListInt8UReverseRequestCallback( } exit: - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); return true; } diff --git a/src/app/clusters/thermostat-server/thermostat-server.cpp b/src/app/clusters/thermostat-server/thermostat-server.cpp index 6e87527dbc6fab..47e7a0fd5b3cda 100644 --- a/src/app/clusters/thermostat-server/thermostat-server.cpp +++ b/src/app/clusters/thermostat-server/thermostat-server.cpp @@ -751,7 +751,7 @@ bool emberAfThermostatClusterSetpointRaiseLowerCallback(app::CommandHandler * co break; } - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, app::ToInteractionModelStatus(status)); return true; } diff --git a/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp index 44ab2baeb356dd..9908fc77c91334 100644 --- a/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp +++ b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp @@ -37,6 +37,7 @@ using namespace chip::app::Clusters; using namespace chip::app::Clusters::ThreadNetworkDiagnostics; using namespace chip::app::Clusters::ThreadNetworkDiagnostics::Attributes; using namespace chip::DeviceLayer; +using chip::Protocols::InteractionModel::Status; namespace { @@ -139,7 +140,7 @@ bool emberAfThreadNetworkDiagnosticsClusterResetCountsCallback(app::CommandHandl const Commands::ResetCounts::DecodableType & commandData) { ConnectivityMgr().ResetThreadNetworkDiagnosticsCounts(); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } diff --git a/src/app/clusters/window-covering-server/window-covering-server.cpp b/src/app/clusters/window-covering-server/window-covering-server.cpp index 766a9539f2afe8..edb6f3940878ff 100644 --- a/src/app/clusters/window-covering-server/window-covering-server.cpp +++ b/src/app/clusters/window-covering-server/window-covering-server.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -36,6 +37,7 @@ using namespace chip; using namespace chip::app::Clusters; using namespace chip::app::Clusters::WindowCovering; +using chip::Protocols::InteractionModel::Status; #define CHECK_BOUNDS_INVALID(MIN, VAL, MAX) ((VAL < MIN) || (VAL > MAX)) #define CHECK_BOUNDS_VALID(MIN, VAL, MAX) (!CHECK_BOUNDS_INVALID(MIN, VAL, MAX)) @@ -567,7 +569,7 @@ void PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeI } } -EmberAfStatus GetMotionLockStatus(chip::EndpointId endpoint) +Status GetMotionLockStatus(chip::EndpointId endpoint) { BitMask mode = ModeGet(endpoint); BitMask configStatus = ConfigStatusGet(endpoint); @@ -578,17 +580,17 @@ EmberAfStatus GetMotionLockStatus(chip::EndpointId endpoint) if (mode.Has(Mode::kMaintenanceMode)) { // Mainterance Mode - return EMBER_ZCL_STATUS_BUSY; + return Status::Busy; } if (mode.Has(Mode::kCalibrationMode)) { // Calibration Mode - return EMBER_ZCL_STATUS_FAILURE; + return Status::Failure; } } - return EMBER_ZCL_STATUS_SUCCESS; + return Status::Success; } void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate) @@ -625,11 +627,11 @@ bool emberAfWindowCoveringClusterUpOrOpenCallback(app::CommandHandler * commandO emberAfWindowCoveringClusterPrint("UpOrOpen command received"); - EmberAfStatus status = GetMotionLockStatus(endpoint); - if (EMBER_ZCL_STATUS_SUCCESS != status) + Status status = GetMotionLockStatus(endpoint); + if (Status::Success != status) { emberAfWindowCoveringClusterPrint("Err device locked"); - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -660,7 +662,7 @@ bool emberAfWindowCoveringClusterUpOrOpenCallback(app::CommandHandler * commandO emberAfWindowCoveringClusterPrint("WindowCovering has no delegate set for endpoint:%u", endpoint); } - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); return true; } @@ -675,11 +677,11 @@ bool emberAfWindowCoveringClusterDownOrCloseCallback(app::CommandHandler * comma emberAfWindowCoveringClusterPrint("DownOrClose command received"); - EmberAfStatus status = GetMotionLockStatus(endpoint); - if (EMBER_ZCL_STATUS_SUCCESS != status) + Status status = GetMotionLockStatus(endpoint); + if (Status::Success != status) { emberAfWindowCoveringClusterPrint("Err device locked"); - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -691,7 +693,7 @@ bool emberAfWindowCoveringClusterDownOrCloseCallback(app::CommandHandler * comma { Attributes::TargetPositionTiltPercent100ths::Set(endpoint, WC_PERCENT100THS_MAX_CLOSED); } - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); Delegate * delegate = GetDelegate(endpoint); if (delegate) @@ -725,11 +727,11 @@ bool emberAfWindowCoveringClusterStopMotionCallback(app::CommandHandler * comman emberAfWindowCoveringClusterPrint("StopMotion command received"); - EmberAfStatus status = GetMotionLockStatus(endpoint); - if (EMBER_ZCL_STATUS_SUCCESS != status) + Status status = GetMotionLockStatus(endpoint); + if (Status::Success != status) { emberAfWindowCoveringClusterPrint("Err device locked"); - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -755,7 +757,7 @@ bool emberAfWindowCoveringClusterStopMotionCallback(app::CommandHandler * comman (void) Attributes::TargetPositionTiltPercent100ths::Set(endpoint, current); } - return EMBER_SUCCESS == emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + return CHIP_NO_ERROR == commandObj->AddStatus(commandPath, Status::Success); } /** @@ -771,11 +773,11 @@ bool emberAfWindowCoveringClusterGoToLiftValueCallback(app::CommandHandler * com emberAfWindowCoveringClusterPrint("GoToLiftValue %u command received", liftValue); - EmberAfStatus status = GetMotionLockStatus(endpoint); - if (EMBER_ZCL_STATUS_SUCCESS != status) + Status status = GetMotionLockStatus(endpoint); + if (Status::Success != status) { emberAfWindowCoveringClusterPrint("Err device locked"); - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -791,12 +793,12 @@ bool emberAfWindowCoveringClusterGoToLiftValueCallback(app::CommandHandler * com { emberAfWindowCoveringClusterPrint("WindowCovering has no delegate set for endpoint:%u", endpoint); } - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); } else { emberAfWindowCoveringClusterPrint("Err Device is not PA LF"); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); } return true; } @@ -813,11 +815,11 @@ bool emberAfWindowCoveringClusterGoToLiftPercentageCallback(app::CommandHandler emberAfWindowCoveringClusterPrint("GoToLiftPercentage %u command received", percent100ths); - EmberAfStatus status = GetMotionLockStatus(endpoint); - if (EMBER_ZCL_STATUS_SUCCESS != status) + Status status = GetMotionLockStatus(endpoint); + if (Status::Success != status) { emberAfWindowCoveringClusterPrint("Err device locked"); - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -835,17 +837,17 @@ bool emberAfWindowCoveringClusterGoToLiftPercentageCallback(app::CommandHandler { emberAfWindowCoveringClusterPrint("WindowCovering has no delegate set for endpoint:%u", endpoint); } - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); } else { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + commandObj->AddStatus(commandPath, Status::ConstraintError); } } else { emberAfWindowCoveringClusterPrint("Err Device is not PA LF"); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); } return true; } @@ -863,11 +865,11 @@ bool emberAfWindowCoveringClusterGoToTiltValueCallback(app::CommandHandler * com emberAfWindowCoveringClusterPrint("GoToTiltValue %u command received", tiltValue); - EmberAfStatus status = GetMotionLockStatus(endpoint); - if (EMBER_ZCL_STATUS_SUCCESS != status) + Status status = GetMotionLockStatus(endpoint); + if (Status::Success != status) { emberAfWindowCoveringClusterPrint("Err device locked"); - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -883,12 +885,12 @@ bool emberAfWindowCoveringClusterGoToTiltValueCallback(app::CommandHandler * com { emberAfWindowCoveringClusterPrint("WindowCovering has no delegate set for endpoint:%u", endpoint); } - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); } else { emberAfWindowCoveringClusterPrint("Err Device is not PA TL"); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); } return true; } @@ -905,11 +907,11 @@ bool emberAfWindowCoveringClusterGoToTiltPercentageCallback(app::CommandHandler emberAfWindowCoveringClusterPrint("GoToTiltPercentage %u command received", percent100ths); - EmberAfStatus status = GetMotionLockStatus(endpoint); - if (EMBER_ZCL_STATUS_SUCCESS != status) + Status status = GetMotionLockStatus(endpoint); + if (Status::Success != status) { emberAfWindowCoveringClusterPrint("Err device locked"); - emberAfSendImmediateDefaultResponse(status); + commandObj->AddStatus(commandPath, status); return true; } @@ -927,17 +929,17 @@ bool emberAfWindowCoveringClusterGoToTiltPercentageCallback(app::CommandHandler { emberAfWindowCoveringClusterPrint("WindowCovering has no delegate set for endpoint:%u", endpoint); } - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); + commandObj->AddStatus(commandPath, Status::Success); } else { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + commandObj->AddStatus(commandPath, Status::ConstraintError); } } else { emberAfWindowCoveringClusterPrint("Err Device is not PA TL"); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + commandObj->AddStatus(commandPath, Status::Failure); } return true; } diff --git a/src/app/clusters/window-covering-server/window-covering-server.h b/src/app/clusters/window-covering-server/window-covering-server.h index 874417ab1d1214..b1d21d8bb750bf 100644 --- a/src/app/clusters/window-covering-server/window-covering-server.h +++ b/src/app/clusters/window-covering-server/window-covering-server.h @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -115,7 +116,7 @@ uint16_t TiltToPercent100ths(chip::EndpointId endpoint, uint16_t tilt); uint16_t Percent100thsToTilt(chip::EndpointId endpoint, uint16_t percent100ths); void TiltPositionSet(chip::EndpointId endpoint, NPercent100ths position); -EmberAfStatus GetMotionLockStatus(chip::EndpointId endpoint); +Protocols::InteractionModel::Status GetMotionLockStatus(chip::EndpointId endpoint); /** * @brief PostAttributeChange is called when an Attribute is modified. diff --git a/src/app/util/af.h b/src/app/util/af.h index 1192b60c77325a..9632d68f6d0ee8 100644 --- a/src/app/util/af.h +++ b/src/app/util/af.h @@ -520,19 +520,6 @@ EmberStatus emberEventControlSetDelayMS(EmberEventControl * control, uint32_t de */ EmberStatus emberAfSendDefaultResponse(const EmberAfClusterCommand * cmd, EmberAfStatus status); -/** - * @brief Sends a default response to a cluster command using the - * current command. - * - * This function is used to prepare and send a default response to a cluster - * command. - * - * @param status Status code for the default response command. - * @return An ::EmberStatus value that indicates the success or failure of - * sending the response. - */ -EmberStatus emberAfSendImmediateDefaultResponse(EmberAfStatus status); - /** * @brief Access to client API APS frame. */ diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index dee7c35902c548..f61d492ff4a089 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -334,11 +334,6 @@ void emAfApplyDisableDefaultResponse(uint8_t * frame_control) } } -EmberStatus emberAfSendImmediateDefaultResponse(EmberAfStatus status) -{ - return emberAfSendDefaultResponse(emberAfCurrentCommand(), status); -} - EmberStatus emberAfSendDefaultResponse(const EmberAfClusterCommand * cmd, EmberAfStatus status) { // Default Response commands are only sent in response to unicast commands.