blob: 635daa12fb2163c70177ef92a2cfb262823ffb6c [file]
/*
* Copyright (c) 2024-2026 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.
*/
#pragma once
#include <app/clusters/commissioner-control-server/Delegate.h>
#include <app/server-cluster/DefaultServerCluster.h>
#include <clusters/CommissionerControl/Commands.h>
#include <clusters/CommissionerControl/Enums.h>
#include <clusters/CommissionerControl/Events.h>
namespace chip::app::Clusters {
class CommissionerControlCluster : public DefaultServerCluster
{
public:
CommissionerControlCluster(EndpointId endpointId, CommissionerControl::Delegate & delegate);
// Server cluster implementation
DataModel::ActionReturnStatus ReadAttribute(const DataModel::ReadAttributeRequest & request,
AttributeValueEncoder & encoder) override;
CHIP_ERROR Attributes(const ConcreteClusterPath & path, ReadOnlyBufferBuilder<DataModel::AttributeEntry> & builder) override;
std::optional<DataModel::ActionReturnStatus> InvokeCommand(const DataModel::InvokeRequest & request,
TLV::TLVReader & input_arguments, CommandHandler * handler) override;
CHIP_ERROR AcceptedCommands(const ConcreteClusterPath & path,
ReadOnlyBufferBuilder<DataModel::AcceptedCommandEntry> & builder) override;
CHIP_ERROR GeneratedCommands(const ConcreteClusterPath & path, ReadOnlyBufferBuilder<CommandId> & builder) override;
void SetSupportedDeviceCategories(const BitMask<CommissionerControl::SupportedDeviceCategoryBitmap> supportedDeviceCategories);
BitMask<CommissionerControl::SupportedDeviceCategoryBitmap> GetSupportedDeviceCategories() const
{
return mSupportedDeviceCategories;
}
// Should be called after the server return SUCCESS to a correctly formatted RequestCommissioningApproval command.
void GenerateCommissioningRequestResultEvent(const CommissionerControl::Events::CommissioningRequestResult::Type & result);
private:
CommissionerControl::Delegate & mDelegate;
BitMask<CommissionerControl::SupportedDeviceCategoryBitmap> mSupportedDeviceCategories;
std::optional<DataModel::ActionReturnStatus> HandleRequestCommissioningApproval(
CommandHandler * commandObj, const ConcreteCommandPath & commandPath,
const CommissionerControl::Commands::RequestCommissioningApproval::DecodableType & commandData);
std::optional<DataModel::ActionReturnStatus>
HandleCommissionNode(CommandHandler * commandObj, const ConcreteCommandPath & commandPath,
const CommissionerControl::Commands::CommissionNode::DecodableType & commandData);
};
} // namespace chip::app::Clusters