Skip to content

Commit

Permalink
Reporting OperationalCredentials Attribute Change
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Oct 28, 2021
1 parent 149e582 commit 1ca9059
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
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);

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
6 changes: 6 additions & 0 deletions src/app/reporting/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ class Engine
*/
bool mMoreChunkedMessages = false;

/**
* Boolean to indicate if ScheduleRun is pending
*
*/
bool mScheduleRunPending = false;

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

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

0 comments on commit 1ca9059

Please sign in to comment.