Skip to content

Commit

Permalink
Release commissionee device once the device is visible on operational…
Browse files Browse the repository at this point in the history
… network
  • Loading branch information
pan-apple committed Nov 9, 2021
1 parent e6dab37 commit 1b69687
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,17 +957,6 @@ void DeviceCommissioner::RendezvousCleanup(CHIP_ERROR status)
{
FreeRendezvousSession();

if (mDeviceBeingCommissioned != nullptr)
{
// Let's release the device that's being paired.
// If pairing was successful, its information is
// already persisted. The application will use GetDevice()
// method to get access to the device, which will fetch
// the device information from the persistent storage.
ReleaseCommissioneeDevice(mDeviceBeingCommissioned);
mDeviceBeingCommissioned = nullptr;
}

if (mPairingDelegate != nullptr)
{
mPairingDelegate->OnPairingComplete(status);
Expand Down Expand Up @@ -1627,6 +1616,14 @@ void DeviceCommissioner::OnNodeIdResolved(const chip::Dnssd::ResolvedNodeData &
ChipLogValueX64(nodeData.mPeerId.GetNodeId()));
VerifyOrReturn(mState == State::Initialized);

if (mDeviceBeingCommissioned != nullptr && mDeviceBeingCommissioned->GetDeviceId() == nodeData.mPeerId.GetNodeId())
{
// Let's release the device that's being paired, if pairing was successful,
// and the device is available on the operational network.
ReleaseCommissioneeDevice(mDeviceBeingCommissioned);
mDeviceBeingCommissioned = nullptr;
}

GetOperationalDeviceWithAddress(nodeData.mPeerId.GetNodeId(), ToPeerAddress(nodeData), &mOnDeviceConnectedCallback,
&mOnDeviceConnectionFailureCallback);

Expand Down

0 comments on commit 1b69687

Please sign in to comment.