Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
f0adceb
Start some prototypes
andreilitvin Aug 12, 2025
924553a
More integration
andreilitvin Aug 12, 2025
91cb98f
More work
andreilitvin Aug 12, 2025
cf9c67e
Restyle
andreilitvin Aug 12, 2025
c66614a
Update attributes sets a bit to help for more generic code
andreilitvin Aug 12, 2025
cf639b5
Comment update
andreilitvin Aug 12, 2025
37d84a0
General diangostics integration: this seems to cost too much right now
andreilitvin Aug 12, 2025
df42029
Start seeing some savings afte wifi cluste migration. We are now at 2…
andreilitvin Aug 12, 2025
6a9a706
Another update, we are at 124 bytes of overhead
andreilitvin Aug 12, 2025
0e03026
Code size diff is now 100% a wash
andreilitvin Aug 12, 2025
9c32d7c
All attributes logic...
andreilitvin Aug 12, 2025
337fec7
Slight API cleanup
andreilitvin Aug 12, 2025
15236e6
Add some unit tests
andreilitvin Aug 12, 2025
45d9995
Slightly shorter code
andreilitvin Aug 12, 2025
2832aa2
Restyled by clang-format
restyled-commits Aug 12, 2025
7000db5
Use maxendpointcount be 1
andreilitvin Aug 12, 2025
d08eff6
Fix conditional
andreilitvin Aug 12, 2025
4eddafe
Fix typo
andreilitvin Aug 12, 2025
5c25b46
Fix copy and paste
andreilitvin Aug 12, 2025
ec2021e
Update data type
andreilitvin Aug 12, 2025
2c24c44
Fix typo
andreilitvin Aug 12, 2025
fe2e5e3
Remove %u check ... althouhg this is silly...
andreilitvin Aug 12, 2025
b2be556
Merge branch 'master' into centralize_codegen_integration
andy31415 Aug 12, 2025
a2f96d0
Add file names to gni file
andy31415 Aug 12, 2025
e7cad9c
Fix ota provider
andy31415 Aug 12, 2025
aba4279
Merge branch 'master' into centralize_codegen_integration
andy31415 Aug 13, 2025
a77b9cc
Also convert basic information
andy31415 Aug 13, 2025
d3ded91
slight arrange
andy31415 Aug 13, 2025
7bd86ff
Undo submodule update
andy31415 Aug 13, 2025
440b198
Add one more ember override in dynamic dispatcher
andy31415 Aug 13, 2025
8c0f5c2
Restyled by clang-format
restyled-commits Aug 13, 2025
28fd918
Fix ifdef not being defined
andy31415 Aug 13, 2025
23de75e
Fix typo
andy31415 Aug 13, 2025
9443e7d
Merge branch 'master' into centralize_codegen_integration
andy31415 Aug 13, 2025
b41ed02
Fix typo
andy31415 Aug 13, 2025
03f5e31
Update src/app/server-cluster/tests/TestOptionalAttributeSet.cpp
andy31415 Aug 14, 2025
7618be8
Slight clarity update
andreilitvin Aug 14, 2025
02f289d
Ameba does not like typeof
andreilitvin Aug 14, 2025
cf8de98
Merge branch 'master' into centralize_codegen_integration
andreilitvin Aug 14, 2025
07f36bb
Also convert the pushav stream transport server
andreilitvin Aug 14, 2025
f889687
fix compiles
andreilitvin Aug 14, 2025
9d5a5f3
fix compiles
andreilitvin Aug 14, 2025
88e08a8
Logic fix in pushav stream server
andreilitvin Aug 14, 2025
010d26c
Slight test adjustment: better comments and looks like a better test
andreilitvin Aug 14, 2025
46f3ef4
Update src/data-model-providers/codegen/ClusterIntegration.h
andy31415 Aug 14, 2025
ed9ed60
Update src/data-model-providers/codegen/ClusterIntegration.cpp
andy31415 Aug 14, 2025
0fc0f85
Update comments
andreilitvin Aug 14, 2025
29d9b75
Merge branch 'centralize_codegen_integration' of github.com:andy31415…
andreilitvin Aug 14, 2025
afd0981
Restyled by clang-format
restyled-commits Aug 14, 2025
cfc0156
Merge branch 'master' into centralize_codegen_integration
andreilitvin Aug 15, 2025
dcc1a00
Update some comments to have better capitalization
andreilitvin Aug 15, 2025
779bc59
More comment updates
andreilitvin Aug 15, 2025
74ab244
Some review feedback: updated variable name, added more comment on de…
andreilitvin Aug 15, 2025
ac1b359
More renames based on review feedback
andreilitvin Aug 15, 2025
2f19eb1
A few comment updates
andreilitvin Aug 15, 2025
e6c634f
place logging on a configuration flag
andreilitvin Aug 15, 2025
b98fc29
Merge branch 'master' into centralize_codegen_integration
andreilitvin Aug 15, 2025
0ce0363
Convert group key management cluster as well
andreilitvin Aug 15, 2025
f9c47a1
make feature map return a value
andreilitvin Aug 15, 2025
f8c7751
Restyled by clang-format
restyled-commits Aug 15, 2025
fcfa5f9
Restyled by gn
restyled-commits Aug 15, 2025
2f86de2
Fix comment
andreilitvin Aug 15, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ jobs:
type-safe getters
if: always()
run: |
git grep -I -n 'emberAfReadAttribute' -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)src/app/util/attribute-table.h' ':(exclude)zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp' ':(exclude)src/app/zap-templates/templates/app/attributes/Accessors.cpp.zapt' ':(exclude)src/app/util/attribute-table.cpp' ':(exclude)src/app/dynamic_server/DynamicDispatcher.cpp' && exit 1 || exit 0
git grep -I -n 'emberAfReadAttribute' -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)src/app/util/attribute-table.h' ':(exclude)zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp' ':(exclude)src/app/zap-templates/templates/app/attributes/Accessors.cpp.zapt' ':(exclude)src/app/util/attribute-table.cpp' ':(exclude)src/app/dynamic_server/DynamicDispatcher.cpp' ':(exclude)src/data-model-providers/codegen/ClusterIntegration.cpp' && exit 1 || exit 0

# git grep exits with 0 if it finds a match, but we want
# to fail (exit nonzero) on match. And we want to exclude this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
*/
#include <app/clusters/administrator-commissioning-server/AdministratorCommissioningCluster.h>
#include <app/static-cluster-config/AdministratorCommissioning.h>
#include <data-model-providers/codegen/CodegenDataModelProvider.h>
#include <data-model-providers/codegen/ClusterIntegration.h>

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/util/attribute-storage.h>
#include <app/util/config.h> // REQUIRED for ifdefs for commands

using namespace chip;
using namespace chip::app;
Expand Down Expand Up @@ -51,43 +50,52 @@ using ClusterImpl = AdministratorCommissioningCluster;

LazyRegisteredServerCluster<ClusterImpl> gServer;

} // namespace

void emberAfAdministratorCommissioningClusterServerInitCallback(EndpointId endpointId)
class IntegrationDelegate : public CodegenClusterIntegration::Delegate
{
if (endpointId != kRootEndpointId)
public:
ServerClusterRegistration & CreateRegistration(EndpointId endpointId, unsigned emberEndpointIndex,
uint32_t optionalAttributeBits, uint32_t featureMap) override
{
return;
gServer.Create(endpointId, BitFlags<AdministratorCommissioning::Feature>(featureMap));
return gServer.Registration();
}

uint32_t rawFeatureMap;
if (FeatureMap::Get(endpointId, &rawFeatureMap) != Status::Success)
{
ChipLogError(AppServer, "Failed to get feature map for endpoint %u", endpointId);
rawFeatureMap = 0;
}
ServerClusterInterface & FindRegistration(unsigned emberEndpointIndex) override { return gServer.Cluster(); }
void ReleaseRegistration(unsigned emberEndpointIndex) override { gServer.Destroy(); }
};

gServer.Create(endpointId, BitFlags<AdministratorCommissioning::Feature>(rawFeatureMap));
CHIP_ERROR err = CodegenDataModelProvider::Instance().Registry().Register(gServer.Registration());
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Admin Commissioning register error: endpoint %u, %" CHIP_ERROR_FORMAT, endpointId, err.Format());
}
} // namespace

void emberAfAdministratorCommissioningClusterServerInitCallback(EndpointId endpointId)
{
IntegrationDelegate integrationDelegate;

// register a singleton server (root endpoint only)
CodegenClusterIntegration::RegisterServer(
{
.endpointId = endpointId,
.clusterId = AdministratorCommissioning::Id,
.fixedClusterServerEndpointCount = 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you know it's 1? What if endpoint 0 is a dynamic endpoint? This could be 0. Or potentially more than 1 in the presence of fabric sync, but see below.

This needs to use the right kFixedClusterConfig.size(), no?

.maxEndpointCount = 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong a priori; fabric sync allows multiple Administrator Commissioning clusters on multiple endpoints, right?

Now I know the existing code does not work with that, so you can't use codegen for fabric sync, but this is at least worth documentation explaining why this value is 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case we claim that "the implementation here only handles the root node global instance administrator commissioning" hence the value of 1: we only ever support root endpoint.

For the rest, we would error out if codegen requests it. AdministratorCommissioning logic in fabric sync installs its own versions of this cluster and it is not this cluster in particular.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is we should document that here.

.fetchFeatureMap = true,
.fetchOptionalAttributes = false,
},
integrationDelegate);
}

void MatterAdministratorCommissioningClusterServerShutdownCallback(EndpointId endpointId)
{
if (endpointId != kRootEndpointId)
{
return;
}
IntegrationDelegate integrationDelegate;

CHIP_ERROR err = CodegenDataModelProvider::Instance().Registry().Unregister(&gServer.Cluster());
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Admin Commissioning unregister error: endpoint %u, %" CHIP_ERROR_FORMAT, endpointId, err.Format());
}
gServer.Destroy();
// register a singleton server (root endpoint only)
CodegenClusterIntegration::UnregisterServer(
{
.endpointId = endpointId,
.clusterId = AdministratorCommissioning::Id,
.fixedClusterServerEndpointCount = 1,
.maxEndpointCount = 1,
Comment on lines +95 to +96
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, these counts look off.

},
integrationDelegate);
}

void MatterAdministratorCommissioningPluginServerInitCallback() {}
Expand Down
69 changes: 42 additions & 27 deletions src/app/clusters/basic-information/CodegenIntegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include <app/static-cluster-config/BasicInformation.h>
#include <app/util/attribute-storage.h>
#include <app/util/endpoint-config-api.h>
#include <data-model-providers/codegen/CodegenDataModelProvider.h>
#include <lib/support/BitFlags.h>
#include <data-model-providers/codegen/ClusterIntegration.h>

using namespace chip;
using namespace chip::app;
Expand All @@ -46,44 +45,60 @@ static_assert((kBasicInformationFixedClusterCount == 0) ||

ServerClusterRegistration gRegistration(BasicInformationCluster::Instance());

class IntegrationDelegate : public CodegenClusterIntegration::Delegate
{
public:
ServerClusterRegistration & CreateRegistration(EndpointId endpointId, unsigned emberEndpointIndex,
uint32_t optionalAttributeBits, uint32_t featureMap) override
{

BasicInformationCluster::Instance().OptionalAttributes() =
BasicInformationCluster::OptionalAttributesSet(optionalAttributeBits);

return gRegistration;
}

ServerClusterInterface & FindRegistration(unsigned emberEndpointIndex) override { return BasicInformationCluster::Instance(); }

// Nothing to destroy: separate singleton class without constructor/destructor is used
void ReleaseRegistration(unsigned emberEndpointIndex) override {}
};

} // namespace

void emberAfBasicInformationClusterServerInitCallback(EndpointId endpointId)
{
VerifyOrReturn(endpointId == kRootEndpointId);

BasicInformationCluster::OptionalAttributesSet & attrs = BasicInformationCluster::Instance().OptionalAttributes();
IntegrationDelegate integrationDelegate;

attrs.Set<ManufacturingDate::Id>(emberAfContainsAttribute(endpointId, BasicInformation::Id, ManufacturingDate::Id))
.Set<PartNumber::Id>(emberAfContainsAttribute(endpointId, BasicInformation::Id, PartNumber::Id))
.Set<ProductURL::Id>(emberAfContainsAttribute(endpointId, BasicInformation::Id, ProductURL::Id))
.Set<ProductLabel::Id>(emberAfContainsAttribute(endpointId, BasicInformation::Id, ProductLabel::Id))
.Set<SerialNumber::Id>(emberAfContainsAttribute(endpointId, BasicInformation::Id, SerialNumber::Id))
.Set<LocalConfigDisabled::Id>(emberAfContainsAttribute(endpointId, BasicInformation::Id, LocalConfigDisabled::Id))
.Set<Reachable::Id>(emberAfContainsAttribute(endpointId, BasicInformation::Id, Reachable::Id))
.Set<ProductAppearance::Id>(emberAfContainsAttribute(endpointId, BasicInformation::Id, ProductAppearance::Id))

// This is NOT typical, however we try to respect ZAP here. MCORE_FS tests require this:
// Specifically builds need to support the "do not build with unique id (make it optional)"
// to emulate the test case where UniqueID is missing as it was optional in previous versions of the spec
.Set<UniqueID::Id>(emberAfContainsAttribute(endpointId, BasicInformation::Id, UniqueID::Id));

CHIP_ERROR err = CodegenDataModelProvider::Instance().Registry().Register(gRegistration);
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Basic Information register error: endpoint %u, %" CHIP_ERROR_FORMAT, endpointId, err.Format());
}
// register a singleton server (root endpoint only)
CodegenClusterIntegration::RegisterServer(
{
.endpointId = endpointId,
.clusterId = BasicInformation::Id,
.fixedClusterServerEndpointCount = 1,
.maxEndpointCount = 1,
Comment on lines +80 to +81
Copy link
Contributor

@bzbarsky-apple bzbarsky-apple Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above: the first 1 looks wrong, the second 1 needs documentation (i.e: there is only one Basic Information instance on a node; this one is simpler than Administrator Commissioning).

.fetchFeatureMap = false,
.fetchOptionalAttributes = true,
},
integrationDelegate);
}

void MatterBasicInformationClusterServerShutdownCallback(EndpointId endpointId)
{
VerifyOrReturn(endpointId == kRootEndpointId);

CHIP_ERROR err = CodegenDataModelProvider::Instance().Registry().Unregister(&BasicInformationCluster::Instance());
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Basic Information unregister error: endpoint %u, %" CHIP_ERROR_FORMAT, endpointId, err.Format());
}
IntegrationDelegate integrationDelegate;

CodegenClusterIntegration::UnregisterServer(
{
.endpointId = endpointId,
.clusterId = BasicInformation::Id,
.fixedClusterServerEndpointCount = 1,
.maxEndpointCount = 1,
Comment on lines +98 to +99
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to stop commenting on these, but they all need fixing.

},
integrationDelegate);
}

void MatterBasicInformationPluginServerInitCallback() {}
Expand Down
94 changes: 54 additions & 40 deletions src/app/clusters/general-diagnostics-server/CodegenIntegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <app/static-cluster-config/GeneralDiagnostics.h>
#include <app/util/config.h>
#include <app/util/util.h>
#include <data-model-providers/codegen/CodegenDataModelProvider.h>
#include <data-model-providers/codegen/ClusterIntegration.h>

using namespace chip;
using namespace chip::app;
Expand All @@ -43,61 +43,75 @@ LazyRegisteredServerCluster<GeneralDiagnosticsClusterFullConfigurable> gServer;
LazyRegisteredServerCluster<GeneralDiagnosticsCluster> gServer;
#endif

} // namespace

void emberAfGeneralDiagnosticsClusterServerInitCallback(EndpointId endpointId)
class IntegrationDelegate : public CodegenClusterIntegration::Delegate
{
VerifyOrDie(endpointId == kRootEndpointId);

GeneralDiagnosticsCluster::OptionalAttributeSet optionalAttributeSet =
GeneralDiagnosticsCluster::OptionalAttributeSet()
.Set<TotalOperationalHours::Id>(emberAfContainsAttribute(endpointId, GeneralDiagnostics::Id, TotalOperationalHours::Id))
.Set<BootReason::Id>(emberAfContainsAttribute(endpointId, GeneralDiagnostics::Id, BootReason::Id))
.Set<ActiveHardwareFaults::Id>(emberAfContainsAttribute(endpointId, GeneralDiagnostics::Id, ActiveHardwareFaults::Id))
.Set<ActiveRadioFaults::Id>(emberAfContainsAttribute(endpointId, GeneralDiagnostics::Id, ActiveRadioFaults::Id))
.Set<ActiveNetworkFaults::Id>(emberAfContainsAttribute(endpointId, GeneralDiagnostics::Id, ActiveNetworkFaults::Id));
public:
ServerClusterRegistration & CreateRegistration(EndpointId endpointId, unsigned emberEndpointIndex,
uint32_t optionalAttributeBits, uint32_t featureMap) override
{
GeneralDiagnosticsCluster::OptionalAttributeSet optionalAttributeSet(optionalAttributeBits);

#if defined(ZCL_USING_TIME_SYNCHRONIZATION_CLUSTER_SERVER) || defined(GENERAL_DIAGNOSTICS_ENABLE_PAYLOAD_TEST_REQUEST_CMD)
const GeneralDiagnosticsFunctionsConfig functionsConfig
{
/*
Only consider real time if time sync cluster is actually enabled. If it's not
enabled, this avoids likelihood of frequently reporting unusable unsynched time.
*/
const GeneralDiagnosticsFunctionsConfig functionsConfig
{
/*
Only consider real time if time sync cluster is actually enabled. If it's not
enabled, this avoids likelihood of frequently reporting unusable unsynched time.
*/
#if defined(ZCL_USING_TIME_SYNCHRONIZATION_CLUSTER_SERVER)
.enablePosixTime = true,
.enablePosixTime = true,
#else
.enablePosixTime = false,
.enablePosixTime = false,
#endif
#if defined(GENERAL_DIAGNOSTICS_ENABLE_PAYLOAD_TEST_REQUEST_CMD)
.enablePayloadSnaphot = true,
.enablePayloadSnaphot = true,
#else
.enablePayloadSnaphot = false,
.enablePayloadSnaphot = false,
#endif
};
gServer.Create(optionalAttributeSet, functionsConfig);
};
gServer.Create(optionalAttributeSet, functionsConfig);
#else
gServer.Create(optionalAttributeSet);
gServer.Create(optionalAttributeSet);
#endif

CHIP_ERROR err = CodegenDataModelProvider::Instance().Registry().Register(gServer.Registration());
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Failed to register GeneralDiagnostics on endpoint %u: %" CHIP_ERROR_FORMAT, endpointId,
err.Format());
return gServer.Registration();
}

ServerClusterInterface & FindRegistration(unsigned emberEndpointIndex) override { return gServer.Cluster(); }
void ReleaseRegistration(unsigned emberEndpointIndex) override { gServer.Destroy(); }
};

} // namespace

void emberAfGeneralDiagnosticsClusterServerInitCallback(EndpointId endpointId)
{
IntegrationDelegate integrationDelegate;

// register a singleton server (root endpoint only)
CodegenClusterIntegration::RegisterServer(
{
.endpointId = endpointId,
.clusterId = GeneralDiagnostics::Id,
.fixedClusterServerEndpointCount = 1,
.maxEndpointCount = 1,
.fetchFeatureMap = false,
.fetchOptionalAttributes = true,
},
integrationDelegate);
}

void MatterGeneralDiagnosticsClusterServerShutdownCallback(EndpointId endpointId)
{
VerifyOrReturn(endpointId == kRootEndpointId);
CHIP_ERROR err = CodegenDataModelProvider::Instance().Registry().Unregister(&gServer.Cluster());
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Failed to unregister GeneralDiagnostics on endpoint %u: %" CHIP_ERROR_FORMAT, endpointId,
err.Format());
}
gServer.Destroy();
IntegrationDelegate integrationDelegate;

// register a singleton server (root endpoint only)
CodegenClusterIntegration::UnregisterServer(
{
.endpointId = endpointId,
.clusterId = GeneralDiagnostics::Id,
.fixedClusterServerEndpointCount = 1,
.maxEndpointCount = 1,
},
integrationDelegate);
}

void MatterGeneralDiagnosticsPluginServerInitCallback() {}
Expand Down
Loading
Loading