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

Handle StopPairing more cleanly in DeviceController #28939

Merged
Merged
Changes from all commits
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
21 changes: 16 additions & 5 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,16 +918,27 @@ CHIP_ERROR DeviceCommissioner::StopPairing(NodeId remoteDeviceId)
VerifyOrReturnError(mState == State::Initialized, CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(remoteDeviceId != kUndefinedNodeId, CHIP_ERROR_INVALID_ARGUMENT);

bool stopped = mSetUpCodePairer.StopPairing(remoteDeviceId);
ChipLogProgress(Controller, "StopPairing called for node ID 0x" ChipLogFormatX64, ChipLogValueX64(remoteDeviceId));

// If we're still in the process of discovering the device, just stop the SetUpCodePairer
if (mSetUpCodePairer.StopPairing(remoteDeviceId))
{
return CHIP_NO_ERROR;
}

// Otherwise we might be pairing and / or commissioning it.
CommissioneeDeviceProxy * device = FindCommissioneeDevice(remoteDeviceId);
if (device != nullptr)
VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_DEVICE_DESCRIPTOR);

if (mDeviceBeingCommissioned == device)
{
CommissioningStageComplete(CHIP_ERROR_CANCELLED);
ksperling-apple marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
ReleaseCommissioneeDevice(device);
stopped = true;
}

return (stopped) ? CHIP_NO_ERROR : CHIP_ERROR_INVALID_DEVICE_DESCRIPTOR;
return CHIP_NO_ERROR;
}

CHIP_ERROR DeviceCommissioner::UnpairDevice(NodeId remoteDeviceId)
Expand Down