Skip to content

Commit

Permalink
Implement MaxCumulativeFailsafeSeconds (#19582)
Browse files Browse the repository at this point in the history
Added MaxCumulativeFailsafeSeconds attribute to GeneralCommissioningCluster
Added second timer in fail safe context to expire when
  • Loading branch information
tehampson authored and pull[bot] committed Jul 15, 2023
1 parent 532da57 commit ed8adc9
Show file tree
Hide file tree
Showing 40 changed files with 134 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
1 change: 1 addition & 0 deletions examples/bridge-app/bridge-common/bridge-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/lighting-common/lighting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/lock-common/lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
2 changes: 2 additions & 0 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ client cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down Expand Up @@ -654,6 +655,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
2 changes: 2 additions & 0 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ client cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down Expand Up @@ -654,6 +655,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
1 change: 1 addition & 0 deletions examples/pump-app/pump-common/pump-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
1 change: 1 addition & 0 deletions examples/thermostat/thermostat-common/thermostat.matter
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
2 changes: 2 additions & 0 deletions examples/tv-app/tv-common/tv-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ client cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down Expand Up @@ -633,6 +634,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
1 change: 1 addition & 0 deletions examples/window-app/common/window-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ server cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ CHIP_ERROR GeneralCommissioningAttrAccess::ReadBasicCommissioningInfo(AttributeV

// TODO: The commissioner might use the critical parameters in BasicCommissioningInfo to initialize
// the CommissioningParameters at the beginning of commissioning flow.
basicCommissioningInfo.failSafeExpiryLengthSeconds = CHIP_DEVICE_CONFIG_FAILSAFE_EXPIRY_LENGTH_SEC;
basicCommissioningInfo.failSafeExpiryLengthSeconds = CHIP_DEVICE_CONFIG_FAILSAFE_EXPIRY_LENGTH_SEC;
basicCommissioningInfo.maxCumulativeFailsafeSeconds = CHIP_DEVICE_CONFIG_MAX_CUMULATIVE_FAILSAFE_SEC;
static_assert(CHIP_DEVICE_CONFIG_MAX_CUMULATIVE_FAILSAFE_SEC >= CHIP_DEVICE_CONFIG_FAILSAFE_EXPIRY_LENGTH_SEC,
"Max cumulative failsafe seconds must be larger than failsafe expiry length seconds");

return aEncoder.Encode(basicCommissioningInfo);
}
Expand All @@ -140,7 +143,7 @@ CHIP_ERROR GeneralCommissioningAttrAccess::ReadSupportsConcurrentConnection(Attr

// TODO: The commissioner might use the critical parameters in BasicCommissioningInfo to initialize
// the CommissioningParameters at the beginning of commissioning flow.
supportsConcurrentConnection = (CHIP_DEVICE_CONFIG_FAILSAFE_EXPIRY_LENGTH_SEC) != 0;
supportsConcurrentConnection = (CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION) != 0;

return aEncoder.Encode(supportsConcurrentConnection);
}
Expand Down
6 changes: 5 additions & 1 deletion src/app/tests/suites/certification/Test_TC_CGEN_2_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ tests:
command: "readAttribute"
attribute: "BasicCommissioningInfo"
response:
value: { FailSafeExpiryLengthSeconds: 60 }
value:
{
FailSafeExpiryLengthSeconds: 60,
MaxCumulativeFailsafeSeconds: 900,
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ limitations under the License.
</enum>
<struct name="BasicCommissioningInfo">
<cluster code="0x0030"/>
<item name="FailSafeExpiryLengthSeconds" type="INT16U"/>
<item fieldId="0" name="FailSafeExpiryLengthSeconds" type="INT16U"/>
<item fieldId="1" name="MaxCumulativeFailsafeSeconds" type="INT16U"/>
</struct>
<cluster>
<domain>General</domain>
Expand Down
1 change: 1 addition & 0 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,7 @@ client cluster GeneralCommissioning = 48 {

struct BasicCommissioningInfo {
int16u failSafeExpiryLengthSeconds = 0;
int16u maxCumulativeFailsafeSeconds = 1;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/controller/python/chip/clusters/Objects.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.mm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@
#define CHIP_DEVICE_CONFIG_FAILSAFE_EXPIRY_LENGTH_SEC 60
#endif // CHIP_DEVICE_CONFIG_FAILSAFE_EXPIRY_LENGTH_SEC

/**
* CHIP_DEVICE_CONFIG_MAX_CUMULATIVE_FAILSAFE_SEC
*
* The default conservative value in seconds denoting the maximum total duration for which a fail safe
* timer can be re-armed.
*/
#ifndef CHIP_DEVICE_CONFIG_MAX_CUMULATIVE_FAILSAFE_SEC
#define CHIP_DEVICE_CONFIG_MAX_CUMULATIVE_FAILSAFE_SEC 900
#endif // CHIP_DEVICE_CONFIG_MAX_CUMULATIVE_FAILSAFE_SEC

/**
* CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
*
Expand Down
6 changes: 6 additions & 0 deletions src/include/platform/FailSafeContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ class FailSafeContext
*/
static void HandleArmFailSafeTimer(System::Layer * layer, void * aAppState);

/**
* @brief
* The callback function to be called when max cumulative time expires.
*/
static void HandleMaxCumulativeFailSafeTimer(System::Layer * layer, void * aAppState);

/**
* @brief
* The callback function to be called asynchronously after various cleanup work has completed
Expand Down
Loading

0 comments on commit ed8adc9

Please sign in to comment.