From 469c1eedbf52f1fbe11d41b89b1cf4163276c126 Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs <112982107+lpbeliveau-silabs@users.noreply.github.com> Date: Tue, 10 Oct 2023 09:18:19 -0400 Subject: [PATCH] Applied fixes to be compliant with scenes test plan (#29598) --- src/app/clusters/level-control/level-control.cpp | 16 ++++++++-------- .../clusters/scenes-server/SceneTableImpl.cpp | 4 +++- src/app/clusters/scenes-server/scenes-server.cpp | 14 +++++++++----- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/app/clusters/level-control/level-control.cpp b/src/app/clusters/level-control/level-control.cpp index 28f7c16573d86f..c7e376aa5a99f3 100644 --- a/src/app/clusters/level-control/level-control.cpp +++ b/src/app/clusters/level-control/level-control.cpp @@ -419,14 +419,6 @@ void emberAfLevelControlClusterServerTickCallback(EndpointId endpoint) updateCoupledColorTemp(endpoint); -#ifdef EMBER_AF_PLUGIN_SCENES - // The level has changed, so the scene is no longer valid. - if (emberAfContainsServer(endpoint, Scenes::Id)) - { - Scenes::ScenesServer::Instance().MakeSceneInvalid(endpoint); - } -#endif // EMBER_AF_PLUGIN_SCENES - // Are we at the requested level? if (currentLevel.Value() == state->moveToLevel) { @@ -918,6 +910,14 @@ static Status moveToLevelHandler(EndpointId endpoint, CommandId commandId, uint8 state->callbackSchedule.runTime = System::Clock::Milliseconds32(0); +#ifdef EMBER_AF_PLUGIN_SCENES + // The level has changed, the scene is no longer valid. + if (emberAfContainsServer(endpoint, Scenes::Id)) + { + Scenes::ScenesServer::Instance().MakeSceneInvalid(endpoint); + } +#endif // EMBER_AF_PLUGIN_SCENES + // The setup was successful, so mark the new state as active and return. scheduleTimerCallbackMs(endpoint, computeCallbackWaitTimeMs(state->callbackSchedule, state->eventDurationMs)); diff --git a/src/app/clusters/scenes-server/SceneTableImpl.cpp b/src/app/clusters/scenes-server/SceneTableImpl.cpp index 70ad7ab9325cda..ea894c9d1d108c 100644 --- a/src/app/clusters/scenes-server/SceneTableImpl.cpp +++ b/src/app/clusters/scenes-server/SceneTableImpl.cpp @@ -767,7 +767,9 @@ CHIP_ERROR DefaultSceneTableImpl::DeleteAllScenesInGroup(FabricIndex fabric_inde FabricSceneData fabric(mEndpointId, fabric_index, mMaxScenesPerFabric, mMaxScenesPerEndpoint); SceneTableData scene(mEndpointId, fabric_index); - ReturnErrorOnFailure(fabric.Load(mStorage)); + CHIP_ERROR err = fabric.Load(mStorage); + VerifyOrReturnValue(CHIP_ERROR_NOT_FOUND != err, CHIP_NO_ERROR); + ReturnErrorOnFailure(err); for (uint16_t i = 0; i < mMaxScenesPerFabric; i++) { diff --git a/src/app/clusters/scenes-server/scenes-server.cpp b/src/app/clusters/scenes-server/scenes-server.cpp index 9fe876315cdf5a..92eb4720a4a72e 100644 --- a/src/app/clusters/scenes-server/scenes-server.cpp +++ b/src/app/clusters/scenes-server/scenes-server.cpp @@ -718,11 +718,15 @@ void ScenesServer::HandleRecallScene(HandlerContext & ctx, const Commands::Recal if (CHIP_NO_ERROR == err) { status = Attributes::SceneValid::Set(ctx.mRequestPath.mEndpointId, true); - if (EMBER_ZCL_STATUS_SUCCESS != status) - { - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, ToInteractionModelStatus(status)); - return; - } + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, ToInteractionModelStatus(status)); + return; + } + + if (CHIP_ERROR_NOT_FOUND == err) + { + // TODO : implement proper mapping between CHIP_ERROR and IM Status + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::NotFound); + return; } ctx.mCommandHandler.AddStatus(ctx.mRequestPath, StatusIB(err).mStatus);