From 4887698c709f23e837f3cf9d9fb9d126be0af91a Mon Sep 17 00:00:00 2001 From: du48s03 Date: Fri, 1 Apr 2022 10:10:53 -0700 Subject: [PATCH] On mode overwrite (#16791) * Let OnMode overwrites StartUpMode. * Generated Changes. * Restyled by clang-format * Restyled by prettier-yaml * Remove comments in Tests. Co-authored-by: Restyled.io --- .../all-clusters-common/all-clusters-app.zap | 6 +- .../mode-select-server/mode-select-server.cpp | 32 ++ .../clusters/on-off-server/on-off-server.cpp | 100 +++-- .../clusters/on-off-server/on-off-server.h | 1 + .../tests/suites/TestModeSelectCluster.yaml | 51 +++ .../zap-generated/endpoint_config.h | 6 +- .../chip-tool/zap-generated/test/Commands.h | 365 ++++++++++++++---- 7 files changed, 442 insertions(+), 119 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index fa478d352bdc68..095a2923329497 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -8023,7 +8023,7 @@ "mfgCode": null, "side": "server", "included": 1, - "storageOption": "RAM", + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "0xFF", @@ -10561,7 +10561,7 @@ "mfgCode": null, "side": "server", "included": 1, - "storageOption": "RAM", + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "255", @@ -21557,4 +21557,4 @@ } ], "log": [] -} \ No newline at end of file +} 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 cb700bed4d0d4e..f7f4b7942656f5 100644 --- a/src/app/clusters/mode-select-server/mode-select-server.cpp +++ b/src/app/clusters/mode-select-server/mode-select-server.cpp @@ -26,9 +26,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -134,6 +136,29 @@ void emberAfModeSelectClusterServerInitCallback(EndpointId endpointId) // Initialise currentMode to 0 uint8_t currentMode = 0; status = Attributes::CurrentMode::Get(endpointId, ¤tMode); +#ifdef EMBER_AF_PLUGIN_ON_OFF + // OnMode with Power Up + // If the On/Off feature is supported and the On/Off cluster attribute StartUpOnOff is present, with a + // value of On (turn on at power up), then the CurrentMode attribute SHALL be set to the OnMode attribute + // value when the server is supplied with power, except if the OnMode attribute is null. + if (emberAfContainsServer(endpointId, OnOff::Id) && + emberAfContainsAttribute(endpointId, OnOff::Id, OnOff::Attributes::StartUpOnOff::Id, true) && + emberAfContainsAttribute(endpointId, ModeSelect::Id, ModeSelect::Attributes::OnMode::Id, true)) + { + Attributes::OnMode::TypeInfo::Type onMode; + bool onOffValueForStartUp = 0; + if (Attributes::OnMode::Get(endpointId, onMode) == EMBER_ZCL_STATUS_SUCCESS && + emberAfIsNonVolatileAttribute(endpointId, OnOff::Id, OnOff::Attributes::StartUpOnOff::Id, true) && + OnOffServer::Instance().getOnOffValueForStartUp(endpointId, onOffValueForStartUp) == EMBER_ZCL_STATUS_SUCCESS) + { + if (onOffValueForStartUp && !onMode.IsNull()) + { + emberAfPrintln(EMBER_AF_PRINT_DEBUG, "ModeSelect: CurrentMode is overwritten by OnMode"); + return; + } + } + } +#endif // EMBER_AF_PLUGIN_ON_OFF if (status == EMBER_ZCL_STATUS_SUCCESS && startUpMode.Value() != currentMode) { status = Attributes::CurrentMode::Set(endpointId, startUpMode.Value()); @@ -196,6 +221,9 @@ InteractionModel::Status MatterModeSelectClusterServerPreAttributeChangedCallbac case ModeSelect::Attributes::StartUpMode::Id: result = verifyModeValue(endpointId, *value); break; + case ModeSelect::Attributes::OnMode::Id: + result = verifyModeValue(endpointId, *value); + break; default: result = InteractionModel::Status::Success; } @@ -211,6 +239,10 @@ InteractionModel::Status MatterModeSelectClusterServerPreAttributeChangedCallbac */ static InteractionModel::Status verifyModeValue(const EndpointId endpointId, const uint8_t newMode) { + if (NumericAttributeTraits::IsNullValue(newMode)) // This indicates that the new mode is null. + { + return InteractionModel::Status::Success; + } const ModeSelect::Structs::ModeOptionStruct::Type * modeOptionPtr; EmberAfStatus checkSupportedModeStatus = ModeSelect::getSupportedModesManager()->getModeOptionByMode(endpointId, newMode, &modeOptionPtr); 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 b82d3cbcfa8a5a..54eafddc6cf118 100644 --- a/src/app/clusters/on-off-server/on-off-server.cpp +++ b/src/app/clusters/on-off-server/on-off-server.cpp @@ -169,17 +169,15 @@ EmberAfStatus OnOffServer::setOnOffValue(chip::EndpointId endpoint, uint8_t comm #endif #ifdef EMBER_AF_PLUGIN_MODE_SELECT // If OnMode is not a null value, then change the current mode to it. - ModeSelect::Attributes::OnMode::TypeInfo::Type onMode; - status = ModeSelect::Attributes::OnMode::Get(endpoint, onMode); - if (status != EMBER_ZCL_STATUS_SUCCESS) - { - emberAfOnOffClusterPrintln("ERR: reading onMode %x", status); - return status; - } - if (!onMode.IsNull()) + if (emberAfContainsServer(endpoint, ModeSelect::Id) && + emberAfContainsAttribute(endpoint, ModeSelect::Id, ModeSelect::Attributes::OnMode::Id, true)) { - emberAfOnOffClusterPrintln("Changing Current Mode to %x", onMode.Value()); - status = ModeSelect::Attributes::CurrentMode::Set(endpoint, onMode.Value()); + ModeSelect::Attributes::OnMode::TypeInfo::Type onMode; + if (ModeSelect::Attributes::OnMode::Get(endpoint, onMode) == EMBER_ZCL_STATUS_SUCCESS && !onMode.IsNull()) + { + emberAfOnOffClusterPrintln("Changing Current Mode to %x", onMode.Value()); + status = ModeSelect::Attributes::CurrentMode::Set(endpoint, onMode.Value()); + } } #endif } @@ -248,41 +246,73 @@ void OnOffServer::initOnOffServer(chip::EndpointId endpoint) // 0xff This value cannot happen. // null Set the OnOff attribute to its previous value. - app::DataModel::Nullable startUpOnOff; - EmberAfStatus status = Attributes::StartUpOnOff::Get(endpoint, startUpOnOff); + bool onOffValueForStartUp = 0; + EmberAfStatus status = getOnOffValueForStartUp(endpoint, onOffValueForStartUp); if (status == EMBER_ZCL_STATUS_SUCCESS) { - // Initialise updated value to 0 - bool updatedOnOff = 0; - status = Attributes::OnOff::Get(endpoint, &updatedOnOff); - if (status == EMBER_ZCL_STATUS_SUCCESS) + status = setOnOffValue(endpoint, onOffValueForStartUp, false); + } + +#ifdef EMBER_AF_PLUGIN_MODE_SELECT + // If OnMode is not a null value, then change the current mode to it. + if (onOffValueForStartUp && emberAfContainsServer(endpoint, ModeSelect::Id) && + emberAfContainsAttribute(endpoint, ModeSelect::Id, ModeSelect::Attributes::OnMode::Id, true)) + { + ModeSelect::Attributes::OnMode::TypeInfo::Type onMode; + if (ModeSelect::Attributes::OnMode::Get(endpoint, onMode) == EMBER_ZCL_STATUS_SUCCESS && !onMode.IsNull()) { - if (!startUpOnOff.IsNull()) - { - switch (startUpOnOff.Value()) - { - case OnOff::OnOffStartUpOnOff::kOff: - updatedOnOff = 0; // Off - break; - case OnOff::OnOffStartUpOnOff::kOn: - updatedOnOff = 1; // On - break; - case OnOff::OnOffStartUpOnOff::kTogglePreviousOnOff: - updatedOnOff = !updatedOnOff; - break; - default: - // All other values 0x03- 0xFE are reserved - no action. - break; - } - } - status = setOnOffValue(endpoint, updatedOnOff, false); + emberAfOnOffClusterPrintln("Changing Current Mode to %x", onMode.Value()); + status = ModeSelect::Attributes::CurrentMode::Set(endpoint, onMode.Value()); } } +#endif } #endif // IGNORE_ON_OFF_CLUSTER_START_UP_ON_OFF emberAfPluginOnOffClusterServerPostInitCallback(endpoint); } +/** @brief Get the OnOff value when server starts. + * + * This function determines how StartUpOnOff affects the OnOff value when the server starts. + * + * @param endpoint Ver.: always + * @param onOffValueForStartUp Ver.: always + */ +EmberAfStatus OnOffServer::getOnOffValueForStartUp(chip::EndpointId endpoint, bool & onOffValueForStartUp) +{ + app::DataModel::Nullable startUpOnOff; + EmberAfStatus status = Attributes::StartUpOnOff::Get(endpoint, startUpOnOff); + if (status == EMBER_ZCL_STATUS_SUCCESS) + { + // Initialise updated value to 0 + bool updatedOnOff = 0; + status = Attributes::OnOff::Get(endpoint, &updatedOnOff); + if (status == EMBER_ZCL_STATUS_SUCCESS) + { + if (!startUpOnOff.IsNull()) + { + switch (startUpOnOff.Value()) + { + case OnOff::OnOffStartUpOnOff::kOff: + updatedOnOff = 0; // Off + break; + case OnOff::OnOffStartUpOnOff::kOn: + updatedOnOff = 1; // On + break; + case OnOff::OnOffStartUpOnOff::kTogglePreviousOnOff: + updatedOnOff = !updatedOnOff; + break; + default: + // All other values 0x03- 0xFE are reserved - no action. + break; + } + } + onOffValueForStartUp = updatedOnOff; + } + } + return status; +} + bool OnOffServer::offCommand(const app::ConcreteCommandPath & commandPath) { EmberAfStatus status = setOnOffValue(commandPath.mEndpointId, Commands::Off::Id, false); 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 94e61e66d81445..0bab9ea4df97d8 100644 --- a/src/app/clusters/on-off-server/on-off-server.h +++ b/src/app/clusters/on-off-server/on-off-server.h @@ -59,6 +59,7 @@ class OnOffServer const chip::app::Clusters::OnOff::Commands::OnWithTimedOff::DecodableType & commandData); void updateOnOffTimeCommand(chip::EndpointId endpoint); EmberAfStatus setOnOffValue(chip::EndpointId endpoint, uint8_t command, bool initiatedByLevelChange); + EmberAfStatus getOnOffValueForStartUp(chip::EndpointId endpoint, bool & onOffValueForStartUp); bool HasFeature(chip::EndpointId endpoint, OnOffFeature feature); inline bool SupportsLightingApplications(chip::EndpointId endpointId) diff --git a/src/app/tests/suites/TestModeSelectCluster.yaml b/src/app/tests/suites/TestModeSelectCluster.yaml index c3b070fe999904..970567d7c31711 100644 --- a/src/app/tests/suites/TestModeSelectCluster.yaml +++ b/src/app/tests/suites/TestModeSelectCluster.yaml @@ -112,6 +112,14 @@ tests: response: value: currentModeBeforeToggle + - label: "Change to Unsupported OnMode" + command: "writeAttribute" + attribute: "OnMode" + arguments: + value: 2 + response: + error: CONSTRAINT_ERROR + - label: "Change OnMode" command: "writeAttribute" attribute: "OnMode" @@ -166,6 +174,49 @@ tests: - name: "NewMode" value: 0 + - label: "Change On Mode" + command: "writeAttribute" + attribute: "OnMode" + arguments: + value: 4 + + - label: "Set StartUpOnOff" + cluster: "On/Off" + command: "writeAttribute" + attribute: "StartUpOnOff" + arguments: + value: 1 + + - label: "Reboot target device" + cluster: "SystemCommands" + command: "Reboot" + arguments: + values: + - name: "discriminator" + value: discriminator + + - label: "Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: + "Verify Current Mode Change based on OnMode, as it overwrites + StartUpMode" + command: "readAttribute" + attribute: "CurrentMode" + response: + value: 4 + + - label: "Change On Mode to Null" + command: "writeAttribute" + attribute: "OnMode" + arguments: + value: null + - label: "Reboot target device" cluster: "SystemCommands" command: "Reboot" diff --git a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h index 8efd0cff4f8c0d..de462010a3f6b1 100644 --- a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h +++ b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h @@ -1360,7 +1360,8 @@ { 0x00004001, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* OnTime */ \ { 0x00004002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* OffWaitTime */ \ { 0x00004003, ZAP_TYPE(ENUM8), 1, \ - ZAP_ATTRIBUTE_MASK(MIN_MAX) | ZAP_ATTRIBUTE_MASK(WRITABLE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_ATTRIBUTE_MASK(MIN_MAX) | ZAP_ATTRIBUTE_MASK(TOKENIZE) | ZAP_ATTRIBUTE_MASK(WRITABLE) | \ + ZAP_ATTRIBUTE_MASK(NULLABLE), \ ZAP_MIN_MAX_DEFAULTS_INDEX(1) }, /* StartUpOnOff */ \ { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* FeatureMap */ \ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(4) }, /* ClusterRevision */ \ @@ -1465,7 +1466,8 @@ { 0x00000004, ZAP_TYPE(INT8U), 1, \ ZAP_ATTRIBUTE_MASK(TOKENIZE) | ZAP_ATTRIBUTE_MASK(WRITABLE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ ZAP_SIMPLE_DEFAULT(0) }, /* StartUpMode */ \ - { 0x00000005, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(WRITABLE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + { 0x00000005, ZAP_TYPE(INT8U), 1, \ + ZAP_ATTRIBUTE_MASK(TOKENIZE) | ZAP_ATTRIBUTE_MASK(WRITABLE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ ZAP_SIMPLE_DEFAULT(255) }, /* OnMode */ \ { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(386) }, /* FeatureMap */ \ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 604d4784494e8e..2a11d247f7a750 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -91902,52 +91902,81 @@ class TestModeSelectClusterSuite : public TestCommand err = TestVerifyCurrentModeDoesNotChangeWhenOnModeIsNull_12(); break; case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Change OnMode\n"); - err = TestChangeOnMode_13(); + ChipLogProgress(chipTool, " ***** Test Step 13 : Change to Unsupported OnMode\n"); + err = TestChangeToUnsupportedOnMode_13(); break; case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Verify OnMode\n"); - err = TestVerifyOnMode_14(); + ChipLogProgress(chipTool, " ***** Test Step 14 : Change OnMode\n"); + err = TestChangeOnMode_14(); break; case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Toggle OnOff\n"); - err = TestToggleOnOff_15(); + ChipLogProgress(chipTool, " ***** Test Step 15 : Verify OnMode\n"); + err = TestVerifyOnMode_15(); break; case 16: ChipLogProgress(chipTool, " ***** Test Step 16 : Toggle OnOff\n"); err = TestToggleOnOff_16(); break; case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Verify Current Mode Changes if OnMode is not null\n"); - err = TestVerifyCurrentModeChangesIfOnModeIsNotNull_17(); + ChipLogProgress(chipTool, " ***** Test Step 17 : Toggle OnOff\n"); + err = TestToggleOnOff_17(); break; case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Change to Unsupported StartUp Mode\n"); - err = TestChangeToUnsupportedStartUpMode_18(); + ChipLogProgress(chipTool, " ***** Test Step 18 : Verify Current Mode Changes if OnMode is not null\n"); + err = TestVerifyCurrentModeChangesIfOnModeIsNotNull_18(); break; case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Change to Supported StartUp Mode\n"); - err = TestChangeToSupportedStartUpMode_19(); + ChipLogProgress(chipTool, " ***** Test Step 19 : Change to Unsupported StartUp Mode\n"); + err = TestChangeToUnsupportedStartUpMode_19(); break; case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Verify StartUp Mode Change\n"); - err = TestVerifyStartUpModeChange_20(); + ChipLogProgress(chipTool, " ***** Test Step 20 : Change to Supported StartUp Mode\n"); + err = TestChangeToSupportedStartUpMode_20(); break; case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Change CurrentMode to another value\n"); - err = TestChangeCurrentModeToAnotherValue_21(); + ChipLogProgress(chipTool, " ***** Test Step 21 : Verify StartUp Mode Change\n"); + err = TestVerifyStartUpModeChange_21(); break; case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Reboot target device\n"); - err = TestRebootTargetDevice_22(); + ChipLogProgress(chipTool, " ***** Test Step 22 : Change CurrentMode to another value\n"); + err = TestChangeCurrentModeToAnotherValue_22(); break; case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_23(); + ChipLogProgress(chipTool, " ***** Test Step 23 : Change On Mode\n"); + err = TestChangeOnMode_23(); break; case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Verify Current Mode Change based on new StartUp Mode\n"); - err = TestVerifyCurrentModeChangeBasedOnNewStartUpMode_24(); + ChipLogProgress(chipTool, " ***** Test Step 24 : Set StartUpOnOff\n"); + err = TestSetStartUpOnOff_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Reboot target device\n"); + err = TestRebootTargetDevice_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_26(); + break; + case 27: + ChipLogProgress(chipTool, + " ***** Test Step 27 : Verify Current Mode Change based on OnMode, as it overwrites StartUpMode\n"); + err = TestVerifyCurrentModeChangeBasedOnOnModeAsItOverwritesStartUpMode_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Change On Mode to Null\n"); + err = TestChangeOnModeToNull_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Reboot target device\n"); + err = TestRebootTargetDevice_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Verify Current Mode Change based on new StartUp Mode\n"); + err = TestVerifyCurrentModeChangeBasedOnNewStartUpMode_31(); break; } @@ -91965,7 +91994,7 @@ class TestModeSelectClusterSuite : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 25; + const uint16_t mTestCount = 32; chip::Optional mNodeId; chip::Optional mCluster; @@ -92082,19 +92111,19 @@ class TestModeSelectClusterSuite : public TestCommand (static_cast(context))->OnFailureResponse_14(error); } - static void OnSuccessCallback_14(void * context, const chip::app::DataModel::Nullable & onMode) + static void OnSuccessCallback_14(void * context) { - (static_cast(context))->OnSuccessResponse_14(onMode); + (static_cast(context))->OnSuccessResponse_14(); } - static void OnFailureCallback_17(void * context, CHIP_ERROR error) + static void OnFailureCallback_15(void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_17(error); + (static_cast(context))->OnFailureResponse_15(error); } - static void OnSuccessCallback_17(void * context, uint8_t currentMode) + static void OnSuccessCallback_15(void * context, const chip::app::DataModel::Nullable & onMode) { - (static_cast(context))->OnSuccessResponse_17(currentMode); + (static_cast(context))->OnSuccessResponse_15(onMode); } static void OnFailureCallback_18(void * context, CHIP_ERROR error) @@ -92102,9 +92131,9 @@ class TestModeSelectClusterSuite : public TestCommand (static_cast(context))->OnFailureResponse_18(error); } - static void OnSuccessCallback_18(void * context) + static void OnSuccessCallback_18(void * context, uint8_t currentMode) { - (static_cast(context))->OnSuccessResponse_18(); + (static_cast(context))->OnSuccessResponse_18(currentMode); } static void OnFailureCallback_19(void * context, CHIP_ERROR error) @@ -92122,9 +92151,29 @@ class TestModeSelectClusterSuite : public TestCommand (static_cast(context))->OnFailureResponse_20(error); } - static void OnSuccessCallback_20(void * context, const chip::app::DataModel::Nullable & startUpMode) + static void OnSuccessCallback_20(void * context) + { + (static_cast(context))->OnSuccessResponse_20(); + } + + static void OnFailureCallback_21(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_21(error); + } + + static void OnSuccessCallback_21(void * context, const chip::app::DataModel::Nullable & startUpMode) + { + (static_cast(context))->OnSuccessResponse_21(startUpMode); + } + + static void OnFailureCallback_23(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_23(error); + } + + static void OnSuccessCallback_23(void * context) { - (static_cast(context))->OnSuccessResponse_20(startUpMode); + (static_cast(context))->OnSuccessResponse_23(); } static void OnFailureCallback_24(void * context, CHIP_ERROR error) @@ -92132,9 +92181,39 @@ class TestModeSelectClusterSuite : public TestCommand (static_cast(context))->OnFailureResponse_24(error); } - static void OnSuccessCallback_24(void * context, uint8_t currentMode) + static void OnSuccessCallback_24(void * context) { - (static_cast(context))->OnSuccessResponse_24(currentMode); + (static_cast(context))->OnSuccessResponse_24(); + } + + static void OnFailureCallback_27(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_27(error); + } + + static void OnSuccessCallback_27(void * context, uint8_t currentMode) + { + (static_cast(context))->OnSuccessResponse_27(currentMode); + } + + static void OnFailureCallback_28(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_28(error); + } + + static void OnSuccessCallback_28(void * context) + { + (static_cast(context))->OnSuccessResponse_28(); + } + + static void OnFailureCallback_31(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_31(error); + } + + static void OnSuccessCallback_31(void * context, uint8_t currentMode) + { + (static_cast(context))->OnSuccessResponse_31(currentMode); } // @@ -92471,7 +92550,7 @@ class TestModeSelectClusterSuite : public TestCommand NextTest(); } - CHIP_ERROR TestChangeOnMode_13() + CHIP_ERROR TestChangeToUnsupportedOnMode_13() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; chip::Controller::ModeSelectClusterTest cluster; @@ -92479,7 +92558,7 @@ class TestModeSelectClusterSuite : public TestCommand chip::app::DataModel::Nullable onModeArgument; onModeArgument.SetNonNull(); - onModeArgument.Value() = 7; + onModeArgument.Value() = 2; ReturnErrorOnFailure(cluster.WriteAttribute( onModeArgument, this, OnSuccessCallback_13, OnFailureCallback_13)); @@ -92487,31 +92566,55 @@ class TestModeSelectClusterSuite : public TestCommand } void OnFailureResponse_13(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + } + + void OnSuccessResponse_13() { ThrowSuccessResponse(); } + + CHIP_ERROR TestChangeOnMode_14() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::ModeSelectClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + chip::app::DataModel::Nullable onModeArgument; + onModeArgument.SetNonNull(); + onModeArgument.Value() = 7; + + ReturnErrorOnFailure(cluster.WriteAttribute( + onModeArgument, this, OnSuccessCallback_14, OnFailureCallback_14)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_14(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_13() { NextTest(); } + void OnSuccessResponse_14() { NextTest(); } - CHIP_ERROR TestVerifyOnMode_14() + CHIP_ERROR TestVerifyOnMode_15() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; chip::Controller::ModeSelectClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); ReturnErrorOnFailure(cluster.ReadAttribute( - this, OnSuccessCallback_14, OnFailureCallback_14, true)); + this, OnSuccessCallback_15, OnFailureCallback_15, true)); return CHIP_NO_ERROR; } - void OnFailureResponse_14(CHIP_ERROR error) + void OnFailureResponse_15(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_14(const chip::app::DataModel::Nullable & onMode) + void OnSuccessResponse_15(const chip::app::DataModel::Nullable & onMode) { VerifyOrReturn(CheckValueNonNull("onMode", onMode)); VerifyOrReturn(CheckValue("onMode.Value()", onMode.Value(), 7)); @@ -92520,7 +92623,7 @@ class TestModeSelectClusterSuite : public TestCommand NextTest(); } - CHIP_ERROR TestToggleOnOff_15() + CHIP_ERROR TestToggleOnOff_16() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; using RequestType = chip::app::Clusters::OnOff::Commands::Off::Type; @@ -92528,26 +92631,26 @@ class TestModeSelectClusterSuite : public TestCommand RequestType request; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_15(); + (static_cast(context))->OnSuccessResponse_16(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_15(error); + (static_cast(context))->OnFailureResponse_16(error); }; ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_15(CHIP_ERROR error) + void OnFailureResponse_16(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_15() { NextTest(); } + void OnSuccessResponse_16() { NextTest(); } - CHIP_ERROR TestToggleOnOff_16() + CHIP_ERROR TestToggleOnOff_17() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; using RequestType = chip::app::Clusters::OnOff::Commands::On::Type; @@ -92555,50 +92658,50 @@ class TestModeSelectClusterSuite : public TestCommand RequestType request; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_16(); + (static_cast(context))->OnSuccessResponse_17(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_16(error); + (static_cast(context))->OnFailureResponse_17(error); }; ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_16(CHIP_ERROR error) + void OnFailureResponse_17(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_16() { NextTest(); } + void OnSuccessResponse_17() { NextTest(); } - CHIP_ERROR TestVerifyCurrentModeChangesIfOnModeIsNotNull_17() + CHIP_ERROR TestVerifyCurrentModeChangesIfOnModeIsNotNull_18() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; chip::Controller::ModeSelectClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); ReturnErrorOnFailure(cluster.ReadAttribute( - this, OnSuccessCallback_17, OnFailureCallback_17, true)); + this, OnSuccessCallback_18, OnFailureCallback_18, true)); return CHIP_NO_ERROR; } - void OnFailureResponse_17(CHIP_ERROR error) + void OnFailureResponse_18(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_17(uint8_t currentMode) + void OnSuccessResponse_18(uint8_t currentMode) { VerifyOrReturn(CheckValue("currentMode", currentMode, OnModeValue)); NextTest(); } - CHIP_ERROR TestChangeToUnsupportedStartUpMode_18() + CHIP_ERROR TestChangeToUnsupportedStartUpMode_19() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; chip::Controller::ModeSelectClusterTest cluster; @@ -92609,20 +92712,20 @@ class TestModeSelectClusterSuite : public TestCommand startUpModeArgument.Value() = 2; ReturnErrorOnFailure(cluster.WriteAttribute( - startUpModeArgument, this, OnSuccessCallback_18, OnFailureCallback_18)); + startUpModeArgument, this, OnSuccessCallback_19, OnFailureCallback_19)); return CHIP_NO_ERROR; } - void OnFailureResponse_18(CHIP_ERROR error) + void OnFailureResponse_19(CHIP_ERROR error) { chip::app::StatusIB status(error); VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); NextTest(); } - void OnSuccessResponse_18() { ThrowSuccessResponse(); } + void OnSuccessResponse_19() { ThrowSuccessResponse(); } - CHIP_ERROR TestChangeToSupportedStartUpMode_19() + CHIP_ERROR TestChangeToSupportedStartUpMode_20() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; chip::Controller::ModeSelectClusterTest cluster; @@ -92633,36 +92736,36 @@ class TestModeSelectClusterSuite : public TestCommand startUpModeArgument.Value() = 7; ReturnErrorOnFailure(cluster.WriteAttribute( - startUpModeArgument, this, OnSuccessCallback_19, OnFailureCallback_19)); + startUpModeArgument, this, OnSuccessCallback_20, OnFailureCallback_20)); return CHIP_NO_ERROR; } - void OnFailureResponse_19(CHIP_ERROR error) + void OnFailureResponse_20(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_19() { NextTest(); } + void OnSuccessResponse_20() { NextTest(); } - CHIP_ERROR TestVerifyStartUpModeChange_20() + CHIP_ERROR TestVerifyStartUpModeChange_21() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; chip::Controller::ModeSelectClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); ReturnErrorOnFailure(cluster.ReadAttribute( - this, OnSuccessCallback_20, OnFailureCallback_20, true)); + this, OnSuccessCallback_21, OnFailureCallback_21, true)); return CHIP_NO_ERROR; } - void OnFailureResponse_20(CHIP_ERROR error) + void OnFailureResponse_21(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_20(const chip::app::DataModel::Nullable & startUpMode) + void OnSuccessResponse_21(const chip::app::DataModel::Nullable & startUpMode) { VerifyOrReturn(CheckValueNonNull("startUpMode", startUpMode)); VerifyOrReturn(CheckValue("startUpMode.Value()", startUpMode.Value(), 7)); @@ -92670,7 +92773,7 @@ class TestModeSelectClusterSuite : public TestCommand NextTest(); } - CHIP_ERROR TestChangeCurrentModeToAnotherValue_21() + CHIP_ERROR TestChangeCurrentModeToAnotherValue_22() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; using RequestType = chip::app::Clusters::ModeSelect::Commands::ChangeToMode::Type; @@ -92679,55 +92782,159 @@ class TestModeSelectClusterSuite : public TestCommand request.newMode = 0; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_21(); + (static_cast(context))->OnSuccessResponse_22(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_21(error); + (static_cast(context))->OnFailureResponse_22(error); }; ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_21(CHIP_ERROR error) + void OnFailureResponse_22(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_21() { NextTest(); } + void OnSuccessResponse_22() { NextTest(); } - CHIP_ERROR TestRebootTargetDevice_22() + CHIP_ERROR TestChangeOnMode_23() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::ModeSelectClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + chip::app::DataModel::Nullable onModeArgument; + onModeArgument.SetNonNull(); + onModeArgument.Value() = 4; + + ReturnErrorOnFailure(cluster.WriteAttribute( + onModeArgument, this, OnSuccessCallback_23, OnFailureCallback_23)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_23(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_23() { NextTest(); } + + CHIP_ERROR TestSetStartUpOnOff_24() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::OnOffClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + chip::app::DataModel::Nullable startUpOnOffArgument; + startUpOnOffArgument.SetNonNull(); + startUpOnOffArgument.Value() = static_cast(1); + + ReturnErrorOnFailure(cluster.WriteAttribute( + startUpOnOffArgument, this, OnSuccessCallback_24, OnFailureCallback_24)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_24(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_24() { NextTest(); } + + CHIP_ERROR TestRebootTargetDevice_25() { SetIdentity(kIdentityAlpha); return Reboot(mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U); } - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_23() + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_26() { SetIdentity(kIdentityAlpha); return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); } - CHIP_ERROR TestVerifyCurrentModeChangeBasedOnNewStartUpMode_24() + CHIP_ERROR TestVerifyCurrentModeChangeBasedOnOnModeAsItOverwritesStartUpMode_27() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; chip::Controller::ModeSelectClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); ReturnErrorOnFailure(cluster.ReadAttribute( - this, OnSuccessCallback_24, OnFailureCallback_24, true)); + this, OnSuccessCallback_27, OnFailureCallback_27, true)); return CHIP_NO_ERROR; } - void OnFailureResponse_24(CHIP_ERROR error) + void OnFailureResponse_27(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_27(uint8_t currentMode) + { + VerifyOrReturn(CheckValue("currentMode", currentMode, 4)); + + NextTest(); + } + + CHIP_ERROR TestChangeOnModeToNull_28() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::ModeSelectClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + chip::app::DataModel::Nullable onModeArgument; + onModeArgument.SetNull(); + + ReturnErrorOnFailure(cluster.WriteAttribute( + onModeArgument, this, OnSuccessCallback_28, OnFailureCallback_28)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_28(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_28() { NextTest(); } + + CHIP_ERROR TestRebootTargetDevice_29() + { + SetIdentity(kIdentityAlpha); + return Reboot(mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_30() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR TestVerifyCurrentModeChangeBasedOnNewStartUpMode_31() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::ModeSelectClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_31, OnFailureCallback_31, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_31(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_24(uint8_t currentMode) + void OnSuccessResponse_31(uint8_t currentMode) { VerifyOrReturn(CheckValue("currentMode", currentMode, 7));