Skip to content

Commit

Permalink
Fix rendezvous bypass mode (#6681)
Browse files Browse the repository at this point in the history
* Fix rendezvous bypass mode

* address review comments
  • Loading branch information
pan-apple authored and pull[bot] committed Jun 2, 2021
1 parent 0ecceb8 commit 1074168
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ CHIP_ERROR DeviceCommissioner::PairTestDeviceWithoutSecurity(NodeId remoteDevice

SecurePairingUsingTestSecret * testSecurePairingSecret = nullptr;

// Check that the caller has provided an IP address (instead of a BLE peer address)
VerifyOrExit(peerAddress.GetTransportType() == Transport::Type::kUdp, err = CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrExit(remoteDeviceId != kUndefinedNodeId && remoteDeviceId != kAnyNodeId, err = CHIP_ERROR_INVALID_ARGUMENT);

Expand All @@ -869,7 +870,31 @@ CHIP_ERROR DeviceCommissioner::PairTestDeviceWithoutSecurity(NodeId remoteDevice

device->Serialize(serialized);

OnSessionEstablished();
err = mSessionMgr->NewPairing(Optional<Transport::PeerAddress>::Value(peerAddress), device->GetDeviceId(),
testSecurePairingSecret, SecureSession::SessionRole::kInitiator, mAdminId, nullptr);
if (err != CHIP_NO_ERROR)
{
ChipLogError(Controller, "Failed in setting up secure channel: err %s", ErrorStr(err));
OnSessionEstablishmentError(err);
}
SuccessOrExit(err);

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);

exit:
if (testSecurePairingSecret != nullptr)
Expand Down Expand Up @@ -988,7 +1013,7 @@ void DeviceCommissioner::OnSessionEstablished()
SecureSession::SessionRole::kInitiator, mAdminId, nullptr);
if (err != CHIP_NO_ERROR)
{
ChipLogError(Ble, "Failed in setting up secure channel: err %s", ErrorStr(err));
ChipLogError(Controller, "Failed in setting up secure channel: err %s", ErrorStr(err));
OnSessionEstablishmentError(err);
return;
}
Expand All @@ -999,7 +1024,7 @@ void DeviceCommissioner::OnSessionEstablished()
err = SendOperationalCertificateSigningRequestCommand(device->GetDeviceId());
if (err != CHIP_NO_ERROR)
{
ChipLogError(Ble, "Failed in sending opcsr request command to the device: err %s", ErrorStr(err));
ChipLogError(Controller, "Failed in sending opcsr request command to the device: err %s", ErrorStr(err));
OnSessionEstablishmentError(err);
return;
}
Expand Down

0 comments on commit 1074168

Please sign in to comment.