Skip to content

Commit 252aad1

Browse files
authored
[SetUpCodePairer] Pass the MRP parameters to RendezvousParameters in order to get them used in the initial pairing session (#23302)
1 parent a78aa15 commit 252aad1

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

src/controller/CHIPDeviceController.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, Re
686686

687687
mDeviceInPASEEstablishment = device;
688688
device->Init(GetControllerDeviceInitParams(), remoteDeviceId, peerAddress);
689+
device->UpdateDeviceData(params.GetPeerAddress(), params.GetMRPConfig());
689690

690691
#if CONFIG_NETWORK_LAYER_BLE
691692
if (params.GetPeerAddress().GetTransportType() == Transport::Type::kBle)
@@ -706,8 +707,7 @@ CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, Re
706707
}
707708
}
708709
#endif
709-
// TODO: In some cases like PASE over IP, SAI and SII values from commissionable node service should be used
710-
session = mSystemState->SessionMgr()->CreateUnauthenticatedSession(params.GetPeerAddress(), device->GetRemoteMRPConfig());
710+
session = mSystemState->SessionMgr()->CreateUnauthenticatedSession(params.GetPeerAddress(), params.GetMRPConfig());
711711
VerifyOrExit(session.HasValue(), err = CHIP_ERROR_NO_MEMORY);
712712

713713
// Allocate the exchange immediately before calling PASESession::Pair.

src/controller/SetUpCodePairer.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,19 @@ void SetUpCodePairer::NotifyCommissionableDeviceDiscovered(const Dnssd::Discover
344344
Transport::PeerAddress::UDP(nodeData.resolutionData.ipAddress[0], nodeData.resolutionData.port, interfaceId);
345345
mDiscoveredParameters.emplace();
346346
mDiscoveredParameters.back().SetPeerAddress(peerAddress);
347+
348+
if (nodeData.resolutionData.mrpRetryIntervalIdle.HasValue())
349+
{
350+
auto interval = nodeData.resolutionData.mrpRetryIntervalIdle.Value();
351+
mDiscoveredParameters.back().SetIdleInterval(interval);
352+
}
353+
354+
if (nodeData.resolutionData.mrpRetryIntervalActive.HasValue())
355+
{
356+
auto interval = nodeData.resolutionData.mrpRetryIntervalActive.Value();
357+
mDiscoveredParameters.back().SetActiveInterval(interval);
358+
}
359+
347360
ConnectToDiscoveredDevice();
348361
}
349362

src/protocols/secure_channel/RendezvousParameters.h

+28
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@
2424
#endif // CONFIG_NETWORK_LAYER_BLE
2525

2626
#include <lib/support/logging/CHIPLogging.h>
27+
#include <messaging/ReliableMessageProtocolConfig.h>
2728
#include <protocols/secure_channel/PASESession.h>
2829

2930
namespace chip {
3031

3132
// The largest supported value for Rendezvous discriminators
3233
const uint16_t kMaxRendezvousDiscriminatorValue = 0xFFF;
3334

35+
// The largest supported value for sleepy idle interval and sleepy active interval
36+
constexpr uint32_t kMaxSleepyInterval = 3600000;
37+
3438
class RendezvousParameters
3539
{
3640
public:
@@ -93,6 +97,28 @@ class RendezvousParameters
9397
bool HasConnectionObject() const { return false; }
9498
#endif // CONFIG_NETWORK_LAYER_BLE
9599

100+
bool HasMRPConfig() const { return mMRPConfig.HasValue(); }
101+
ReliableMessageProtocolConfig GetMRPConfig() const { return mMRPConfig.ValueOr(GetDefaultMRPConfig()); }
102+
RendezvousParameters & SetIdleInterval(System::Clock::Milliseconds32 interval)
103+
{
104+
if (!mMRPConfig.HasValue())
105+
{
106+
mMRPConfig.Emplace(GetDefaultMRPConfig());
107+
}
108+
mMRPConfig.Value().mIdleRetransTimeout = interval;
109+
return *this;
110+
}
111+
112+
RendezvousParameters & SetActiveInterval(System::Clock::Milliseconds32 interval)
113+
{
114+
if (!mMRPConfig.HasValue())
115+
{
116+
mMRPConfig.Emplace(GetDefaultMRPConfig());
117+
}
118+
mMRPConfig.Value().mActiveRetransTimeout = interval;
119+
return *this;
120+
}
121+
96122
private:
97123
Transport::PeerAddress mPeerAddress; ///< the peer node address
98124
uint32_t mSetupPINCode = 0; ///< the target peripheral setup PIN Code
@@ -101,6 +127,8 @@ class RendezvousParameters
101127
Spake2pVerifier mPASEVerifier;
102128
bool mHasPASEVerifier = false;
103129

130+
Optional<ReliableMessageProtocolConfig> mMRPConfig;
131+
104132
#if CONFIG_NETWORK_LAYER_BLE
105133
Ble::BleLayer * mBleLayer = nullptr;
106134
BLE_CONNECTION_OBJECT mConnectionObject = BLE_CONNECTION_UNINITIALIZED;

0 commit comments

Comments
 (0)