diff --git a/src/app/clusters/operational-state-server/operational-state-server.cpp b/src/app/clusters/operational-state-server/operational-state-server.cpp index b3fd2d89523f00..a91f13d2f257a5 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.cpp +++ b/src/app/clusters/operational-state-server/operational-state-server.cpp @@ -113,7 +113,11 @@ void OperationalStateServer::HandlePauseState(HandlerContext & ctx, const Comman VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); uint8_t opState = delegate->GetCurrentOperationalState(); - if (opState != to_underlying(OperationalStateEnum::kPaused)) + if (opState != to_underlying(OperationalStateEnum::kPaused) && opState != to_underlying(OperationalStateEnum::kRunning)) + { + err.Set(to_underlying(ErrorStateEnum::kCommandInvalidInState)); + } + else if (opState != to_underlying(OperationalStateEnum::kPaused)) { delegate->HandlePauseStateCallback(err); } diff --git a/src/app/tests/suites/TestRVCOperationalState.yaml b/src/app/tests/suites/TestRVCOperationalState.yaml index 3a52d89fb7ad00..de40e7f6088be1 100644 --- a/src/app/tests/suites/TestRVCOperationalState.yaml +++ b/src/app/tests/suites/TestRVCOperationalState.yaml @@ -89,26 +89,26 @@ tests: response: values: - name: "CommandResponseState" - value: { ErrorStateID: 0 } + value: { ErrorStateID: 3 } - label: "Read current Operational State" command: "readAttribute" attribute: "OperationalState" response: - value: 2 + value: 0 - label: "Resume Command" command: "Resume" response: values: - name: "CommandResponseState" - value: { ErrorStateID: 0 } + value: { ErrorStateID: 3 } - label: "Read current Operational State" command: "readAttribute" attribute: "OperationalState" response: - value: 1 + value: 0 - label: "Stop Command" command: "Stop" @@ -119,4 +119,4 @@ tests: command: "readAttribute" attribute: "OperationalState" response: - value: 1 + value: 0 diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index cad0d50b715b57..2c0cce594e24a3 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -96662,7 +96662,7 @@ class TestRVCOperationalStateSuite : public TestCommand { chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 0U)); + VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 3U)); } break; case 10: @@ -96670,7 +96670,7 @@ class TestRVCOperationalStateSuite : public TestCommand { uint8_t value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState", value, 2U)); + VerifyOrReturn(CheckValue("operationalState", value, 0U)); } break; case 11: @@ -96678,7 +96678,7 @@ class TestRVCOperationalStateSuite : public TestCommand { chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 0U)); + VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 3U)); } break; case 12: @@ -96686,7 +96686,7 @@ class TestRVCOperationalStateSuite : public TestCommand { uint8_t value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState", value, 1U)); + VerifyOrReturn(CheckValue("operationalState", value, 0U)); } break; case 13: @@ -96697,7 +96697,7 @@ class TestRVCOperationalStateSuite : public TestCommand { uint8_t value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState", value, 1U)); + VerifyOrReturn(CheckValue("operationalState", value, 0U)); } break; default: diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index fcad5b306ce5ab..2dc568d1ef81d4 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -142893,7 +142893,7 @@ class TestRVCOperationalState : public TestCommandBridge { { id actualValue = values.commandResponseState; VerifyOrReturn( - CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 3U)); } NextTest(); @@ -142918,7 +142918,7 @@ class TestRVCOperationalState : public TestCommandBridge { { id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 2U)); + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); } NextTest(); @@ -142945,7 +142945,7 @@ class TestRVCOperationalState : public TestCommandBridge { { id actualValue = values.commandResponseState; VerifyOrReturn( - CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 3U)); } NextTest(); @@ -142970,7 +142970,7 @@ class TestRVCOperationalState : public TestCommandBridge { { id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 1U)); + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); } NextTest(); @@ -143017,7 +143017,7 @@ class TestRVCOperationalState : public TestCommandBridge { { id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 1U)); + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); } NextTest();