|
28 | 28 | #include <crypto/CHIPCryptoPAL.h>
|
29 | 29 | #include <json/json.h>
|
30 | 30 | #include <lib/core/CHIPError.h>
|
| 31 | +#include <lib/core/CHIPConfig.h> |
31 | 32 | #include <lib/support/Base64.h>
|
32 | 33 | #include <lib/support/BytesToHex.h>
|
33 | 34 | #include <lib/support/CHIPMemString.h>
|
@@ -132,6 +133,11 @@ enum
|
132 | 133 | kDeviceOption_TermsAndConditions_Version,
|
133 | 134 | kDeviceOption_TermsAndConditions_Required,
|
134 | 135 | #endif
|
| 136 | +#if CHIP_CONFIG_ENABLE_ICD_SERVER |
| 137 | + kDeviceOption_icdActiveModeDurationMs, |
| 138 | + kDeviceOption_icdIdleModeDuration, |
| 139 | + kDeviceOption_icdPeriodicWakeupDurationMs, |
| 140 | +#endif // CHIP_ENABLE_ICD_SERVER |
135 | 141 | };
|
136 | 142 |
|
137 | 143 | constexpr unsigned kAppUsageLength = 64;
|
@@ -212,6 +218,11 @@ OptionDef sDeviceOptionDefs[] = {
|
212 | 218 | { "tc-version", kArgumentRequired, kDeviceOption_TermsAndConditions_Version },
|
213 | 219 | { "tc-required", kArgumentRequired, kDeviceOption_TermsAndConditions_Required },
|
214 | 220 | #endif
|
| 221 | +#if CHIP_CONFIG_ENABLE_ICD_SERVER |
| 222 | + { "icdActiveModeDurationMs", kArgumentRequired, kDeviceOption_icdActiveModeDurationMs }, |
| 223 | + { "icdIdleModeDuration", kArgumentRequired, kDeviceOption_icdIdleModeDuration }, |
| 224 | + { "icdPeriodicWakeupDurationMs", kArgumentRequired, kDeviceOption_icdPeriodicWakeupDurationMs }, |
| 225 | +#endif // CHIP_ENABLE_ICD_SERVER |
215 | 226 | {}
|
216 | 227 | };
|
217 | 228 |
|
@@ -383,8 +394,21 @@ const char * sDeviceOptionHelp =
|
383 | 394 | " --faults <fault-string,...>\n"
|
384 | 395 | " Inject specified fault(s) at runtime.\n"
|
385 | 396 | #endif
|
386 |
| - " --dac_provider <filepath>\n" |
| 397 | + " --dac_provider <filepath>\n" |
387 | 398 | " A json file with data used by the example dac provider to validate device attestation procedure.\n"
|
| 399 | +#if CHIP_CONFIG_ENABLE_ICD_SERVER |
| 400 | + " --icdActiveModeDurationMs <icdActiveModeDurationMs>\n" |
| 401 | + " Sets the ICD active mode threshold (in milliseconds). (Default: 300) \n" |
| 402 | + " This defines the how long the the server typically will stay in active mode after \n" |
| 403 | + " initial transition out of idle mode.\n" |
| 404 | + " --icdIdleModeDuration <icdIdleModeDuration>\n" |
| 405 | + " Sets the ICD idle mode durations (in seconds). (Default: 300) \n" |
| 406 | + " This defines the how long the ICD server can stay in idle mode.\n" |
| 407 | + " --icdPeriodicWakeupDurationMs <icdPeriodicWakupDurationMs>\n" |
| 408 | + " Sets the ICD periodic wakeup (in milliseconds). (Default: 6000)\n" |
| 409 | + " This is for testing purpose on Linux which defines the internal to wakeup periodically to send \n" |
| 410 | + " Check-In messages since Linux application doesn't have a physical button to trigger wakeup\n" |
| 411 | +#endif |
388 | 412 | "\n";
|
389 | 413 |
|
390 | 414 | #if CHIP_CONFIG_USE_ACCESS_RESTRICTIONS
|
@@ -774,6 +798,38 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier,
|
774 | 798 | LinuxDeviceOptions::GetInstance().tcRequired.SetValue(static_cast<uint16_t>(atoi(aValue)));
|
775 | 799 | break;
|
776 | 800 | }
|
| 801 | +#endif |
| 802 | +#if CHIP_CONFIG_ENABLE_ICD_SERVER |
| 803 | + case kDeviceOption_icdActiveModeDurationMs: { |
| 804 | + uint32_t value = static_cast<uint32_t>(strtoul(aValue, nullptr, 0)); |
| 805 | + if (value < 1) |
| 806 | + { |
| 807 | + PrintArgError("%s: invalid value specified for icdActiveModeDurationMs: %s\n", aProgram, aValue); |
| 808 | + retval = false; |
| 809 | + } |
| 810 | + else |
| 811 | + { |
| 812 | + LinuxDeviceOptions::GetInstance().icdActiveModeDurationMs.SetValue(chip::System::Clock::Milliseconds32(value)); |
| 813 | + } |
| 814 | + break; |
| 815 | + } |
| 816 | + case kDeviceOption_icdIdleModeDuration: { |
| 817 | + uint32_t value = static_cast<uint32_t>(strtoul(aValue, nullptr, 0)); |
| 818 | + if ((value < 1) || (value > 86400)) |
| 819 | + { |
| 820 | + PrintArgError("%s: invalid value specified for icdIdleModeDuration: %s\n", aProgram, aValue); |
| 821 | + retval = false; |
| 822 | + } |
| 823 | + else |
| 824 | + { |
| 825 | + // Covert from seconds to mini seconds |
| 826 | + LinuxDeviceOptions::GetInstance().icdIdleModeDurationMs.SetValue(chip::System::Clock::Milliseconds32(value * 1000)); |
| 827 | + } |
| 828 | + break; |
| 829 | + } |
| 830 | + case kDeviceOption_icdPeriodicWakeupDurationMs: |
| 831 | + LinuxDeviceOptions::GetInstance().icdPeriodicWakeupDurationMs = static_cast<uint32_t>(atoi(aValue)); |
| 832 | + break; |
777 | 833 | #endif
|
778 | 834 | default:
|
779 | 835 | PrintArgError("%s: INTERNAL ERROR: Unhandled option: %s\n", aProgram, aName);
|
|
0 commit comments