Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/InteractionModelEngine.h>
#include <app/clusters/basic-information/DeviceLayerBasicInformationDelegate.h>
#include <app/clusters/groupcast/GroupcastCluster.h>
#include <app/clusters/groupcast/GroupcastContext.h>
#include <lib/support/CHIPMem.h>
Expand Down Expand Up @@ -48,14 +49,13 @@ CHIP_ERROR RootNodeDevice::Register(EndpointId endpointId, CodeDrivenDataModelPr
.Set<BasicInformation::Attributes::LocalConfigDisabled::Id>()
.Set<BasicInformation::Attributes::Reachable::Id>();

mBasicInformationCluster.Create(
optionalAttributeSet,
BasicInformationCluster::Context{
.deviceInstanceInfoProvider = mContext.deviceInstanceInfoProvider,
.configurationManager = mContext.configurationManager,
.platformManager = mContext.platformManager,
.subscriptionsPerFabric = InteractionModelEngine::GetInstance()->GetMinGuaranteedSubscriptionsPerFabric(),
});
static chip::app::Clusters::BasicInformation::DeviceLayerBasicInformationDelegate delegate({
.deviceInstanceInfoProvider = mContext.deviceInstanceInfoProvider,
.configurationManager = mContext.configurationManager,
.platformManager = mContext.platformManager,
.subscriptionsPerFabric = InteractionModelEngine::GetInstance()->GetMinGuaranteedSubscriptionsPerFabric(),
});
mBasicInformationCluster.Create(optionalAttributeSet, &delegate, mContext.platformManager);

ReturnErrorOnFailure(provider.AddCluster(mBasicInformationCluster.Registration()));
mGeneralCommissioningCluster.Create(
Expand Down
3 changes: 3 additions & 0 deletions src/app/clusters/basic-information/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ source_set("basic-information") {
sources = [
"BasicInformationCluster.cpp",
"BasicInformationCluster.h",
"BasicInformationDelegate.h",
"DeviceLayerBasicInformationDelegate.cpp",
"DeviceLayerBasicInformationDelegate.h",
]
public_deps = [
"${chip_root}/src/app:constants",
Expand Down
316 changes: 78 additions & 238 deletions src/app/clusters/basic-information/BasicInformationCluster.cpp

Large diffs are not rendered by default.

23 changes: 8 additions & 15 deletions src/app/clusters/basic-information/BasicInformationCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
*/
#pragma once

#include <app/clusters/basic-information/BasicInformationDelegate.h>
#include <app/persistence/String.h>
#include <app/server-cluster/DefaultServerCluster.h>
#include <app/server-cluster/OptionalAttributeSet.h>
#include <clusters/BasicInformation/AttributeIds.h>
#include <clusters/BasicInformation/ClusterId.h>
#include <lib/core/DataModelTypes.h>
#include <platform/ConfigurationManager.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/PlatformManager.h>

namespace chip {
Expand All @@ -38,15 +37,6 @@ namespace Clusters {
class BasicInformationCluster : public DefaultServerCluster, public DeviceLayer::PlatformManagerDelegate
{
public:
// Define the Context struct with References
struct Context
{
DeviceLayer::DeviceInstanceInfoProvider & deviceInstanceInfoProvider;
DeviceLayer::ConfigurationManager & configurationManager;
DeviceLayer::PlatformManager & platformManager;
uint16_t subscriptionsPerFabric;
};

using OptionalAttributesSet = chip::app::OptionalAttributeSet< //
BasicInformation::Attributes::ManufacturingDate::Id, //
BasicInformation::Attributes::PartNumber::Id, //
Expand All @@ -62,9 +52,11 @@ class BasicInformationCluster : public DefaultServerCluster, public DeviceLayer:
BasicInformation::Attributes::UniqueID::Id //
>;

BasicInformationCluster(OptionalAttributesSet optionalAttributeSet, Context ctx) :
DefaultServerCluster({ kRootEndpointId, BasicInformation::Id }), mEnabledOptionalAttributes(optionalAttributeSet),
mClusterContext(ctx)
BasicInformationCluster(OptionalAttributesSet optionalAttributeSet, BasicInformation::BasicInformationDelegate * delegate,
DeviceLayer::PlatformManager & platformManager) :
DefaultServerCluster({ kRootEndpointId, BasicInformation::Id }),
mEnabledOptionalAttributes(optionalAttributeSet), mDelegate(delegate), mPlatformManager(platformManager)

{
mEnabledOptionalAttributes
.Set<BasicInformation::Attributes::UniqueID::Id>(); // Unless told otherwise, unique id is mandatory
Expand Down Expand Up @@ -109,7 +101,8 @@ class BasicInformationCluster : public DefaultServerCluster, public DeviceLayer:
OptionalAttributesSet mEnabledOptionalAttributes;

Storage::String<32> mNodeLabel;
Context mClusterContext;
BasicInformation::BasicInformationDelegate * mDelegate;
DeviceLayer::PlatformManager & mPlatformManager;
};

} // namespace Clusters
Expand Down
58 changes: 58 additions & 0 deletions src/app/clusters/basic-information/BasicInformationDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 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 <cstdint>

#include <clusters/BasicInformation/Enums.h>
#include <clusters/BasicInformation/Structs.h>
#include <lib/core/CHIPError.h>
#include <lib/core/DataModelTypes.h>
#include <lib/support/Span.h>
#include <platform/DeviceInstanceInfoProvider.h>

namespace chip {
namespace app {
namespace Clusters {
namespace BasicInformation {

class BasicInformationDelegate
{
public:
virtual ~BasicInformationDelegate() = default;

// String Getters
virtual CHIP_ERROR GetStringAttribute(chip::AttributeId attributeId, MutableCharSpan & buffer) = 0;

// Numeric Getters
virtual CHIP_ERROR GetNumericAttribute(chip::AttributeId attributeId, uint32_t & value) = 0;

// Value Getters
virtual CHIP_ERROR GetProductAppearance(Structs::ProductAppearanceStruct::Type & outProductAppearance) = 0;
virtual CHIP_ERROR GetLocalConfigDisabled(bool & localConfigDisabled) = 0;
virtual CHIP_ERROR GetCapabilityMinima(Structs::CapabilityMinimaStruct::Type & outCapabilityMinima) = 0;

// Setters
virtual CHIP_ERROR SetLocalConfigDisabled(bool localConfigDisabled) = 0;
virtual CHIP_ERROR StoreConfigurationVersion(uint32_t configurationVersion) = 0;
virtual CHIP_ERROR StoreLocation(const CharSpan & code) = 0;
};

} // namespace BasicInformation
} // namespace Clusters
} // namespace app
} // namespace chip
14 changes: 7 additions & 7 deletions src/app/clusters/basic-information/CodegenIntegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/InteractionModelEngine.h>
#include <app/clusters/basic-information/BasicInformationCluster.h>
#include <app/clusters/basic-information/DeviceLayerBasicInformationDelegate.h>
#include <app/static-cluster-config/BasicInformation.h>
#include <app/util/attribute-storage.h>
#include <app/util/endpoint-config-api.h>
Expand Down Expand Up @@ -63,13 +64,12 @@ class IntegrationDelegate : public CodegenClusterIntegration::Delegate
DeviceLayer::DeviceInstanceInfoProvider * provider = DeviceLayer::GetDeviceInstanceInfoProvider();
VerifyOrDie(provider != nullptr);

BasicInformationCluster::Context context = {
.deviceInstanceInfoProvider = *provider,
.configurationManager = DeviceLayer::ConfigurationMgr(),
.platformManager = DeviceLayer::PlatformMgr(),
.subscriptionsPerFabric = InteractionModelEngine::GetInstance()->GetMinGuaranteedSubscriptionsPerFabric()
};
gServer.Create(optionalAttributeSet, context);
static chip::app::Clusters::BasicInformation::DeviceLayerBasicInformationDelegate delegate(
{ .deviceInstanceInfoProvider = *provider,
.configurationManager = DeviceLayer::ConfigurationMgr(),
.platformManager = DeviceLayer::PlatformMgr(),
.subscriptionsPerFabric = InteractionModelEngine::GetInstance()->GetMinGuaranteedSubscriptionsPerFabric() });
gServer.Create(optionalAttributeSet, &delegate, DeviceLayer::PlatformMgr());

// This disabling of the unique id attribute is here only for test purposes. The uniqe id attribute
// is mandatory, but was optional in previous versions. It is forced to be enabled in the basic information
Expand Down
Loading
Loading