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

Fix chip-tool open-commissioning-window to not crash. #11645

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
11 changes: 9 additions & 2 deletions examples/chip-tool/commands/pairing/PairingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ CHIP_ERROR PairingCommand::RunCommand()
{
CHIP_ERROR err = CHIP_NO_ERROR;

mController.RegisterDeviceAddressUpdateDelegate(this);
mController.RegisterPairingDelegate(this);
// If we're OpenCommissioningWindow we don't need to be registered as a
// delegate; we just get notified directly via the callbacks we pass to
// GetConnectedDevice. In fact, if we _do_ register as a delegate we get
// callbacks we don't expect and then weird things happen.
if (mPairingMode != PairingMode::OpenCommissioningWindow)
{
mController.RegisterDeviceAddressUpdateDelegate(this);
mController.RegisterPairingDelegate(this);
}

err = RunInternal(mNodeId);
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(chipTool, "Init Failure! PairDevice: %s", ErrorStr(err)));
Expand Down