From dda1327075df3a381d21eb461684c67dd875cb7b Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Wed, 13 Dec 2023 22:37:00 -0500 Subject: [PATCH] [ICD] Remove user active mode trigger attributes for the external list (#30980) * remove user active trigger attributes for the external list * Add tests to validate attributes * generated files * Fix attribute storage options * generated files * update .matter --- .../lit-icd-common/lit-icd-server-app.matter | 4 +- .../lit-icd-common/lit-icd-server-app.zap | 8 +-- .../suites/TestIcdManagementCluster.yaml | 17 +++++ .../zcl/zcl-with-test-extensions.json | 4 +- src/app/zap-templates/zcl/zcl.json | 4 +- .../zap-generated/attributes/Accessors.cpp | 62 +++++++++++++++++++ .../zap-generated/attributes/Accessors.h | 12 ++++ 7 files changed, 99 insertions(+), 12 deletions(-) diff --git a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter index 9b570517ab0835..ce33f98ec7a354 100644 --- a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter +++ b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter @@ -1740,8 +1740,8 @@ endpoint 0 { callback attribute registeredClients; callback attribute ICDCounter; callback attribute clientsSupportedPerFabric; - callback attribute userActiveModeTriggerHint; - callback attribute userActiveModeTriggerInstruction; + ram attribute userActiveModeTriggerHint default = 0x110D; + ram attribute userActiveModeTriggerInstruction default = "Restart the application"; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; diff --git a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap index 52301cf0d9540e..294429afe14e7f 100644 --- a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap +++ b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap @@ -3494,10 +3494,10 @@ "side": "server", "type": "UserActiveModeTriggerBitmap", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": null, + "defaultValue": "0x110D", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3510,10 +3510,10 @@ "side": "server", "type": "char_string", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": null, + "defaultValue": "Restart the application", "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/src/app/tests/suites/TestIcdManagementCluster.yaml b/src/app/tests/suites/TestIcdManagementCluster.yaml index 4f4cbf00a4dd27..eb611f27db24b9 100644 --- a/src/app/tests/suites/TestIcdManagementCluster.yaml +++ b/src/app/tests/suites/TestIcdManagementCluster.yaml @@ -69,6 +69,23 @@ tests: minValue: 0x0 maxValue: 0xFFFFFFFF + - label: "Read UserActiveModeTriggerHint" + command: "readAttribute" + attribute: "UserActiveModeTriggerHint" + response: + constraints: + type: bitmap32 + value: 0x110D + + - label: "Read UserActiveModeTriggerInstruction" + command: "readAttribute" + attribute: "UserActiveModeTriggerInstruction" + response: + constraints: + type: char_string + minLength: 1 + maxLength: 128 + - label: "Read ClientsSupportedPerFabric" command: "readAttribute" attribute: "ClientsSupportedPerFabric" diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json index 1bab6d709d05df..54c13da92ca35b 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -217,9 +217,7 @@ "ActiveModeThreshold", "RegisteredClients", "ICDCounter", - "ClientsSupportedPerFabric", - "UserActiveModeTriggerHint", - "UserActiveModeTriggerInstruction" + "ClientsSupportedPerFabric" ], "Operational Credentials": [ "SupportedFabrics", diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index 257222de56ad40..1e1e06e7b15c35 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -215,9 +215,7 @@ "ActiveModeThreshold", "RegisteredClients", "ICDCounter", - "ClientsSupportedPerFabric", - "UserActiveModeTriggerHint", - "UserActiveModeTriggerInstruction" + "ClientsSupportedPerFabric" ], "Operational Credentials": [ "SupportedFabrics", diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index 66f3ff69bb6949..c418c95d1b55ea 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -6570,6 +6570,68 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) namespace IcdManagement { namespace Attributes { +namespace UserActiveModeTriggerHint { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::BitMask * value) +{ + using Traits = NumericAttributeTraits>; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::IcdManagement::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + *value = Traits::StorageToWorking(temp); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::BitMask value) +{ + using Traits = NumericAttributeTraits>; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::IcdManagement::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); +} + +} // namespace UserActiveModeTriggerHint + +namespace UserActiveModeTriggerInstruction { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan & value) +{ + uint8_t zclString[128 + 1]; + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::IcdManagement::Id, Id, zclString, sizeof(zclString)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + + VerifyOrReturnError(value.size() == 128, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 128); + value.reduce_size(length); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +{ + static_assert(128 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 128, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[128 + 1]; + auto length = static_cast(value.size()); + Encoding::Put8(zclString, length); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::IcdManagement::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); +} + +} // namespace UserActiveModeTriggerInstruction + namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index 4222d40ea76f9f..70f24570d9770e 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -1274,6 +1274,18 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); namespace IcdManagement { namespace Attributes { +namespace UserActiveModeTriggerHint { +EmberAfStatus +Get(chip::EndpointId endpoint, + chip::BitMask * value); // UserActiveModeTriggerBitmap +EmberAfStatus Set(chip::EndpointId endpoint, chip::BitMask value); +} // namespace UserActiveModeTriggerHint + +namespace UserActiveModeTriggerInstruction { +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan & value); // char_string +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); +} // namespace UserActiveModeTriggerInstruction + namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value);