blob: 3a49f927d4e440ca396615027e38cfaedf77d374 [file]
/*
*
* Copyright (c) 2025 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ClosureControlEndpoint.h>
#include <app-common/zap-generated/cluster-enums.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <protocols/interaction_model/StatusCode.h>
using namespace chip;
using namespace chip::app::Clusters::ClosureControl;
using Protocols::InteractionModel::Status;
namespace {
constexpr ElapsedS kDefaultCountdownTime = 30;
} // namespace
Status PrintOnlyDelegate::HandleCalibrateCommand()
{
ChipLogProgress(AppServer, "HandleCalibrateCommand");
// Add the calibration logic here
return Status::Success;
}
Status PrintOnlyDelegate::HandleMoveToCommand(const Optional<TargetPositionEnum> & position, const Optional<bool> & latch,
const Optional<Globals::ThreeLevelAutoEnum> & speed)
{
ChipLogProgress(AppServer, "HandleMoveToCommand");
// Add the move to logic here
return Status::Success;
}
Status PrintOnlyDelegate::HandleStopCommand()
{
ChipLogProgress(AppServer, "HandleStopCommand");
// Add the stop logic here
return Status::Success;
}
CHIP_ERROR PrintOnlyDelegate::GetCurrentErrorAtIndex(size_t index, ClosureErrorEnum & closureError)
{
// This function should return the current error at the specified index.
// For now, we dont have a ErrorList implemented, so will return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED.
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
}
bool PrintOnlyDelegate::IsReadyToMove()
{
// This function should return true if the closure is ready to move.
// For now, we will return true.
return true;
}
bool PrintOnlyDelegate::IsManualLatchingNeeded()
{
// This function should return true if manual latching is needed.
// For now, we will return false.
return false;
}
ElapsedS PrintOnlyDelegate::GetCalibrationCountdownTime()
{
// This function should return the calibration countdown time.
// For now, we will return kDefaultCountdownTime.
return kDefaultCountdownTime;
}
ElapsedS PrintOnlyDelegate::GetMovingCountdownTime()
{
// This function should return the moving countdown time.
// For now, we will return kDefaultCountdownTime.
return kDefaultCountdownTime;
}
ElapsedS PrintOnlyDelegate::GetWaitingForMotionCountdownTime()
{
// This function should return the waiting for motion countdown time.
// For now, we will return kDefaultCountdownTime.
return kDefaultCountdownTime;
}
CHIP_ERROR ClosureControlEndpoint::Init()
{
ClusterConformance conformance;
conformance.FeatureMap()
.Set(Feature::kPositioning)
.Set(Feature::kMotionLatching)
.Set(Feature::kSpeed)
.Set(Feature::kVentilation)
.Set(Feature::kPedestrian)
.Set(Feature::kCalibration)
.Set(Feature::kProtection)
.Set(Feature::kManuallyOperable);
conformance.OptionalAttributes().Set(OptionalAttributeEnum::kCountdownTime);
ClusterInitParameters initParams;
ReturnErrorOnFailure(mLogic.Init(conformance, initParams));
ReturnErrorOnFailure(mInterface.Init());
return CHIP_NO_ERROR;
}