Skip to content

Commit 73a1c0b

Browse files
authored
[examples-app] Add options to configure MRP intervals at application launch (project-chip#36272)
1 parent cea1e36 commit 73a1c0b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

examples/platform/linux/Options.cpp

+49
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
#include <system/SystemFaultInjection.h>
4747
#endif
4848

49+
#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
50+
#include <messaging/ReliableMessageProtocolConfig.h>
51+
#endif
52+
4953
using namespace chip;
5054
using namespace chip::ArgParser;
5155
using namespace chip::Platform;
@@ -112,6 +116,9 @@ enum
112116
kDeviceOption_WiFiSupports5g,
113117
#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
114118
kDeviceOption_SubscriptionResumptionRetryIntervalSec,
119+
kDeviceOption_IdleRetransmitTimeout,
120+
kDeviceOption_ActiveRetransmitTimeout,
121+
kDeviceOption_ActiveThresholdTime,
115122
#endif
116123
#if CHIP_WITH_NLFAULTINJECTION
117124
kDeviceOption_FaultInjection,
@@ -187,6 +194,9 @@ OptionDef sDeviceOptionDefs[] = {
187194
#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
188195
{ "subscription-capacity", kArgumentRequired, kDeviceOption_SubscriptionCapacity },
189196
{ "subscription-resumption-retry-interval", kArgumentRequired, kDeviceOption_SubscriptionResumptionRetryIntervalSec },
197+
{ "idle-retransmit-timeout", kArgumentRequired, kDeviceOption_IdleRetransmitTimeout },
198+
{ "active-retransmit-timeout", kArgumentRequired, kDeviceOption_ActiveRetransmitTimeout },
199+
{ "active-threshold-time", kArgumentRequired, kDeviceOption_ActiveThresholdTime },
190200
#endif
191201
#if CHIP_WITH_NLFAULTINJECTION
192202
{ "faults", kArgumentRequired, kDeviceOption_FaultInjection },
@@ -335,6 +345,19 @@ const char * sDeviceOptionHelp =
335345
" Max number of subscriptions the device will allow\n"
336346
" --subscription-resumption-retry-interval\n"
337347
" subscription timeout resumption retry interval in seconds\n"
348+
" --idle-retransmit-timeout <timeout>\n"
349+
" Sets the MRP idle retry interval (in milliseconds).\n"
350+
" This interval is used by the peer to calculate the retransmission timeout when the current device is considered idle.\n"
351+
"\n"
352+
" --active-retransmit-timeout <timeout>\n"
353+
" Sets the MRP active retry interval (in milliseconds).\n"
354+
" This interval is used by the peer to calculate the retransmission timeout when the current device is considered "
355+
"active.\n"
356+
"\n"
357+
" --active-threshold-time <time>\n"
358+
" Sets the MRP active threshold (in milliseconds).\n"
359+
" Specifies the time after which the device transitions from active to idle.\n"
360+
"\n"
338361
#endif
339362
#if CHIP_WITH_NLFAULTINJECTION
340363
" --faults <fault-string,...>\n"
@@ -663,6 +686,32 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier,
663686
case kDeviceOption_SubscriptionResumptionRetryIntervalSec:
664687
LinuxDeviceOptions::GetInstance().subscriptionResumptionRetryIntervalSec = static_cast<int32_t>(atoi(aValue));
665688
break;
689+
case kDeviceOption_IdleRetransmitTimeout: {
690+
auto mrpConfig = GetLocalMRPConfig().ValueOr(GetDefaultMRPConfig());
691+
auto idleRetransTimeout = System::Clock::Milliseconds32(static_cast<uint32_t>(strtoul(aValue, nullptr, 0)));
692+
auto activeRetransTimeout = mrpConfig.mActiveRetransTimeout;
693+
auto activeThresholdTime = mrpConfig.mActiveThresholdTime;
694+
OverrideLocalMRPConfig(idleRetransTimeout, activeRetransTimeout, activeThresholdTime);
695+
break;
696+
}
697+
698+
case kDeviceOption_ActiveRetransmitTimeout: {
699+
auto mrpConfig = GetLocalMRPConfig().ValueOr(GetDefaultMRPConfig());
700+
auto idleRetransTimeout = mrpConfig.mIdleRetransTimeout;
701+
auto activeRetransTimeout = System::Clock::Milliseconds32(static_cast<uint32_t>(strtoul(aValue, nullptr, 0)));
702+
auto activeThresholdTime = mrpConfig.mActiveThresholdTime;
703+
OverrideLocalMRPConfig(idleRetransTimeout, activeRetransTimeout, activeThresholdTime);
704+
break;
705+
}
706+
707+
case kDeviceOption_ActiveThresholdTime: {
708+
auto mrpConfig = GetLocalMRPConfig().ValueOr(GetDefaultMRPConfig());
709+
auto idleRetransTimeout = mrpConfig.mIdleRetransTimeout;
710+
auto activeRetransTimeout = mrpConfig.mActiveRetransTimeout;
711+
auto activeThresholdTime = System::Clock::Milliseconds16(static_cast<uint16_t>(strtoul(aValue, nullptr, 0)));
712+
OverrideLocalMRPConfig(idleRetransTimeout, activeRetransTimeout, activeThresholdTime);
713+
break;
714+
}
666715
#endif
667716
#if CHIP_WITH_NLFAULTINJECTION
668717
case kDeviceOption_FaultInjection: {

0 commit comments

Comments
 (0)