Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing AcceptedCommands Interface #37646

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a6c102c
Changing AcceptedCommands Interface
ratgr Feb 19, 2025
60c855f
Update CHI::EnumerateGeneratedCommands to use builder
ratgr Feb 23, 2025
97a16db
Added Builder initializer support
ratgr Feb 23, 2025
0aeb4e5
Update all cluster Implentations of the CHI interface
ratgr Feb 23, 2025
c9918d2
Restyled by whitespace
restyled-commits Feb 23, 2025
9685fee
Fixing Checks
ratgr Feb 23, 2025
1e118db
Size_t
ratgr Feb 23, 2025
3a551c1
[PATCH] Restyled by clang-format
ratgr Feb 24, 2025
ff54464
Updated attributes
ratgr Feb 24, 2025
6511c42
Restyled by whitespace
restyled-commits Feb 24, 2025
77a4f9f
Restyled by clang-format
restyled-commits Feb 24, 2025
7cb4b5e
Clear up Access Permissions
ratgr Feb 24, 2025
dde4481
remove unnecesary file
ratgr Feb 24, 2025
e55e237
Restyled by whitespace
restyled-commits Feb 24, 2025
5a0a934
Restyled by clang-format
restyled-commits Feb 24, 2025
62429e8
Fix to networkCommisioning
ratgr Feb 24, 2025
6f5ea52
AcceptedCommands should return early
ratgr Feb 25, 2025
319d9aa
Check Error for CHIP_ERROR_NOT_IMPLEMENTED
ratgr Feb 25, 2025
8e92e77
Make sure there is space before appending
ratgr Feb 25, 2025
777a609
Fix Darwing Clangtidy issue
ratgr Feb 26, 2025
5f53224
Merge remote-tracking branch 'origin/master' into command-handler-int…
ratgr Feb 26, 2025
9671d96
Fixing dependency movement
ratgr Feb 26, 2025
33a0663
Restyled by clang-format
restyled-commits Feb 26, 2025
6e4a9e9
Remove Forward declaration
ratgr Feb 26, 2025
e4a4968
Use builder instead of static array for network comissioning
ratgr Feb 26, 2025
10cd5d3
Update Comment on new AppendElements for initializer list
ratgr Feb 26, 2025
731222e
Better phrasing in comments
ratgr Feb 26, 2025
98ea178
TestClusterCommandHandler::EnumerateAcceptedCommands don't use dynami…
ratgr Feb 26, 2025
3f4a906
Update src/app/CommandHandlerInterface.h
ratgr Feb 26, 2025
3037bfc
Documenting Upgrading changes
ratgr Feb 26, 2025
f4cdd15
Quick Fix
ratgr Feb 26, 2025
7f56e9f
Update docs/upgrading.md
ratgr Feb 26, 2025
a20600e
Making all Privileges Explicit
ratgr Feb 26, 2025
afc80b1
Remove return of stack ptr
ratgr Feb 26, 2025
8c10c16
Allocate only once in enumeration
ratgr Feb 27, 2025
2bf9949
Privileges in ResetWatermarks up to spec
ratgr Feb 28, 2025
8b8947b
remove chip from Access::Privilege;
ratgr Feb 28, 2025
316072b
Rephrasing Upgrading comment
ratgr Feb 28, 2025
9c54176
Some more fixes
ratgr Feb 28, 2025
088f797
Update src/app/clusters/network-commissioning/network-commissioning.cpp
ratgr Feb 28, 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
30 changes: 30 additions & 0 deletions admin_storage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"sdk-config": {
"g/lkgt": "FSYAgKi8LBg=",
"g/gcc": "aJuaDw==",
"g/gdc": "eVQ1Cw==",
"ExampleOpCredsCAKey1": "BNJGVNf+KuPMsKB1rJHyNZEKiXS/0lXyW0m7Als9bGvS7yhgFy5HlZ+Ukuju7DyicIXPC+NAVNdWttf+z0YrSKNpPaFJxR1qyW4+aqrqzIEw0UYHFzL5wed7AWRtDb2PWw==",
"ExampleOpCredsICAKey1": "BJW39nhSeUPdfSELvjAuf7wNkny6xkzxC1eeb0p/FmcrVv7q0x+z5J7p61o1OgAW4mbyB2UPofsRjDWwxGVIUfwpnurkR+oLOyjiZD0cr+gPwpSO46drERQj8HTtbWs41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AAAAAAAAAAAAAAAAGBglB///GA==",
"g/gfl": "FSQBASQCARg=",
"f/1/g": "FSQBACQCACQDACQEACQFACQGASQHABg=",
"g/icdfl": "FgQBGA=="
},
"repl-config": {
"caList": {
"1": [
{
"fabricId": 1,
"vendorId": 65521
}
]
}
}
}
2 changes: 1 addition & 1 deletion src/access/ProviderDeviceTypeResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#pragma once

#include <access/AccessControl.h>
#include <app/data-model-provider/MetadataList.h>
#include <app/data-model/MetadataList.h>
#include <app/data-model-provider/MetadataTypes.h>
#include <app/data-model-provider/Provider.h>

Expand Down
2 changes: 1 addition & 1 deletion src/app/AttributePathExpandIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <app/AttributePathExpandIterator.h>

#include <app/GlobalAttributes.h>
#include <app/data-model-provider/MetadataList.h>
#include <app/data-model/MetadataList.h>
#include <app/data-model-provider/MetadataLookup.h>
#include <app/data-model-provider/MetadataTypes.h>
#include <lib/core/DataModelTypes.h>
Expand Down
2 changes: 1 addition & 1 deletion src/app/AttributePathExpandIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include <app/AttributePathParams.h>
#include <app/ConcreteAttributePath.h>
#include <app/data-model-provider/MetadataList.h>
#include <app/data-model/MetadataList.h>
#include <app/data-model-provider/MetadataTypes.h>
#include <app/data-model-provider/Provider.h>
#include <lib/core/DataModelTypes.h>
Expand Down
8 changes: 6 additions & 2 deletions src/app/CommandHandlerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@
#include <app/ConcreteCommandPath.h>
#include <app/data-model/Decode.h>
#include <app/data-model/List.h> // So we can encode lists
#include <app/data-model/MetadataList.h> // So we can get filled buffers
#include <lib/core/DataModelTypes.h>
#include <lib/support/Iterators.h>

namespace chip {
namespace app {
namespace DataModel {
struct AcceptedCommandEntry;
}

/*
* This interface permits applications to register a server-side command handler
Expand Down Expand Up @@ -122,7 +126,7 @@ class CommandHandlerInterface
* This is used by callbacks that just look for a particular value in the
* list.
*/
virtual CHIP_ERROR EnumerateAcceptedCommands(const ConcreteClusterPath & cluster, CommandIdCallback callback, void * context)
virtual CHIP_ERROR EnumerateAcceptedCommands(const ConcreteClusterPath & cluster, DataModel::ListBuilder<DataModel::AcceptedCommandEntry> & builder)
{
return CHIP_ERROR_NOT_IMPLEMENTED;
}
Expand All @@ -146,7 +150,7 @@ class CommandHandlerInterface
* This is used by callbacks that just look for a particular value in the
* list.
*/
virtual CHIP_ERROR EnumerateGeneratedCommands(const ConcreteClusterPath & cluster, CommandIdCallback callback, void * context)
virtual CHIP_ERROR EnumerateGeneratedCommands(const ConcreteClusterPath & cluster, CommandIdCallback, void * context)
{
return CHIP_ERROR_NOT_IMPLEMENTED;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <app/EventPathParams.h>
#include <app/RequiredPrivilege.h>
#include <app/data-model-provider/ActionReturnStatus.h>
#include <app/data-model-provider/MetadataList.h>
#include <app/data-model/MetadataList.h>
#include <app/data-model-provider/MetadataLookup.h>
#include <app/data-model-provider/MetadataTypes.h>
#include <app/data-model-provider/OperationTypes.h>
Expand Down
2 changes: 1 addition & 1 deletion src/app/clusters/descriptor/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <app/AttributeAccessInterface.h>
#include <app/AttributeAccessInterfaceRegistry.h>
#include <app/InteractionModelEngine.h>
#include <app/data-model-provider/MetadataList.h>
#include <app/data-model/MetadataList.h>
#include <app/data-model-provider/MetadataTypes.h>
#include <app/data-model/List.h>
#include <app/util/attribute-storage.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,46 +104,46 @@ CHIP_ERROR Instance::Read(const ConcreteReadAttributePath & aPath, AttributeValu
}

// CommandHandlerInterface
CHIP_ERROR Instance::EnumerateAcceptedCommands(const ConcreteClusterPath & cluster, CommandIdCallback callback, void * context)
CHIP_ERROR Instance::EnumerateAcceptedCommands(const ConcreteClusterPath & cluster, ListBuilder<AcceptedCommandEntry> & builder)
{
using namespace Commands;
using QF = DataModel::CommandQualityFlags;

if (HasFeature(Feature::kPowerAdjustment))
{
for (auto && cmd : {
PowerAdjustRequest::Id,
CancelPowerAdjustRequest::Id,
})
{
VerifyOrExit(callback(cmd, context) == Loop::Continue, /**/);
}
VerifyOrExit(builder.AppendElements({
{PowerAdjustRequest::Id, QF::kFabricScoped, Access::Privilege::kOperate}, //TODO:: WHAT IS THE NEEDED PRIVILEGE AND CommandQualityFlags
{CancelPowerAdjustRequest::Id, QF::kFabricScoped, Access::Privilege::kOperate} //TODO:: WHAT IS THE NEEDED PRIVILEGE AND CommandQualityFlags
}));
}

if (HasFeature(Feature::kStartTimeAdjustment))
{
VerifyOrExit(callback(StartTimeAdjustRequest::Id, context) == Loop::Continue, /**/);
VerifyOrExit(builder.AppendElement({StartTimeAdjustRequest::Id, QF::kFabricScoped})); //TODO:: WHAT IS THE NEEDED PRIVILEGE AND CommandQualityFlags
}

if (HasFeature(Feature::kPausable))
{
VerifyOrExit(callback(PauseRequest::Id, context) == Loop::Continue, /**/);
VerifyOrExit(callback(ResumeRequest::Id, context) == Loop::Continue, /**/);
VerifyOrExit(builder.AppendElements({
{PauseRequest::Id, QF::kFabricScoped, Access::Privilege::kOperate},
{ResumeRequest::Id, BitFlags<QF>(QF::kFabricScoped), Access::Privilege::kOperate}
}));
}

if (HasFeature(Feature::kForecastAdjustment))
{
VerifyOrExit(callback(ModifyForecastRequest::Id, context) == Loop::Continue, /**/);
VerifyOrExit(builder.AppendElement({ModifyForecastRequest::Id, QF::kFabricScoped})); //TODO:: WHAT IS THE NEEDED PRIVILEGE AND CommandQualityFlags
}

if (HasFeature(Feature::kConstraintBasedAdjustment))
{
VerifyOrExit(callback(RequestConstraintBasedForecast::Id, context) == Loop::Continue, /**/);
VerifyOrExit(builder.AppendElement({ModifyForecastRequest::Id, QF::kFabricScoped})); //TODO:: WHAT IS THE NEEDED PRIVILEGE AND CommandQualityFlags
}

if (HasFeature(Feature::kStartTimeAdjustment) || HasFeature(Feature::kForecastAdjustment) ||
HasFeature(Feature::kConstraintBasedAdjustment))
{
VerifyOrExit(callback(CancelRequest::Id, context) == Loop::Continue, /**/);
VerifyOrExit(builder.AppendElement({CancelRequest::Id, QF::kFabricScoped})); //TODO:: WHAT IS THE NEEDED PRIVILEGE AND CommandQualityFlags
}

exit:
Expand Down
2 changes: 0 additions & 2 deletions src/app/data-model-provider/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ source_set("data-model-provider") {
"ActionReturnStatus.h",
"Context.h",
"EventsGenerator.h",
"MetadataList.cpp",
"MetadataList.h",
"MetadataLookup.cpp",
"MetadataLookup.h",
"OperationTypes.h",
Expand Down
2 changes: 1 addition & 1 deletion src/app/data-model-provider/MetadataLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
#include <app/data-model-provider/MetadataLookup.h>

#include <app/data-model-provider/MetadataList.h>
#include <app/data-model/MetadataList.h>

namespace chip {
namespace app {
Expand Down
2 changes: 1 addition & 1 deletion src/app/data-model-provider/MetadataLookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include <app/ConcreteAttributePath.h>
#include <app/ConcreteClusterPath.h>
#include <app/data-model-provider/MetadataList.h>
#include <app/data-model/MetadataList.h>
#include <app/data-model-provider/MetadataTypes.h>
#include <app/data-model-provider/ProviderMetadataTree.h>
#include <lib/core/DataModelTypes.h>
Expand Down
2 changes: 1 addition & 1 deletion src/app/data-model-provider/ProviderMetadataTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <app/data-model-provider/ProviderMetadataTree.h>

#include <app/data-model-provider/MetadataList.h>
#include <app/data-model/MetadataList.h>

namespace chip {
namespace app {
Expand Down
2 changes: 1 addition & 1 deletion src/app/data-model-provider/ProviderMetadataTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <app/ConcreteAttributePath.h>
#include <app/ConcreteClusterPath.h>
#include <app/ConcreteCommandPath.h>
#include <app/data-model-provider/MetadataList.h>
#include <app/data-model/MetadataList.h>
#include <app/data-model-provider/MetadataTypes.h>
#include <app/data-model/List.h>
#include <lib/support/Span.h>
Expand Down
2 changes: 1 addition & 1 deletion src/app/data-model-provider/tests/TestMetadataList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <pw_unit_test/framework.h>

#include <app/data-model-provider/MetadataList.h>
#include <app/data-model/MetadataList.h>

#include <lib/core/CHIPError.h>
#include <lib/core/DataModelTypes.h>
Expand Down
2 changes: 2 additions & 0 deletions src/app/data-model/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ source_set("data-model") {
"FabricScopedPreEncodedValue.cpp",
"FabricScopedPreEncodedValue.h",
"List.h",
"MetadataList.cpp",
"MetadataList.h",
"PreEncodedValue.cpp",
"PreEncodedValue.h",
"WrappedStructEncoder.h",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <app/data-model-provider/MetadataList.h>
#include <app/data-model/MetadataList.h>

#include <lib/core/CHIPError.h>
#include <lib/support/CHIPMem.h>
Expand Down
2 changes: 1 addition & 1 deletion src/app/reporting/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ DataModel::ActionReturnStatus RetrieveClusterData(DataModel::Provider * dataMode
reportBuilder.Checkpoint(checkpoint);

DataModel::ActionReturnStatus status(CHIP_NO_ERROR);
AttributeValueEncoder attributeValueEncoder(reportBuilder, subjectDescriptor, path, version, isFabricFiltered, encoderState);
AttributeValueEncoder attributeValueEncoder ={reportBuilder, subjectDescriptor, path, version, isFabricFiltered, encoderState};

// TODO: we explicitly DO NOT validate that path is a valid cluster path (even more, above serverClusterFinder
// explicitly ignores that case). This means that global attribute reads as well as ReadAttribute
Expand Down
5 changes: 2 additions & 3 deletions src/controller/tests/TestServerCommandDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ void TestClusterCommandHandler::InvokeCommand(chip::app::CommandHandlerInterface
});
}

CHIP_ERROR TestClusterCommandHandler::EnumerateAcceptedCommands(const ConcreteClusterPath & cluster,
CommandHandlerInterface::CommandIdCallback callback, void * context)
CHIP_ERROR TestClusterCommandHandler::EnumerateAcceptedCommands(const ConcreteClusterPath & cluster, ListBuilder<AcceptedCommandEntry> & builder)
{
if (!mOverrideAcceptedCommands)
{
Expand All @@ -116,7 +115,7 @@ CHIP_ERROR TestClusterCommandHandler::EnumerateAcceptedCommands(const ConcreteCl
{
return CHIP_NO_ERROR;
}

builder.get
// We just have one command id.
callback(Clusters::UnitTesting::Commands::TestSimpleArgumentRequest::Id, context);
return CHIP_NO_ERROR;
Expand Down
94 changes: 4 additions & 90 deletions src/data-model-providers/codegen/CodegenDataModelProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <app/ConcreteCommandPath.h>
#include <app/EventPathParams.h>
#include <app/RequiredPrivilege.h>
#include <app/data-model-provider/MetadataList.h>
#include <app/data-model/MetadataList.h>
#include <app/data-model-provider/MetadataTypes.h>
#include <app/data-model-provider/Provider.h>
#include <app/util/DataModelHandler.h>
Expand Down Expand Up @@ -335,53 +335,7 @@ CHIP_ERROR CodegenDataModelProvider::AcceptedCommands(const ConcreteClusterPath
CommandHandlerInterfaceRegistry::Instance().GetCommandHandler(path.mEndpointId, path.mClusterId);
if (interface != nullptr)
{
size_t commandCount = 0;

CHIP_ERROR err = interface->EnumerateAcceptedCommands(
path,
[](CommandId id, void * context) -> Loop {
*reinterpret_cast<size_t *>(context) += 1;
return Loop::Continue;
},
reinterpret_cast<void *>(&commandCount));

if (err == CHIP_NO_ERROR)
{
using EnumerationData = struct
{
ConcreteCommandPath commandPath;
DataModel::ListBuilder<DataModel::AcceptedCommandEntry> * acceptedCommandList;
CHIP_ERROR processingError;
};

EnumerationData enumerationData;
enumerationData.commandPath = ConcreteCommandPath(path.mEndpointId, path.mClusterId, kInvalidCommandId);
enumerationData.processingError = CHIP_NO_ERROR;
enumerationData.acceptedCommandList = &builder;

ReturnErrorOnFailure(builder.EnsureAppendCapacity(commandCount));

ReturnErrorOnFailure(interface->EnumerateAcceptedCommands(
path,
[](CommandId commandId, void * context) -> Loop {
auto input = reinterpret_cast<EnumerationData *>(context);
input->commandPath.mCommandId = commandId;
CHIP_ERROR appendError = input->acceptedCommandList->Append(AcceptedCommandEntryFor(input->commandPath));
if (appendError != CHIP_NO_ERROR)
{
input->processingError = appendError;
return Loop::Break;
}
return Loop::Continue;
},
reinterpret_cast<void *>(&enumerationData)));
ReturnErrorOnFailure(enumerationData.processingError);

// the two invocations MUST return the same sizes.
VerifyOrReturnError(builder.Size() == commandCount, CHIP_ERROR_INTERNAL);
return CHIP_NO_ERROR;
}
VerifyOrReturnError(err == CHIP_ERROR_NOT_IMPLEMENTED, err);
ReturnErrorOnFailure(interface->EnumerateAcceptedCommands(path, builder));
}

VerifyOrReturnError(serverCluster->acceptedCommandList != nullptr, CHIP_NO_ERROR);
Expand Down Expand Up @@ -420,48 +374,8 @@ CHIP_ERROR CodegenDataModelProvider::GeneratedCommands(const ConcreteClusterPath
if (interface != nullptr)
{
size_t commandCount = 0;

CHIP_ERROR err = interface->EnumerateGeneratedCommands(
path,
[](CommandId id, void * context) -> Loop {
*reinterpret_cast<size_t *>(context) += 1;
return Loop::Continue;
},
reinterpret_cast<void *>(&commandCount));

if (err == CHIP_NO_ERROR)
{
ReturnErrorOnFailure(builder.EnsureAppendCapacity(commandCount));

using EnumerationData = struct
{
DataModel::ListBuilder<CommandId> * generatedCommandList;
CHIP_ERROR processingError;
};
EnumerationData enumerationData;
enumerationData.processingError = CHIP_NO_ERROR;
enumerationData.generatedCommandList = &builder;

ReturnErrorOnFailure(interface->EnumerateGeneratedCommands(
path,
[](CommandId id, void * context) -> Loop {
auto input = reinterpret_cast<EnumerationData *>(context);

CHIP_ERROR appendError = input->generatedCommandList->Append(id);
if (appendError != CHIP_NO_ERROR)
{
input->processingError = appendError;
return Loop::Break;
}
return Loop::Continue;
},
reinterpret_cast<void *>(&enumerationData)));
ReturnErrorOnFailure(enumerationData.processingError);

// the two invocations MUST return the same sizes.
VerifyOrReturnError(builder.Size() == commandCount, CHIP_ERROR_INTERNAL);
return CHIP_NO_ERROR;
}
CHIP_ERROR err = interface->EnumerateGeneratedCommands(path, builder);
// if err == CHIP_ERROR_NOT_IMPLEMENTED then continue, else just return whatever err is
VerifyOrReturnError(err == CHIP_ERROR_NOT_IMPLEMENTED, err);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <app/CommandHandlerInterface.h>
#include <app/ConcreteCommandPath.h>
#include <app/data-model-provider/ActionReturnStatus.h>
#include <app/data-model-provider/MetadataList.h>
#include <app/data-model/MetadataList.h>
#include <app/util/af-types.h>
#include <lib/core/CHIPPersistentStorageDelegate.h>

Expand Down
Loading
Loading