@@ -850,6 +850,7 @@ CHIP_ERROR DeviceCommissioner::PairTestDeviceWithoutSecurity(NodeId remoteDevice
850
850
851
851
SecurePairingUsingTestSecret * testSecurePairingSecret = nullptr ;
852
852
853
+ // Check that the caller has provided an IP address (instead of a BLE peer address)
853
854
VerifyOrExit (peerAddress.GetTransportType () == Transport::Type::kUdp , err = CHIP_ERROR_INVALID_ARGUMENT);
854
855
VerifyOrExit (remoteDeviceId != kUndefinedNodeId && remoteDeviceId != kAnyNodeId , err = CHIP_ERROR_INVALID_ARGUMENT);
855
856
@@ -869,7 +870,31 @@ CHIP_ERROR DeviceCommissioner::PairTestDeviceWithoutSecurity(NodeId remoteDevice
869
870
870
871
device->Serialize (serialized);
871
872
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);
873
898
874
899
exit :
875
900
if (testSecurePairingSecret != nullptr )
@@ -988,7 +1013,7 @@ void DeviceCommissioner::OnSessionEstablished()
988
1013
SecureSession::SessionRole::kInitiator , mAdminId , nullptr );
989
1014
if (err != CHIP_NO_ERROR)
990
1015
{
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));
992
1017
OnSessionEstablishmentError (err);
993
1018
return ;
994
1019
}
@@ -999,7 +1024,7 @@ void DeviceCommissioner::OnSessionEstablished()
999
1024
err = SendOperationalCertificateSigningRequestCommand (device->GetDeviceId ());
1000
1025
if (err != CHIP_NO_ERROR)
1001
1026
{
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));
1003
1028
OnSessionEstablishmentError (err);
1004
1029
return ;
1005
1030
}
0 commit comments