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

[OperationalCredentials]: Reporting change for the attributes not managed by the attribute store. #11155

Merged
merged 4 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -28,6 +28,7 @@
#include <app/AttributeAccessInterface.h>
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/reporting/reporting.h>
#include <app/server/Dnssd.h>
#include <app/server/Server.h>
#include <app/util/af.h>
Expand Down Expand Up @@ -263,6 +264,10 @@ CHIP_ERROR writeFabricsIntoFabricsListAttribute()
err = CHIP_ERROR_PERSISTED_STORAGE_FAILED;
}

// Currently, we only manage FabricsList attribute in endpoint 0, OperationalCredentials cluster is always required to be on
// EP0.
MatterReportingAttributeChangeCallback(0, OperationalCredentials::Id, OperationalCredentials::Attributes::FabricsList::Id);
yufengwangca marked this conversation as resolved.
Show resolved Hide resolved

return err;
}

Expand Down Expand Up @@ -785,6 +790,11 @@ bool emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback(
gFabricBeingCommissioned.Reset();
emberAfPrintln(EMBER_AF_PRINT_DEBUG, "OpCreds: Failed AddTrustedRootCert request.");
}
else
{
MatterReportingAttributeChangeCallback(commandPath.mEndpointId, OperationalCredentials::Id,
OperationalCredentials::Attributes::TrustedRootCertificates::Id);
}

return true;
}
Expand All @@ -795,5 +805,9 @@ bool emberAfOperationalCredentialsClusterRemoveTrustedRootCertificateCallback(
{
EmberAfStatus status = EMBER_ZCL_STATUS_FAILURE;
emberAfSendImmediateDefaultResponse(status);

MatterReportingAttributeChangeCallback(commandPath.mEndpointId, OperationalCredentials::Id,
OperationalCredentials::Attributes::TrustedRootCertificates::Id);

return true;
}
8 changes: 8 additions & 0 deletions src/app/reporting/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,14 @@ void Engine::Run(System::Layer * aSystemLayer, void * apAppState)

CHIP_ERROR Engine::ScheduleRun()
{
if (mScheduleRunPending)
{
return CHIP_NO_ERROR;
}

if (InteractionModelEngine::GetInstance()->GetExchangeManager() != nullptr)
{
mScheduleRunPending = true;
return InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->ScheduleWork(Run,
this);
}
Expand All @@ -352,6 +358,8 @@ void Engine::Run()
InteractionModelEngine * imEngine = InteractionModelEngine::GetInstance();
ReadHandler * readHandler = imEngine->mReadHandlers + mCurReadHandlerIdx;

mScheduleRunPending = false;

while ((mNumReportsInFlight < CHIP_IM_MAX_REPORTS_IN_FLIGHT) && (numReadHandled < CHIP_IM_MAX_NUM_READ_HANDLER))
{
if (readHandler->IsReportable())
Expand Down
7 changes: 7 additions & 0 deletions src/app/reporting/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ class Engine
*/
bool mMoreChunkedMessages = false;

/**
* Boolean to indicate if ScheduleRun is pending. This flag is used to prevent calling ScheduleRun multiple times
* within the same excution context.
yufengwangca marked this conversation as resolved.
Show resolved Hide resolved
*
*/
bool mScheduleRunPending = false;
yufengwangca marked this conversation as resolved.
Show resolved Hide resolved

/**
* The number of report date request in flight
*
Expand Down
5 changes: 5 additions & 0 deletions src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,4 +504,9 @@ void MatterReportingAttributeChangeCallback(EndpointId endpoint, ClusterId clust
info.mFlags.Set(ClusterInfo::Flags::kFieldIdValid);

InteractionModelEngine::GetInstance()->GetReportingEngine().SetDirty(info);

// Schedule a run work asynchronously on the CHIP thread, the scheduled work won't execute until the current execution context
yufengwangca marked this conversation as resolved.
Show resolved Hide resolved
// has completed. This ensures that we can 'gather up' multiple attribute changes that have occurred in the same execution
// context without requiring any explicit 'start' or 'end' change calls into the engine to book-end the change.
InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun();
yufengwangca marked this conversation as resolved.
Show resolved Hide resolved
}