Skip to content

Commit

Permalink
Don't reset AddNoc and UpdateNoc in CommissioningFailedTimerComplete
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Mar 17, 2022
1 parent 267c0e4 commit 6a5f06b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,31 +264,22 @@ FabricInfo * RetrieveCurrentFabric(CommandHandler * aCommandHandler)

void FailSafeCleanup(FailSafeContext & failSafeContext)
{
FabricInfo * fabricInfo = Server::GetInstance().GetFabricTable().FindFabricWithIndex(failSafeContext.GetFabricIndex());

emberAfPrintln(EMBER_AF_PRINT_DEBUG, "OpCreds: Call to FailSafeCleanup");

VerifyOrReturn(fabricInfo != nullptr);

// If an AddNOC or UpdateNOC command has been successfully invoked, terminate all CASE sessions associated with the Fabric
// whose Fabric Index is recorded in the Fail-Safe context (see ArmFailSafe Command) by clearing any associated Secure
// Session Context at the Server.
if (failSafeContext.NocCommandHasBeenInvoked())
{
CASESessionManager * caseSessionManager = Server::GetInstance().GetCASESessionManager();

if (caseSessionManager)
{
caseSessionManager->ReleaseSessionsForFabric(fabricInfo->GetCompressedId());
}
Server::GetInstance().GetSecureSessionManager().ExpireAllPairingsForFabric(failSafeContext.GetFabricIndex());
}

// If an AddNOC command had been successfully invoked, achieve the equivalent effect of invoking the RemoveFabric command
// against the Fabric Index stored in the Fail-Safe Context for the Fabric Index that was the subject of the AddNOC
// command.
if (failSafeContext.AddNocCommandHasBeenInvoked())
{
Server::GetInstance().GetFabricTable().Delete(fabricInfo->GetFabricIndex());
Server::GetInstance().GetFabricTable().Delete(failSafeContext.GetFabricIndex());
}

// If an UpdateNOC command had been successfully invoked, revert the state of operational key pair, NOC and ICAC for that
Expand Down
4 changes: 1 addition & 3 deletions src/platform/FailSafeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ void FailSafeContext::CommissioningFailedTimerComplete()
event.CommissioningComplete.Status = CHIP_ERROR_TIMEOUT;
CHIP_ERROR status = PlatformMgr().PostEvent(&event);

mFailSafeArmed = false;
mAddNocCommandHasBeenInvoked = false;
mUpdateNocCommandHasBeenInvoked = false;
mFailSafeArmed = false;

if (status != CHIP_NO_ERROR)
{
Expand Down

0 comments on commit 6a5f06b

Please sign in to comment.