Skip to content

Commit 60b6beb

Browse files
[ICD] Expose ActiveModeDuration, ActiveModeThreshold, IdleModeDuration to application (project-chip#32494)
* Expose ICD Active/Idle paramter to application * address comment * Restyled by clang-format * change * address comments * Restyled by clang-format * address comments --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent fe889bd commit 60b6beb

File tree

5 files changed

+62
-11
lines changed

5 files changed

+62
-11
lines changed

examples/chip-tool/commands/pairing/PairingCommand.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ void PairingCommand::OnReadCommissioningInfo(const Controller::ReadCommissioning
430430
ChipLogProgress(AppServer, "OnReadCommissioningInfo - LIT UserActiveModeTriggerInstruction=%s",
431431
userActiveModeTriggerInstruction.c_str());
432432
}
433+
ChipLogProgress(AppServer, "OnReadCommissioningInfo ICD - IdleModeDuration=%u activeModeDuration=%u activeModeThreshold=%u",
434+
info.icd.idleModeDuration, info.icd.activeModeDuration, info.icd.activeModeThreshold);
433435
}
434436

435437
void PairingCommand::OnICDRegistrationComplete(NodeId nodeId, uint32_t icdCounter)
@@ -464,9 +466,9 @@ void PairingCommand::OnICDRegistrationComplete(NodeId nodeId, uint32_t icdCounte
464466
ChipLogProgress(chipTool, "Saved ICD Symmetric key for " ChipLogFormatX64, ChipLogValueX64(nodeId));
465467
ChipLogProgress(chipTool,
466468
"ICD Registration Complete for device " ChipLogFormatX64 " / Check-In NodeID: " ChipLogFormatX64
467-
" / Monitored Subject: " ChipLogFormatX64 " / Symmetric Key: %s",
469+
" / Monitored Subject: " ChipLogFormatX64 " / Symmetric Key: %s / ICDCounter %u",
468470
ChipLogValueX64(nodeId), ChipLogValueX64(mICDCheckInNodeId.Value()),
469-
ChipLogValueX64(mICDMonitoredSubject.Value()), icdSymmetricKeyHex);
471+
ChipLogValueX64(mICDMonitoredSubject.Value()), icdSymmetricKeyHex, icdCounter);
470472
}
471473

472474
void PairingCommand::OnICDStayActiveComplete(NodeId deviceId, uint32_t promisedActiveDuration)

examples/platform/linux/CommissionerMain.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ void PairingCommand::OnReadCommissioningInfo(const Controller::ReadCommissioning
367367
ChipLogProgress(AppServer, "OnReadCommissioningInfo - LIT UserActiveModeTriggerInstruction=%s",
368368
userActiveModeTriggerInstruction.c_str());
369369
}
370+
371+
ChipLogProgress(AppServer, "OnReadCommissioningInfo ICD - IdleModeDuration=%u activeModeDuration=%u activeModeThreshold=%u",
372+
info.icd.idleModeDuration, info.icd.activeModeDuration, info.icd.activeModeThreshold);
370373
}
371374

372375
void PairingCommand::OnFabricCheck(NodeId matchingNodeId)

src/controller/AutoCommissioner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ CHIP_ERROR AutoCommissioner::CommissioningStepFinished(CHIP_ERROR err, Commissio
743743

744744
if (mParams.GetCheckForMatchingFabric())
745745
{
746-
chip::NodeId nodeId = mDeviceCommissioningInfo.remoteNodeId;
746+
NodeId nodeId = mDeviceCommissioningInfo.remoteNodeId;
747747
if (nodeId != kUndefinedNodeId)
748748
{
749749
mParams.SetRemoteNodeId(nodeId);

src/controller/CHIPDeviceController.cpp

+43-4
Original file line numberDiff line numberDiff line change
@@ -2319,13 +2319,14 @@ CHIP_ERROR DeviceCommissioner::ParseICDInfo(ReadCommissioningInfo & info)
23192319
CHIP_ERROR err;
23202320
IcdManagement::Attributes::FeatureMap::TypeInfo::DecodableType featureMap;
23212321
bool hasUserActiveModeTrigger = false;
2322-
2322+
bool isICD = false;
23232323
err = mAttributeCache->Get<IcdManagement::Attributes::FeatureMap::TypeInfo>(kRootEndpointId, featureMap);
23242324
if (err == CHIP_NO_ERROR)
23252325
{
23262326
info.icd.isLIT = !!(featureMap & to_underlying(IcdManagement::Feature::kLongIdleTimeSupport));
23272327
info.icd.checkInProtocolSupport = !!(featureMap & to_underlying(IcdManagement::Feature::kCheckInProtocolSupport));
23282328
hasUserActiveModeTrigger = !!(featureMap & to_underlying(IcdManagement::Feature::kUserActiveModeTrigger));
2329+
isICD = true;
23292330
}
23302331
else if (err == CHIP_ERROR_KEY_NOT_FOUND)
23312332
{
@@ -2355,6 +2356,7 @@ CHIP_ERROR DeviceCommissioner::ParseICDInfo(ReadCommissioningInfo & info)
23552356

23562357
info.icd.userActiveModeTriggerHint.ClearAll();
23572358
info.icd.userActiveModeTriggerInstruction = CharSpan();
2359+
23582360
if (hasUserActiveModeTrigger)
23592361
{
23602362
// Intentionally ignore errors since they are not mandatory.
@@ -2390,6 +2392,37 @@ CHIP_ERROR DeviceCommissioner::ParseICDInfo(ReadCommissioningInfo & info)
23902392
}
23912393
}
23922394

2395+
if (!isICD)
2396+
{
2397+
info.icd.idleModeDuration = 0;
2398+
info.icd.activeModeDuration = 0;
2399+
info.icd.activeModeThreshold = 0;
2400+
return CHIP_NO_ERROR;
2401+
}
2402+
2403+
err = mAttributeCache->Get<IcdManagement::Attributes::IdleModeDuration::TypeInfo>(kRootEndpointId, info.icd.idleModeDuration);
2404+
if (err != CHIP_NO_ERROR)
2405+
{
2406+
ChipLogError(Controller, "IcdManagement.IdleModeDuration expected, but failed to read: %" CHIP_ERROR_FORMAT, err.Format());
2407+
return err;
2408+
}
2409+
err =
2410+
mAttributeCache->Get<IcdManagement::Attributes::ActiveModeDuration::TypeInfo>(kRootEndpointId, info.icd.activeModeDuration);
2411+
if (err != CHIP_NO_ERROR)
2412+
{
2413+
ChipLogError(Controller, "IcdManagement.ActiveModeDuration expected, but failed to read: %" CHIP_ERROR_FORMAT,
2414+
err.Format());
2415+
return err;
2416+
}
2417+
2418+
err = mAttributeCache->Get<IcdManagement::Attributes::ActiveModeThreshold::TypeInfo>(kRootEndpointId,
2419+
info.icd.activeModeThreshold);
2420+
if (err != CHIP_NO_ERROR)
2421+
{
2422+
ChipLogError(Controller, "IcdManagement.ActiveModeThreshold expected, but failed to read: %" CHIP_ERROR_FORMAT,
2423+
err.Format());
2424+
}
2425+
23932426
return err;
23942427
}
23952428

@@ -2680,8 +2713,8 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio
26802713
// NOTE: this array cannot have more than 9 entries, since the spec mandates that server only needs to support 9
26812714
// See R1.1, 2.11.2 Interaction Model Limits
26822715

2683-
// Currently, we have at most 5 attributes to read in this stage.
2684-
app::AttributePathParams readPaths[5];
2716+
// Currently, we have at most 8 attributes to read in this stage.
2717+
app::AttributePathParams readPaths[8];
26852718

26862719
// Mandatory attribute
26872720
readPaths[numberOfAttributes++] =
@@ -2700,12 +2733,18 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio
27002733
readPaths[numberOfAttributes++] =
27012734
app::AttributePathParams(endpoint, IcdManagement::Id, IcdManagement::Attributes::FeatureMap::Id);
27022735
}
2736+
27032737
// Always read the active mode trigger hint attributes to notify users about it.
27042738
readPaths[numberOfAttributes++] =
27052739
app::AttributePathParams(endpoint, IcdManagement::Id, IcdManagement::Attributes::UserActiveModeTriggerHint::Id);
27062740
readPaths[numberOfAttributes++] =
27072741
app::AttributePathParams(endpoint, IcdManagement::Id, IcdManagement::Attributes::UserActiveModeTriggerInstruction::Id);
2708-
2742+
readPaths[numberOfAttributes++] =
2743+
app::AttributePathParams(endpoint, IcdManagement::Id, IcdManagement::Attributes::IdleModeDuration::Id);
2744+
readPaths[numberOfAttributes++] =
2745+
app::AttributePathParams(endpoint, IcdManagement::Id, IcdManagement::Attributes::ActiveModeDuration::Id);
2746+
readPaths[numberOfAttributes++] =
2747+
app::AttributePathParams(endpoint, IcdManagement::Id, IcdManagement::Attributes::ActiveModeThreshold::Id);
27092748
SendCommissioningReadRequest(proxy, timeout, readPaths, numberOfAttributes);
27102749
}
27112750
break;

src/controller/CommissioningDelegate.h

+11-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ enum CommissioningStage : uint8_t
7878
kNeedsNetworkCreds,
7979
};
8080

81-
enum ICDRegistrationStrategy : uint8_t
81+
enum class ICDRegistrationStrategy : uint8_t
8282
{
8383
kIgnore, ///< Do not check whether the device is an ICD during commissioning
8484
kBeforeComplete, ///< Do commissioner self-registration or external controller registration,
@@ -699,11 +699,18 @@ struct GeneralCommissioningInfo
699699
struct ICDManagementClusterInfo
700700
{
701701
// Whether the ICD is capable of functioning as a LIT device. If false, the ICD can only be a SIT device.
702-
bool isLIT;
702+
bool isLIT = false;
703703
// Whether the ICD supports the check-in protocol. LIT devices have to support it, but SIT devices
704704
// might or might not.
705-
bool checkInProtocolSupport;
706-
705+
bool checkInProtocolSupport = false;
706+
// Indicate the maximum interval in seconds the server can stay in idle mode.
707+
uint32_t idleModeDuration = 0;
708+
// Indicate the minimum interval in milliseconds the server typically will stay in active mode after initial transition out of
709+
// idle mode.
710+
uint32_t activeModeDuration = 0;
711+
// Indicate the minimum amount of time in milliseconds the server typically will stay active after network activity when in
712+
// active mode.
713+
uint16_t activeModeThreshold = 0;
707714
// userActiveModeTriggerHint indicates which user action(s) will trigger the ICD to switch to Active mode.
708715
// For a LIT: The device is required to provide a value for the bitmap.
709716
// For a SIT: The device may not provide a value. In that case, none of the bits will be set.

0 commit comments

Comments
 (0)