diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 6ca2ba0719d2bd..073d15f2256d5b 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -976,9 +976,7 @@ void DeviceCommissioner::OnSessionEstablished() // TODO: the session should know which peer we are trying to connect to when started pairing->SetPeerNodeId(mDeviceBeingCommissioned->GetDeviceId()); - CHIP_ERROR err = mSystemState->SessionMgr()->NewPairing( - mDeviceBeingCommissioned->GetSecureSessionHolder(), Optional::Value(pairing->GetPeerAddress()), - pairing->GetPeerNodeId(), pairing, CryptoContext::SessionRole::kInitiator, mFabricIndex); + CHIP_ERROR err = mDeviceBeingCommissioned->SetConnected(); if (err != CHIP_NO_ERROR) { ChipLogError(Controller, "Failed in setting up secure channel: err %s", ErrorStr(err)); diff --git a/src/controller/CommissioneeDeviceProxy.cpp b/src/controller/CommissioneeDeviceProxy.cpp index bebd673c3d2c22..1496d4108b7996 100644 --- a/src/controller/CommissioneeDeviceProxy.cpp +++ b/src/controller/CommissioneeDeviceProxy.cpp @@ -132,6 +132,13 @@ CHIP_ERROR CommissioneeDeviceProxy::UpdateDeviceData(const Transport::PeerAddres return CHIP_NO_ERROR; } +CHIP_ERROR CommissioneeDeviceProxy::SetConnected() +{ + mState = ConnectionState::SecureConnected; + bool didLoad; + return LoadSecureSessionParametersIfNeeded(didLoad); +} + void CommissioneeDeviceProxy::Reset() { SetActive(false); diff --git a/src/controller/CommissioneeDeviceProxy.h b/src/controller/CommissioneeDeviceProxy.h index 200e5913b6e11e..ff99a7a16c85a8 100644 --- a/src/controller/CommissioneeDeviceProxy.h +++ b/src/controller/CommissioneeDeviceProxy.h @@ -196,6 +196,14 @@ class CommissioneeDeviceProxy : public DeviceProxy, public SessionReleaseDelegat void SetActive(bool active) { mActive = active; } + /** + * @brief + * Should be called when the pairing completes. + * + * This causes the secure session parameters to be loaded and stores the session details in the session manager. + */ + CHIP_ERROR SetConnected(); + bool IsSecureConnected() const override { return IsActive() && mState == ConnectionState::SecureConnected; } bool IsSessionSetupInProgress() const { return IsActive() && mState == ConnectionState::Connecting; }