@@ -632,27 +632,20 @@ chip::Protocols::InteractionModel::Status ClosureManager::OnMoveToCommand(const
632632 }
633633 }
634634
635- if (mClosurePanelEndpoint2 .GetLogic ().SetTargetState (DataModel::MakeNullable (mClosurePanelEndpoint2Target )) != CHIP_NO_ERROR)
636- {
637- ChipLogError (AppServer, " Failed to set target for Endpoint 2" );
638- return Status::Failure;
639- }
640-
641- if (mClosurePanelEndpoint3 .GetLogic ().SetTargetState (DataModel::MakeNullable (mClosurePanelEndpoint3Target )) != CHIP_NO_ERROR)
642- {
643- ChipLogError (AppServer, " Failed to set target for Endpoint 3" );
644- return Status::Failure;
645- }
635+ VerifyOrReturnError (mClosurePanelEndpoint2 .GetLogic ().SetTargetState (DataModel::MakeNullable (mClosurePanelEndpoint2Target )) ==
636+ CHIP_NO_ERROR,
637+ Status::Failure, ChipLogError (AppServer, " Failed to set target for Endpoint 2" ));
638+ VerifyOrReturnError (mClosurePanelEndpoint3 .GetLogic ().SetTargetState (DataModel::MakeNullable (mClosurePanelEndpoint3Target )) ==
639+ CHIP_NO_ERROR,
640+ Status::Failure, ChipLogError (AppServer, " Failed to set target for Endpoint 3" ));
646641
647- if (mClosureEndpoint1 .GetLogic ().SetCountdownTimeFromDelegate (kDefaultCountdownTimeSeconds ) != CHIP_NO_ERROR)
648- {
649- ChipLogError (AppServer, " Failed to set countdown time for move to command on Endpoint 1" );
650- return Status::Failure;
651- }
642+ VerifyOrReturnError (mClosureEndpoint1 .GetLogic ().SetCountdownTimeFromDelegate (kDefaultCountdownTimeSeconds ) == CHIP_NO_ERROR,
643+ Status::Failure, ChipLogError (AppServer, " Failed to set countdown time for move to command on Endpoint 1" ));
652644
653645 // Set the current action to UNLATCH_ACTION if Latching feature is supported.
654646 // This is to ensure that the closure is unlatched before starting the motion action.
655647 // The Closure Control Cluster will handle the unlatch action before proceeding with the motion action.
648+ DeviceLayer::PlatformMgr ().LockChipStack ();
656649 if (mClosureEndpoint1 .GetLogic ().GetConformance ().HasFeature (ClosureControl::Feature::kMotionLatching ))
657650 {
658651 SetCurrentAction (UNLATCH_ACTION);
@@ -662,6 +655,7 @@ chip::Protocols::InteractionModel::Status ClosureManager::OnMoveToCommand(const
662655 SetCurrentAction (MOVE_TO_ACTION);
663656 }
664657 mIsMoveToInProgress = true ;
658+ DeviceLayer::PlatformMgr ().UnlockChipStack ();
665659
666660 // Post an event to initiate the move to action asynchronously.
667661 // MoveTo Command can only be initiated from Closure Control Endpoint (Endpoint 1).
@@ -821,12 +815,8 @@ chip::Protocols::InteractionModel::Status ClosureManager::OnSetTargetCommand(con
821815 const chip::EndpointId endpointId)
822816{
823817 MainStateEnum mClosureEndpoint1MainState ;
824- if (mClosureEndpoint1 .GetLogic ().GetMainState (mClosureEndpoint1MainState ) != CHIP_NO_ERROR)
825- {
826- ChipLogError (AppServer, " Failed to get main state for SetTarget command on Endpoint 1" );
827- return Status::Failure;
828- }
829-
818+ VerifyOrReturnError (mClosureEndpoint1 .GetLogic ().GetMainState (mClosureEndpoint1MainState ) == CHIP_NO_ERROR, Status::Failure,
819+ ChipLogError (AppServer, " Failed to get main state for SetTarget command on Endpoint 1" ));
830820
831821 // If this command is received while the MainState attribute is currently either in Disengaged, Protected, Calibrating,
832822 // SetupRequired or Error, then a status code of INVALID_IN_STATE shall be returned.
@@ -1110,18 +1100,9 @@ chip::Protocols::InteractionModel::Status ClosureManager::OnStepCommand(const St
11101100 const Optional<Globals::ThreeLevelAutoEnum> & speed,
11111101 const chip::EndpointId & endpointId)
11121102{
1113- // Lock chip stack to safely access cluster state
1114- DeviceLayer::PlatformMgr ().LockChipStack ();
1115-
11161103 MainStateEnum mClosureEndpoint1MainState ;
1117- if (mClosureEndpoint1 .GetLogic ().GetMainState (mClosureEndpoint1MainState ) != CHIP_NO_ERROR)
1118- {
1119- DeviceLayer::PlatformMgr ().UnlockChipStack ();
1120- ChipLogError (AppServer, " Failed to get main state for Step command on Endpoint 1" );
1121- return Status::Failure;
1122- }
1123-
1124- DeviceLayer::PlatformMgr ().UnlockChipStack ();
1104+ VerifyOrReturnError (mClosureEndpoint1 .GetLogic ().GetMainState (mClosureEndpoint1MainState ) == CHIP_NO_ERROR, Status::Failure,
1105+ ChipLogError (AppServer, " Failed to get main state for Step command on Endpoint 1" ));
11251106
11261107 // If this command is received while the MainState attribute is currently either in Disengaged, Protected, Calibrating,
11271108 // SetupRequired or Error, then a status code of INVALID_IN_STATE shall be returned.
0 commit comments