blob: 9fd2bd5d3a5b7432225174afa7ce543c8bb2489a [file] [log] [blame]
/**
*
* Copyright (c) 2025 Project CHIP Authors
*
* 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 <app/clusters/access-control-server/access-control-cluster.h>
#include <app/static-cluster-config/AccessControl.h>
#include <app/util/config.h>
#include <app/util/generic-callbacks.h>
#include <data-model-providers/codegen/ClusterIntegration.h>
namespace {
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::AccessControl;
static_assert((AccessControl::StaticApplicationConfig::kFixedClusterConfig.size() == 1 &&
AccessControl::StaticApplicationConfig::kFixedClusterConfig[0].endpointNumber == kRootEndpointId) ||
AccessControl::StaticApplicationConfig::kFixedClusterConfig.size() == 0);
LazyRegisteredServerCluster<AccessControlCluster> gServer;
class IntegrationDelegate : public CodegenClusterIntegration::Delegate
{
public:
ServerClusterRegistration & CreateRegistration(EndpointId endpointId, unsigned clusterInstanceIndex,
uint32_t optionalAttributeBits, uint32_t featureMap) override
{
gServer.Create();
return gServer.Registration();
}
ServerClusterInterface * FindRegistration(unsigned clusterInstanceIndex) override
{
VerifyOrReturnValue(gServer.IsConstructed(), nullptr);
return &gServer.Cluster();
}
void ReleaseRegistration(unsigned clusterInstanceIndex) override { gServer.Destroy(); }
};
} // namespace
void MatterAccessControlClusterInitCallback(EndpointId endpointId)
{
IntegrationDelegate integrationDelegate;
CodegenClusterIntegration::RegisterServer(
{
.endpointId = endpointId,
.clusterId = AccessControl::Id,
.fixedClusterInstanceCount = AccessControl::StaticApplicationConfig::kFixedClusterConfig.size(),
.maxClusterInstanceCount = 1, // Cluster is a singleton on the root node and this is the only thing supported
.fetchFeatureMap = false,
.fetchOptionalAttributes = false,
},
integrationDelegate);
}
void MatterAccessControlClusterShutdownCallback(EndpointId endpointId, MatterClusterShutdownType shutdownType)
{
IntegrationDelegate integrationDelegate;
CodegenClusterIntegration::UnregisterServer(
{
.endpointId = endpointId,
.clusterId = AccessControl::Id,
.fixedClusterInstanceCount = AccessControl::StaticApplicationConfig::kFixedClusterConfig.size(),
.maxClusterInstanceCount = 1, // Cluster is a singleton on the root node and this is the only thing supported
},
integrationDelegate, shutdownType);
}
void MatterAccessControlPluginServerInitCallback() {}
void MatterAccessControlPluginServerShutdownCallback() {}