Skip to content

Commit 1283835

Browse files
pan-applepull[bot]
authored andcommitted
Fix rendezvous bypass mode (#6681)
* Fix rendezvous bypass mode * address review comments
1 parent 5e96a8b commit 1283835

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/controller/CHIPDeviceController.cpp

+28-3
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ CHIP_ERROR DeviceCommissioner::PairTestDeviceWithoutSecurity(NodeId remoteDevice
850850

851851
SecurePairingUsingTestSecret * testSecurePairingSecret = nullptr;
852852

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

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

870871
device->Serialize(serialized);
871872

872-
OnSessionEstablished();
873+
err = mSessionMgr->NewPairing(Optional<Transport::PeerAddress>::Value(peerAddress), device->GetDeviceId(),
874+
testSecurePairingSecret, SecureSession::SessionRole::kInitiator, mAdminId, nullptr);
875+
if (err != CHIP_NO_ERROR)
876+
{
877+
ChipLogError(Controller, "Failed in setting up secure channel: err %s", ErrorStr(err));
878+
OnSessionEstablishmentError(err);
879+
}
880+
SuccessOrExit(err);
881+
882+
mPairedDevices.Insert(device->GetDeviceId());
883+
mPairedDevicesUpdated = true;
884+
885+
// Note - This assumes storage is synchronous, the device must be in storage before we can cleanup
886+
// the rendezvous session and mark pairing success
887+
PersistDevice(device);
888+
// Also persist the device list at this time
889+
// This makes sure that a newly added device is immediately available
890+
PersistDeviceList();
891+
892+
if (mPairingDelegate != nullptr)
893+
{
894+
mPairingDelegate->OnStatusUpdate(DevicePairingDelegate::SecurePairingSuccess);
895+
}
896+
897+
RendezvousCleanup(CHIP_NO_ERROR);
873898

874899
exit:
875900
if (testSecurePairingSecret != nullptr)
@@ -988,7 +1013,7 @@ void DeviceCommissioner::OnSessionEstablished()
9881013
SecureSession::SessionRole::kInitiator, mAdminId, nullptr);
9891014
if (err != CHIP_NO_ERROR)
9901015
{
991-
ChipLogError(Ble, "Failed in setting up secure channel: err %s", ErrorStr(err));
1016+
ChipLogError(Controller, "Failed in setting up secure channel: err %s", ErrorStr(err));
9921017
OnSessionEstablishmentError(err);
9931018
return;
9941019
}
@@ -999,7 +1024,7 @@ void DeviceCommissioner::OnSessionEstablished()
9991024
err = SendOperationalCertificateSigningRequestCommand(device->GetDeviceId());
10001025
if (err != CHIP_NO_ERROR)
10011026
{
1002-
ChipLogError(Ble, "Failed in sending opcsr request command to the device: err %s", ErrorStr(err));
1027+
ChipLogError(Controller, "Failed in sending opcsr request command to the device: err %s", ErrorStr(err));
10031028
OnSessionEstablishmentError(err);
10041029
return;
10051030
}

0 commit comments

Comments
 (0)