Skip to content

Commit

Permalink
[hotfix][commissioner] Add runtime check in OnOperationalCredentialsP…
Browse files Browse the repository at this point in the history
…rovisioningCompletion (#7177)
  • Loading branch information
erjiaqing authored and pull[bot] committed Jun 3, 2021
1 parent 70ee65c commit 1077760
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,26 +1365,31 @@ CHIP_ERROR DeviceCommissioner::OnOperationalCredentialsProvisioningCompletion(De
VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);

#if CONFIG_USE_CLUSTERS_FOR_IP_COMMISSIONING
AdvanceCommissioningStage(CHIP_NO_ERROR);
#else
mPairingSession.ToSerializable(device->GetPairing());
mSystemLayer->CancelTimer(OnSessionEstablishmentTimeoutCallback, this);

mPairedDevices.Insert(device->GetDeviceId());
mPairedDevicesUpdated = true;

// Note - This assumes storage is synchronous, the device must be in storage before we can cleanup
// the rendezvous session and mark pairing success
PersistDevice(device);
// Also persist the device list at this time
// This makes sure that a newly added device is immediately available
PersistDeviceList();
if (mPairingDelegate != nullptr)
if (mIsIPRendezvous)
{
mPairingDelegate->OnStatusUpdate(DevicePairingDelegate::SecurePairingSuccess);
AdvanceCommissioningStage(CHIP_NO_ERROR);
}
RendezvousCleanup(CHIP_NO_ERROR);
else
#endif
{
mPairingSession.ToSerializable(device->GetPairing());
mSystemLayer->CancelTimer(OnSessionEstablishmentTimeoutCallback, this);

mPairedDevices.Insert(device->GetDeviceId());
mPairedDevicesUpdated = true;

// Note - This assumes storage is synchronous, the device must be in storage before we can cleanup
// the rendezvous session and mark pairing success
PersistDevice(device);
// Also persist the device list at this time
// This makes sure that a newly added device is immediately available
PersistDeviceList();
if (mPairingDelegate != nullptr)
{
mPairingDelegate->OnStatusUpdate(DevicePairingDelegate::SecurePairingSuccess);
}
RendezvousCleanup(CHIP_NO_ERROR);
}

return CHIP_NO_ERROR;
}
Expand Down

0 comments on commit 1077760

Please sign in to comment.