diff --git a/examples/chip-tool/commands/clusters/ReportCommand.h b/examples/chip-tool/commands/clusters/ReportCommand.h index 5a6bb4bf20c3b3..98f8f6de772051 100644 --- a/examples/chip-tool/commands/clusters/ReportCommand.h +++ b/examples/chip-tool/commands/clusters/ReportCommand.h @@ -411,3 +411,29 @@ class SubscribeEvent : public SubscribeCommand chip::Optional mKeepSubscriptions; chip::Optional> mIsUrgents; }; + +class ReadAll : public ReadCommand +{ +public: + ReadAll(CredentialIssuerCommands * credsIssuerConfig) : ReadCommand("read-all", credsIssuerConfig) + { + AddArgument("fabric-filtered", 0, 1, &mFabricFiltered); + ReadCommand::AddArguments(); + } + + ~ReadAll() {} + + void OnDone(chip::app::ReadClient * aReadClient) override + { + InteractionModelReports::CleanupReadClient(aReadClient); + SetCommandExitStatus(mError); + } + + CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override + { + return ReadCommand::ReadAll(device, endpointIds, mFabricFiltered); + } + +private: + chip::Optional mFabricFiltered; +}; diff --git a/examples/chip-tool/templates/commands.zapt b/examples/chip-tool/templates/commands.zapt index 25c8a54859f471..2600ce10eeaa1f 100644 --- a/examples/chip-tool/templates/commands.zapt +++ b/examples/chip-tool/templates/commands.zapt @@ -137,6 +137,7 @@ void registerClusterAny(Commands & commands, CredentialIssuerCommands * credsIss make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // }; commands.Register(clusterName, clusterCommands); diff --git a/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp b/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp index 526106c56d4a07..9a3c738b45d373 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp @@ -448,3 +448,37 @@ void InteractionModelReports::CleanupReadClient(ReadClient * aReadClient) std::remove_if(mReadClients.begin(), mReadClients.end(), [aReadClient](auto & item) { return item.get() == aReadClient; }), mReadClients.end()); } + +CHIP_ERROR InteractionModelReports::ReadAll(DeviceProxy * device, std::vector endpointIds, + const Optional & fabricFiltered) +{ + AttributePathParams attributePathParams[kMaxAllowedPaths]; + EventPathParams eventPathParams[kMaxAllowedPaths]; + + auto pathsCount = endpointIds.size(); + VerifyOrReturnError(pathsCount > 0 && pathsCount <= kMaxAllowedPaths, CHIP_ERROR_INVALID_ARGUMENT); + + for (size_t i = 0; i < pathsCount; i++) + { + auto endpointId = endpointIds.at(i); + attributePathParams[i].mEndpointId = endpointId; + eventPathParams[i].mEndpointId = endpointId; + } + + ReadPrepareParams params(device->GetSecureSession().Value()); + params.mpEventPathParamsList = eventPathParams; + params.mEventPathParamsListSize = pathsCount; + params.mpAttributePathParamsList = attributePathParams; + params.mAttributePathParamsListSize = pathsCount; + + if (fabricFiltered.HasValue()) + { + params.mIsFabricFiltered = fabricFiltered.Value(); + } + + auto client = std::make_unique(InteractionModelEngine::GetInstance(), device->GetExchangeManager(), + mBufferedReadAdapter, ReadClient::InteractionType::Read); + ReturnErrorOnFailure(client->SendRequest(params)); + mReadClients.push_back(std::move(client)); + return CHIP_NO_ERROR; +} diff --git a/src/app/tests/suites/commands/interaction_model/InteractionModel.h b/src/app/tests/suites/commands/interaction_model/InteractionModel.h index a5853fdd3ac560..157195bf2a8352 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.h +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.h @@ -107,6 +107,9 @@ class InteractionModelReports const chip::Optional & keepSubscriptions = chip::NullOptional, const chip::Optional> & isUrgents = chip::NullOptional); + CHIP_ERROR ReadAll(chip::DeviceProxy * device, std::vector endpointIds, + const chip::Optional & fabricFiltered = chip::Optional(true)); + void Shutdown() { mReadClients.clear(); } void CleanupReadClient(chip::app::ReadClient * aReadClient); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index f9349d380f31ff..5f3218a160a64c 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -17356,6 +17356,7 @@ void registerClusterAny(Commands & commands, CredentialIssuerCommands * credsIss make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // }; commands.Register(clusterName, clusterCommands);