144144#if CHIP_CONFIG_ENABLE_ICD_SERVER
145145 kDeviceOption_icdActiveModeDurationMs ,
146146 kDeviceOption_icdIdleModeDuration ,
147+ kDeviceOption_icdShortIdleModeDuration ,
147148#endif
148149#if ENABLE_CAMERA_SERVER
149150 kDeviceOption_Camera_DeferredOffer ,
@@ -247,6 +248,7 @@ OptionDef sDeviceOptionDefs[] = {
247248#if CHIP_CONFIG_ENABLE_ICD_SERVER
248249 { " icdActiveModeDurationMs" , kArgumentRequired , kDeviceOption_icdActiveModeDurationMs },
249250 { " icdIdleModeDuration" , kArgumentRequired , kDeviceOption_icdIdleModeDuration },
251+ { " icdShortIdleModeDuration" , kArgumentRequired , kDeviceOption_icdShortIdleModeDuration },
250252#endif
251253#if ENABLE_CAMERA_SERVER
252254 { " camera-deferred-offer" , kNoArgument , kDeviceOption_Camera_DeferredOffer },
@@ -681,18 +683,18 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier,
681683
682684#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE || CHIP_DEVICE_ENABLE_PORT_PARAMS
683685 case kDeviceOption_SecuredDevicePort :
684- LinuxDeviceOptions::GetInstance ().securedDevicePort = static_cast <uint16_t >(atoi (aValue));
686+ LinuxDeviceOptions::GetInstance ().securedDevicePort = static_cast <uint16_t >(strtoul (aValue, nullptr , 0 ));
685687 break ;
686688
687689 case kDeviceOption_UnsecuredCommissionerPort :
688- LinuxDeviceOptions::GetInstance ().unsecuredCommissionerPort = static_cast <uint16_t >(atoi (aValue));
690+ LinuxDeviceOptions::GetInstance ().unsecuredCommissionerPort = static_cast <uint16_t >(strtoul (aValue, nullptr , 0 ));
689691 break ;
690692
691693#endif
692694
693695#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
694696 case kDeviceOption_SecuredCommissionerPort :
695- LinuxDeviceOptions::GetInstance ().securedCommissionerPort = static_cast <uint16_t >(atoi (aValue));
697+ LinuxDeviceOptions::GetInstance ().securedCommissionerPort = static_cast <uint16_t >(strtoul (aValue, nullptr , 0 ));
696698 break ;
697699 case kCommissionerOption_FabricID :
698700 LinuxDeviceOptions::GetInstance ().commissionerFabricId = static_cast <chip::FabricId>(strtoull (aValue, nullptr , 0 ));
@@ -717,21 +719,21 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier,
717719
718720 case kDeviceOption_InterfaceId :
719721 LinuxDeviceOptions::GetInstance ().interfaceId =
720- Inet::InterfaceId (static_cast <chip::Inet::InterfaceId::PlatformType>(atoi (aValue)));
722+ Inet::InterfaceId (static_cast <chip::Inet::InterfaceId::PlatformType>(strtoul (aValue, nullptr , 0 )));
721723 break ;
722724
723725#if CHIP_CONFIG_TRANSPORT_TRACE_ENABLED
724726 case kDeviceOption_TraceFile :
725727 LinuxDeviceOptions::GetInstance ().traceStreamFilename .SetValue (std::string{ aValue });
726728 break ;
727729 case kDeviceOption_TraceLog :
728- if (atoi (aValue) != 0 )
730+ if (strtoul (aValue, nullptr , 0 ) != 0 )
729731 {
730732 LinuxDeviceOptions::GetInstance ().traceStreamToLogEnabled = true ;
731733 }
732734 break ;
733735 case kDeviceOption_TraceDecode :
734- if (atoi (aValue) != 0 )
736+ if (strtoul (aValue, nullptr , 0 ) != 0 )
735737 {
736738 LinuxDeviceOptions::GetInstance ().traceStreamDecodeEnabled = true ;
737739 }
@@ -807,15 +809,16 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier,
807809 break ;
808810#if defined(PW_RPC_ENABLED)
809811 case kOptionRpcServerPort :
810- LinuxDeviceOptions::GetInstance ().rpcServerPort = static_cast <uint16_t >(atoi (aValue));
812+ LinuxDeviceOptions::GetInstance ().rpcServerPort = static_cast <uint16_t >(strtoul (aValue, nullptr , 0 ));
811813 break ;
812814#endif
813815#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
814816 case kDeviceOption_SubscriptionCapacity :
815- LinuxDeviceOptions::GetInstance ().subscriptionCapacity = static_cast <int32_t >(atoi (aValue));
817+ LinuxDeviceOptions::GetInstance ().subscriptionCapacity = static_cast <int32_t >(strtoul (aValue, nullptr , 0 ));
816818 break ;
817819 case kDeviceOption_SubscriptionResumptionRetryIntervalSec :
818- LinuxDeviceOptions::GetInstance ().subscriptionResumptionRetryIntervalSec = static_cast <int32_t >(atoi (aValue));
820+ LinuxDeviceOptions::GetInstance ().subscriptionResumptionRetryIntervalSec =
821+ static_cast <int32_t >(strtoul (aValue, nullptr , 0 ));
819822 break ;
820823 case kDeviceOption_IdleRetransmitTimeout : {
821824 auto mrpConfig = GetLocalMRPConfig ().ValueOr (GetDefaultMRPConfig ());
@@ -881,12 +884,12 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier,
881884#endif
882885#if CHIP_CONFIG_TERMS_AND_CONDITIONS_REQUIRED
883886 case kDeviceOption_TermsAndConditions_Version : {
884- LinuxDeviceOptions::GetInstance ().tcVersion .SetValue (static_cast <uint16_t >(atoi (aValue)));
887+ LinuxDeviceOptions::GetInstance ().tcVersion .SetValue (static_cast <uint16_t >(strtoul (aValue, nullptr , 0 )));
885888 break ;
886889 }
887890
888891 case kDeviceOption_TermsAndConditions_Required : {
889- LinuxDeviceOptions::GetInstance ().tcRequired .SetValue (static_cast <uint16_t >(atoi (aValue)));
892+ LinuxDeviceOptions::GetInstance ().tcRequired .SetValue (static_cast <uint16_t >(strtoul (aValue, nullptr , 0 )));
890893 break ;
891894 }
892895#endif
@@ -913,11 +916,35 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier,
913916 }
914917 else
915918 {
916- // Covert from seconds to mini seconds
919+ // Covert from seconds to milli seconds
917920 LinuxDeviceOptions::GetInstance ().icdIdleModeDurationMs .SetValue (chip::System::Clock::Milliseconds32 (value * 1000 ));
918921 }
919922 break ;
920923 }
924+ case kDeviceOption_icdShortIdleModeDuration : {
925+ uint32_t value = static_cast <uint32_t >(strtoul (aValue, nullptr , 0 ));
926+ if ((value < 1 ) || (value > 86400 ))
927+ {
928+ PrintArgError (" %s: invalid value specified for icdShortIdleModeDuration: %s\n " , aProgram, aValue);
929+ retval = false ;
930+ }
931+ else
932+ {
933+ if (LinuxDeviceOptions::GetInstance ().icdIdleModeDurationMs .HasValue () &&
934+ (value > std::chrono::duration_cast<System::Clock::Seconds32>(
935+ LinuxDeviceOptions::GetInstance ().icdIdleModeDurationMs .Value ())
936+ .count ()))
937+ {
938+ PrintArgError (" %s: icdShortIdleModeDuration value (%s) must be <= icdIdleModeDuration\n " , aProgram, aValue);
939+ retval = false ;
940+ }
941+ else
942+ {
943+ LinuxDeviceOptions::GetInstance ().shortIdleModeDurationS = chip::System::Clock::Seconds32 (value);
944+ }
945+ }
946+ break ;
947+ }
921948#endif
922949#if ENABLE_CAMERA_SERVER
923950 case kDeviceOption_Camera_DeferredOffer : {
0 commit comments