From 07564e888d07e6ef068daff9d3302950675aeb9a Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 11 Nov 2021 02:31:23 -0500 Subject: [PATCH] Fix Accessors to handle nullable attributes. For setters, the new behavior is: * For non-string attributes when setting an integer or boolean value, do a CanRepresentValue check and fail if that fails. For string attributes, ensure that strings with 0xFF or 0xFFFF as length cannot be passed in in practice. * For nullable attributes add a SetNull method. * For nullable attributes add a Set() method taking a Nullable and calling either SetNull or the setter that expects a non-null value. For getters, the new behavior is: * When reading a nullable integer or boolean, NaU/NaS is converted to a null value stored in the Nullable. * When reading a non-nullable integer or boolean, return error if CanRepresentValue returns false on the value from the attr store. * When reading a nullable string or octet string, length 0xFFFF/0xFF is converted to a null value stored in the Nullable. * When reading a non-nullable string or octet string, length 0xFFFF/0xFF leads to an error. --- .../common/attributes/Accessors.js | 38 +- .../app/attributes/Accessors-src.zapt | 82 +- .../templates/app/attributes/Accessors.zapt | 9 +- .../zap-generated/attributes/Accessors.cpp | 13291 ++++++++++++++-- .../zap-generated/attributes/Accessors.h | 17 +- 5 files changed, 12330 insertions(+), 1107 deletions(-) diff --git a/src/app/zap-templates/common/attributes/Accessors.js b/src/app/zap-templates/common/attributes/Accessors.js index 84433c7abb5a84..fa345c8257e51f 100644 --- a/src/app/zap-templates/common/attributes/Accessors.js +++ b/src/app/zap-templates/common/attributes/Accessors.js @@ -15,9 +15,11 @@ * limitations under the License. */ +const zapPath = '../../../../../third_party/zap/repo/dist/src-electron/'; const ListHelper = require('../../common/ListHelper.js'); const StringHelper = require('../../common/StringHelper.js'); const StructHelper = require('../../common/StructHelper.js'); +const zclHelper = require(zapPath + 'generator/helper-zcl.js') // Issue #8202 // The specification allow non-standard signed and unsigned integer with a width of 24, 40, 48 or 56, but those types does not have @@ -29,24 +31,52 @@ function isUnsupportedType(type) return unsupportedTypes.includes(type.toUpperCase()); } -function canHaveSimpleAccessors(type) +function canHaveSimpleAccessors(attr) { - if (ListHelper.isList(type)) { + if (attr.isArray || attr.isList) { return false; } - if (StructHelper.isStruct(type)) { + if (ListHelper.isList(attr.type)) { return false; } - if (isUnsupportedType(type)) { + if (StructHelper.isStruct(attr.type)) { + return false; + } + + if (isUnsupportedType(attr.type)) { return false; } return true; } +async function accessorGetterType(attr) +{ + let type; + let mayNeedPointer = false; + if (StringHelper.isCharString(attr.type)) { + type = "chip::MutableCharSpan"; + } else if (StringHelper.isOctetString(attr.type)) { + type = "chip::MutableByteSpan"; + } else { + mayNeedPointer = true; + const options = { 'hash' : {} }; + type = await zclHelper.asUnderlyingZclType.call(this, attr.type, options); + } + + if (attr.isNullable) { + type = `DataModel::Nullable<${type}> &`; + } else if (mayNeedPointer) { + type = `${type} *`; + } + + return type; +} + // // Module exports // exports.canHaveSimpleAccessors = canHaveSimpleAccessors; +exports.accessorGetterType = accessorGetterType; diff --git a/src/app/zap-templates/templates/app/attributes/Accessors-src.zapt b/src/app/zap-templates/templates/app/attributes/Accessors-src.zapt index 644b35310bc529..134c0612746481 100644 --- a/src/app/zap-templates/templates/app/attributes/Accessors-src.zapt +++ b/src/app/zap-templates/templates/app/attributes/Accessors-src.zapt @@ -11,6 +11,7 @@ #include #include #include +#include namespace chip { namespace app { @@ -25,39 +26,102 @@ namespace Attributes { {{/first}} {{#if clusterRef}} -{{#if (canHaveSimpleAccessors type)}} +{{#if (canHaveSimpleAccessors this)}} namespace {{asUpperCamelCase label}} { {{#*inline "clusterId"}}Clusters::{{asUpperCamelCase parent.label}}::Id{{/inline}} {{#*inline "sizingBytes"}}{{#if (isShortString type)}}1{{else}}2{{/if}}{{/inline}} -EmberAfStatus Get(chip::EndpointId endpoint, {{#if (isCharString type)}}chip::MutableCharSpan{{else if (isOctetString type)}}chip::MutableByteSpan{{else}}{{asUnderlyingZclType type}} *{{/if}} value) +EmberAfStatus Get(chip::EndpointId endpoint, {{accessorGetterType this}} value) { - {{#if (isString type)}} - VerifyOrReturnError(value.size() == {{maxLength}}, EMBER_ZCL_STATUS_INVALID_ARGUMENT); + {{~#if (isString type)}} + {{~#*inline "lengthType"}}uint{{#if (isShortString type)}}8{{else}}16{{/if}}_t{{/inline}} uint8_t zclString[{{maxLength}} + {{>sizingBytes}}]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, {{>clusterId}}, Id, zclString, sizeof(zclString)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - memcpy(value.data(), &zclString[{{>sizingBytes}}], {{maxLength}}); - value.reduce_size(emberAf{{#if (isLongString type)}}Long{{/if}}StringLength(zclString)); + size_t length = emberAf{{#if (isLongString type)}}Long{{/if}}StringLength(zclString); + if (length == NumericAttributeTraits<{{>lengthType}}>::kNullValue) + { + {{#if isNullable}} + value.SetNull(); + return EMBER_ZCL_STATUS_SUCCESS; + {{else}} + return EMBER_ZCL_STATUS_INVALID_VALUE; + {{/if}} + } + {{#if isNullable}} + auto & span = value.SetNonNull(); + {{/if}} + {{~#*inline "value"}}{{#if isNullable}}span{{else}}value{{/if}}{{/inline}} + VerifyOrReturnError({{>value}}.size() == {{maxLength}}, EMBER_ZCL_STATUS_INVALID_ARGUMENT); + memcpy({{>value}}.data(), &zclString[{{>sizingBytes}}], {{maxLength}}); + {{>value}}.reduce_size(length); return status; {{else}} - return emberAfReadServerAttribute(endpoint, {{>clusterId}}, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits<{{asUnderlyingZclType type}}>::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, {{>clusterId}}, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + {{#if isNullable}} + if (NumericAttributeTraits<{{asUnderlyingZclType type}}>::IsNullValue(temp)) + { + value.SetNull(); + } + else + { + value.SetNonNull() = temp; + } + {{else}} + if (!NumericAttributeTraits<{{asUnderlyingZclType type}}>::CanRepresentValue(/* isNullable = */ {{isNullable}}, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + {{/if}} + return status; {{/if}} } EmberAfStatus Set(chip::EndpointId endpoint, {{asUnderlyingZclType type}} value) { - {{#if (isString type)}} + {{~#if (isString type)}} + {{~#*inline "lengthType"}}uint{{#if (isShortString type)}}8{{else}}16{{/if}}_t{{/inline}} + static_assert({{maxLength}} != NumericAttributeTraits<{{>lengthType}}>::kNullValue, + "value.size() might be too big"); VerifyOrReturnError(value.size() <= {{maxLength}}, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[{{maxLength}} + {{>sizingBytes}}]; - emberAfCopyInt{{#if (isShortString type)}}8{{else}}16{{/if}}u(zclString, 0, static_cast(value.size())); + emberAfCopyInt{{#if (isShortString type)}}8{{else}}16{{/if}}u(zclString, 0, static_cast<{{>lengthType}}>(value.size())); memcpy(&zclString[{{>sizingBytes}}], value.data(), value.size()); return emberAfWriteServerAttribute(endpoint, {{>clusterId}}, Id, zclString, ZCL_{{asDelimitedMacro type}}_ATTRIBUTE_TYPE); {{else}} + if (!NumericAttributeTraits<{{asUnderlyingZclType type}}>::CanRepresentValue(/* isNullable = */ {{isNullable}}, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, {{>clusterId}}, Id, (uint8_t *) &value, ZCL_{{asDelimitedMacro type}}_ATTRIBUTE_TYPE); {{/if}} } +{{#if isNullable}} +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + {{#if (isString type)}} + uint8_t zclString[{{>sizingBytes}}] = { {{#if (isShortString type)}}0xFF{{else}}0xFF, 0xFF{{/if}} }; + return emberAfWriteServerAttribute(endpoint, {{>clusterId}}, Id, zclString, ZCL_{{asDelimitedMacro type}}_ATTRIBUTE_TYPE); + {{else}} + auto value = NumericAttributeTraits<{{asUnderlyingZclType type}}>::kNullValue; + return emberAfWriteServerAttribute(endpoint, {{>clusterId}}, Id, reinterpret_cast(&value), ZCL_{{asDelimitedMacro type}}_ATTRIBUTE_TYPE); + {{/if}} +} + +EmberAfStatus Set(chip::EndpointId endpoint, const DataModel::Nullable<{{asUnderlyingZclType type}}> & value) +{ + if (value.IsNull()) { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); +} +{{/if}} + } // namespace {{asUpperCamelCase label}} {{/if}} diff --git a/src/app/zap-templates/templates/app/attributes/Accessors.zapt b/src/app/zap-templates/templates/app/attributes/Accessors.zapt index 232f77fad1c884..f8c7147620e642 100644 --- a/src/app/zap-templates/templates/app/attributes/Accessors.zapt +++ b/src/app/zap-templates/templates/app/attributes/Accessors.zapt @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -23,10 +24,14 @@ namespace Attributes { {{/first}} {{#if clusterRef}} -{{#if (canHaveSimpleAccessors type)}} +{{#if (canHaveSimpleAccessors this)}} namespace {{asUpperCamelCase label}} { -EmberAfStatus Get(chip::EndpointId endpoint, {{#if (isCharString type)}}chip::MutableCharSpan{{else if (isOctetString type)}}chip::MutableByteSpan{{else}}{{asUnderlyingZclType type}} *{{/if}} value); // {{type}} {{isArray}} +EmberAfStatus Get(chip::EndpointId endpoint, {{accessorGetterType this}} value); // {{type}} {{isArray}} EmberAfStatus Set(chip::EndpointId endpoint, {{asUnderlyingZclType type}} value); +{{#if isNullable}} +EmberAfStatus SetNull(chip::EndpointId endpoint); +EmberAfStatus Set(chip::EndpointId endpoint, const DataModel::Nullable<{{asUnderlyingZclType type}}> & value); +{{/if}} } // namespace {{asUpperCamelCase label}} {{/if}} 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 0a3f9b19433c62..335acd65f1a426 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 @@ -28,6 +28,7 @@ #include #include #include +#include namespace chip { namespace app { @@ -40,10 +41,23 @@ namespace MainsVoltage { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -54,10 +68,23 @@ namespace MainsFrequency { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -68,10 +95,23 @@ namespace MainsAlarmMask { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -82,10 +122,23 @@ namespace MainsVoltageMinThreshold { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -96,10 +149,23 @@ namespace MainsVoltageMaxThreshold { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -110,10 +176,23 @@ namespace MainsVoltageDwellTrip { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -124,10 +203,23 @@ namespace BatteryVoltage { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -138,10 +230,23 @@ namespace BatteryPercentageRemaining { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -152,16 +257,23 @@ namespace BatteryManufacturer { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -175,10 +287,23 @@ namespace BatterySize { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -189,10 +314,23 @@ namespace BatteryAhrRating { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -203,10 +341,23 @@ namespace BatteryQuantity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -217,10 +368,23 @@ namespace BatteryRatedVoltage { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -231,10 +395,23 @@ namespace BatteryAlarmMask { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -245,10 +422,23 @@ namespace BatteryVoltageMinThreshold { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -259,10 +449,23 @@ namespace BatteryVoltageThreshold1 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -273,10 +476,23 @@ namespace BatteryVoltageThreshold2 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -287,10 +503,23 @@ namespace BatteryVoltageThreshold3 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -301,10 +530,23 @@ namespace BatteryPercentageMinThreshold { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -315,10 +557,23 @@ namespace BatteryPercentageThreshold1 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -329,10 +584,23 @@ namespace BatteryPercentageThreshold2 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -343,10 +611,23 @@ namespace BatteryPercentageThreshold3 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -357,10 +638,23 @@ namespace BatteryAlarmState { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_BITMAP32_ATTRIBUTE_TYPE); } @@ -371,10 +665,23 @@ namespace Battery2Voltage { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -385,10 +692,23 @@ namespace Battery2PercentageRemaining { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -399,16 +719,23 @@ namespace Battery2Manufacturer { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -422,10 +749,23 @@ namespace Battery2Size { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -436,10 +776,23 @@ namespace Battery2AhrRating { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -450,10 +803,23 @@ namespace Battery2Quantity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -464,10 +830,23 @@ namespace Battery2RatedVoltage { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -478,10 +857,23 @@ namespace Battery2AlarmMask { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -492,10 +884,23 @@ namespace Battery2VoltageMinThreshold { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -506,10 +911,23 @@ namespace Battery2VoltageThreshold1 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -520,10 +938,23 @@ namespace Battery2VoltageThreshold2 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -534,10 +965,23 @@ namespace Battery2VoltageThreshold3 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -548,10 +992,23 @@ namespace Battery2PercentageMinThreshold { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -562,10 +1019,23 @@ namespace Battery2PercentageThreshold1 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -576,10 +1046,23 @@ namespace Battery2PercentageThreshold2 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -590,10 +1073,23 @@ namespace Battery2PercentageThreshold3 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -604,10 +1100,23 @@ namespace Battery2AlarmState { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_BITMAP32_ATTRIBUTE_TYPE); } @@ -618,10 +1127,23 @@ namespace Battery3Voltage { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -632,10 +1154,23 @@ namespace Battery3PercentageRemaining { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -646,16 +1181,23 @@ namespace Battery3Manufacturer { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -669,10 +1211,23 @@ namespace Battery3Size { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -683,10 +1238,23 @@ namespace Battery3AhrRating { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -697,10 +1265,23 @@ namespace Battery3Quantity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -711,10 +1292,23 @@ namespace Battery3RatedVoltage { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -725,10 +1319,23 @@ namespace Battery3AlarmMask { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -739,10 +1346,23 @@ namespace Battery3VoltageMinThreshold { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -753,10 +1373,23 @@ namespace Battery3VoltageThreshold1 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -767,10 +1400,23 @@ namespace Battery3VoltageThreshold2 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -781,10 +1427,23 @@ namespace Battery3VoltageThreshold3 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -795,10 +1454,23 @@ namespace Battery3PercentageMinThreshold { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -809,10 +1481,23 @@ namespace Battery3PercentageThreshold1 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -823,10 +1508,23 @@ namespace Battery3PercentageThreshold2 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -837,10 +1535,23 @@ namespace Battery3PercentageThreshold3 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -851,10 +1562,23 @@ namespace Battery3AlarmState { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerConfiguration::Id, Id, (uint8_t *) &value, ZCL_BITMAP32_ATTRIBUTE_TYPE); } @@ -871,11 +1595,23 @@ namespace CurrentTemperature { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -886,11 +1622,23 @@ namespace MinTempExperienced { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -901,11 +1649,23 @@ namespace MaxTempExperienced { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -916,11 +1676,23 @@ namespace OverTempTotalDwell { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -931,11 +1703,23 @@ namespace DeviceTempAlarmMask { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -946,11 +1730,23 @@ namespace LowTempThreshold { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -961,11 +1757,23 @@ namespace HighTempThreshold { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DeviceTemperatureConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -982,10 +1790,23 @@ namespace IdentifyTime { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Identify::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Identify::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Identify::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -995,10 +1816,23 @@ namespace IdentifyType { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Identify::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Identify::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Identify::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -1014,10 +1848,23 @@ namespace NameSupport { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Groups::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Groups::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Groups::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -1033,10 +1880,23 @@ namespace SceneCount { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Scenes::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Scenes::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Scenes::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -1046,10 +1906,23 @@ namespace CurrentScene { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Scenes::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Scenes::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Scenes::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -1059,10 +1932,23 @@ namespace CurrentGroup { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Scenes::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Scenes::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Scenes::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1072,10 +1958,23 @@ namespace SceneValid { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Scenes::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Scenes::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Scenes::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -1085,10 +1984,23 @@ namespace NameSupport { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Scenes::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Scenes::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Scenes::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -1098,10 +2010,23 @@ namespace LastConfiguredBy { EmberAfStatus Get(chip::EndpointId endpoint, chip::NodeId * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Scenes::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Scenes::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::NodeId value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Scenes::Id, Id, (uint8_t *) &value, ZCL_NODE_ID_ATTRIBUTE_TYPE); } @@ -1117,10 +2042,23 @@ namespace OnOff { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -1130,10 +2068,23 @@ namespace SampleMfgSpecificAttribute0x00000x1002 { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1143,10 +2094,23 @@ namespace SampleMfgSpecificAttribute0x00000x1049 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -1156,10 +2120,23 @@ namespace SampleMfgSpecificAttribute0x00010x1002 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -1169,10 +2146,23 @@ namespace SampleMfgSpecificAttribute0x00010x1040 { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1182,10 +2172,23 @@ namespace GlobalSceneControl { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -1195,10 +2198,23 @@ namespace OnTime { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1208,10 +2224,23 @@ namespace OffWaitTime { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1221,10 +2250,23 @@ namespace StartUpOnOff { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OnOff::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -1240,10 +2282,23 @@ namespace SwitchType { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OnOffSwitchConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OnOffSwitchConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OnOffSwitchConfiguration::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -1254,10 +2309,23 @@ namespace SwitchActions { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OnOffSwitchConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OnOffSwitchConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OnOffSwitchConfiguration::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -1274,10 +2342,23 @@ namespace CurrentLevel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -1287,10 +2368,23 @@ namespace RemainingTime { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1300,10 +2394,23 @@ namespace MinLevel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -1313,10 +2420,23 @@ namespace MaxLevel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -1326,10 +2446,23 @@ namespace CurrentFrequency { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1339,10 +2472,23 @@ namespace MinFrequency { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1352,10 +2498,23 @@ namespace MaxFrequency { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1365,10 +2524,23 @@ namespace Options { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -1378,10 +2550,23 @@ namespace OnOffTransitionTime { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1391,10 +2576,23 @@ namespace OnLevel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -1404,10 +2602,23 @@ namespace OnTransitionTime { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1417,10 +2628,23 @@ namespace OffTransitionTime { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1430,10 +2654,23 @@ namespace DefaultMoveRate { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -1443,10 +2680,23 @@ namespace StartUpCurrentLevel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LevelControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LevelControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -1462,10 +2712,23 @@ namespace AlarmCount { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Alarms::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Alarms::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Alarms::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1481,10 +2744,23 @@ namespace Time { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) &value, ZCL_EPOCH_S_ATTRIBUTE_TYPE); } @@ -1494,10 +2770,23 @@ namespace TimeStatus { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -1507,10 +2796,23 @@ namespace TimeZone { EmberAfStatus Get(chip::EndpointId endpoint, int32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) &value, ZCL_INT32S_ATTRIBUTE_TYPE); } @@ -1520,10 +2822,23 @@ namespace DstStart { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -1533,10 +2848,23 @@ namespace DstEnd { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -1546,10 +2874,23 @@ namespace DstShift { EmberAfStatus Get(chip::EndpointId endpoint, int32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) &value, ZCL_INT32S_ATTRIBUTE_TYPE); } @@ -1559,10 +2900,23 @@ namespace StandardTime { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -1572,10 +2926,23 @@ namespace LocalTime { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) value, sizeof(*value)); -} + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; +} EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -1585,10 +2952,23 @@ namespace LastSetTime { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) &value, ZCL_EPOCH_S_ATTRIBUTE_TYPE); } @@ -1598,10 +2978,23 @@ namespace ValidUntilTime { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Time::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Time::Id, Id, (uint8_t *) &value, ZCL_EPOCH_S_ATTRIBUTE_TYPE); } @@ -1617,16 +3010,23 @@ namespace ActiveText { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -1640,16 +3040,23 @@ namespace Description { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -1663,16 +3070,23 @@ namespace InactiveText { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -1686,10 +3100,23 @@ namespace OutOfService { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -1700,10 +3127,23 @@ namespace Polarity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -1713,10 +3153,23 @@ namespace PresentValue { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -1727,10 +3180,23 @@ namespace Reliability { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -1740,10 +3206,23 @@ namespace StatusFlags { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -1754,10 +3233,23 @@ namespace ApplicationType { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BinaryInputBasic::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -1773,10 +3265,23 @@ namespace TotalProfileNum { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -1786,10 +3291,23 @@ namespace MultipleScheduling { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -1799,10 +3317,23 @@ namespace EnergyFormatting { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -1812,10 +3343,23 @@ namespace EnergyRemote { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -1825,10 +3369,23 @@ namespace ScheduleMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerProfile::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -1844,10 +3401,23 @@ namespace StartTime { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplianceControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ApplianceControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplianceControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1857,10 +3427,23 @@ namespace FinishTime { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplianceControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ApplianceControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplianceControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1870,10 +3453,23 @@ namespace RemainingTime { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplianceControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ApplianceControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplianceControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1895,10 +3491,23 @@ namespace CheckInInterval { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -1908,10 +3517,23 @@ namespace LongPollInterval { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -1921,10 +3543,23 @@ namespace ShortPollInterval { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1934,10 +3569,23 @@ namespace FastPollTimeout { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1947,10 +3595,23 @@ namespace CheckInIntervalMin { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -1960,10 +3621,23 @@ namespace LongPollIntervalMin { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -1973,10 +3647,23 @@ namespace FastPollTimeoutMax { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PollControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PollControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -1992,16 +3679,23 @@ namespace SetupUrl { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 512, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[512 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedActions::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 512, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 512); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(512 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 512, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[512 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2021,10 +3715,23 @@ namespace InteractionModelVersion { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -2034,16 +3741,23 @@ namespace VendorName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::Basic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2057,10 +3771,23 @@ namespace VendorID { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -2070,16 +3797,23 @@ namespace ProductName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::Basic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2093,10 +3827,23 @@ namespace ProductID { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -2106,16 +3853,23 @@ namespace UserLabel { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::Basic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2129,16 +3883,23 @@ namespace Location { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 2, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[2 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::Basic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 2, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 2); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(2 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 2, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[2 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2152,10 +3913,23 @@ namespace HardwareVersion { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -2165,16 +3939,23 @@ namespace HardwareVersionString { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[64 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::Basic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 64); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(64 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[64 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2188,10 +3969,23 @@ namespace SoftwareVersion { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -2201,16 +3995,23 @@ namespace SoftwareVersionString { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[64 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::Basic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 64); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(64 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[64 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2224,16 +4025,23 @@ namespace ManufacturingDate { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::Basic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2247,16 +4055,23 @@ namespace PartNumber { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::Basic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2270,16 +4085,23 @@ namespace ProductURL { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 256, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[256 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::Basic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 256, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 256); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(256 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 256, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[256 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2293,16 +4115,23 @@ namespace ProductLabel { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[64 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::Basic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 64); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(64 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[64 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2316,16 +4145,23 @@ namespace SerialNumber { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::Basic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2339,10 +4175,23 @@ namespace LocalConfigDisabled { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -2352,10 +4201,23 @@ namespace Reachable { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Basic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Basic::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -2371,17 +4233,24 @@ namespace DefaultOtaProvider { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2396,10 +4265,23 @@ namespace UpdatePossible { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -2416,10 +4298,23 @@ namespace Status { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -2429,10 +4324,23 @@ namespace Order { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -2442,16 +4350,23 @@ namespace Description { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 60, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[60 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerSource::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 60, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 60); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(60 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 60, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[60 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2465,10 +4380,23 @@ namespace WiredAssessedInputVoltage { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -2478,10 +4406,23 @@ namespace WiredAssessedInputFrequency { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -2491,10 +4432,23 @@ namespace WiredCurrentType { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -2504,10 +4458,23 @@ namespace WiredAssessedCurrent { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -2517,10 +4484,23 @@ namespace WiredNominalVoltage { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -2530,10 +4510,23 @@ namespace WiredMaximumCurrent { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -2543,10 +4536,23 @@ namespace WiredPresent { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -2556,10 +4562,23 @@ namespace BatteryVoltage { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -2569,10 +4588,23 @@ namespace BatteryPercentRemaining { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -2582,10 +4614,23 @@ namespace BatteryTimeRemaining { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -2595,10 +4640,23 @@ namespace BatteryChargeLevel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -2608,10 +4666,23 @@ namespace BatteryReplacementNeeded { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -2621,10 +4692,23 @@ namespace BatteryReplaceability { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -2634,10 +4718,23 @@ namespace BatteryPresent { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -2647,16 +4744,23 @@ namespace BatteryReplacementDescription { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 60, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[60 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerSource::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 60, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 60); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(60 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 60, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[60 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2670,10 +4774,23 @@ namespace BatteryCommonDesignation { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -2683,16 +4800,23 @@ namespace BatteryANSIDesignation { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 20, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[20 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerSource::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 20, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 20); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(20 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 20, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[20 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2706,16 +4830,23 @@ namespace BatteryIECDesignation { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 20, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[20 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PowerSource::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 20, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 20); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(20 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 20, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[20 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -2729,10 +4860,23 @@ namespace BatteryApprovedChemistry { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -2742,10 +4886,23 @@ namespace BatteryCapacity { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -2755,10 +4912,23 @@ namespace BatteryQuantity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -2768,10 +4938,23 @@ namespace BatteryChargeState { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -2781,10 +4964,23 @@ namespace BatteryTimeToFullCharge { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -2794,10 +4990,23 @@ namespace BatteryFunctionalWhileCharging { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -2807,10 +5016,23 @@ namespace BatteryChargingCurrent { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::PowerSource::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PowerSource::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -2826,10 +5048,23 @@ namespace Breadcrumb { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -2846,10 +5081,23 @@ namespace RebootCount { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -2860,10 +5108,23 @@ namespace UpTime { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -2874,10 +5135,23 @@ namespace TotalOperationalHours { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -2888,10 +5162,23 @@ namespace BootReasons { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -2908,10 +5195,23 @@ namespace CurrentHeapFree { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -2922,10 +5222,23 @@ namespace CurrentHeapUsed { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -2936,10 +5249,23 @@ namespace CurrentHeapHighWatermark { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -2956,10 +5282,23 @@ namespace Channel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -2970,10 +5309,23 @@ namespace RoutingRole { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -2984,17 +5336,24 @@ namespace NetworkName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -3009,10 +5368,23 @@ namespace PanId { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -3023,10 +5395,23 @@ namespace ExtendedPanId { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -3037,17 +5422,24 @@ namespace MeshLocalPrefix { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 17, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[17 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 17, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 17); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(17 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 17, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[17 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -3062,10 +5454,23 @@ namespace OverrunCount { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -3076,10 +5481,23 @@ namespace PartitionId { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3090,10 +5508,23 @@ namespace Weighting { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -3104,10 +5535,23 @@ namespace DataVersion { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -3118,10 +5562,23 @@ namespace StableDataVersion { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -3132,10 +5589,23 @@ namespace LeaderRouterId { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -3146,10 +5616,23 @@ namespace DetachedRoleCount { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -3160,10 +5643,23 @@ namespace ChildRoleCount { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -3174,10 +5670,23 @@ namespace RouterRoleCount { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -3188,10 +5697,23 @@ namespace LeaderRoleCount { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -3202,10 +5724,23 @@ namespace AttachAttemptCount { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -3216,10 +5751,23 @@ namespace PartitionIdChangeCount { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -3230,10 +5778,23 @@ namespace BetterPartitionAttachAttemptCount { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -3244,10 +5805,23 @@ namespace ParentChangeCount { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -3258,10 +5832,23 @@ namespace TxTotalCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3272,10 +5859,23 @@ namespace TxUnicastCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3286,10 +5886,23 @@ namespace TxBroadcastCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3300,10 +5913,23 @@ namespace TxAckRequestedCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3314,10 +5940,23 @@ namespace TxAckedCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3328,10 +5967,23 @@ namespace TxNoAckRequestedCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3342,10 +5994,23 @@ namespace TxDataCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3356,10 +6021,23 @@ namespace TxDataPollCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3370,10 +6048,23 @@ namespace TxBeaconCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3384,10 +6075,23 @@ namespace TxBeaconRequestCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3398,10 +6102,23 @@ namespace TxOtherCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3412,10 +6129,23 @@ namespace TxRetryCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3426,10 +6156,23 @@ namespace TxDirectMaxRetryExpiryCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3440,10 +6183,23 @@ namespace TxIndirectMaxRetryExpiryCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3454,10 +6210,23 @@ namespace TxErrCcaCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3468,10 +6237,23 @@ namespace TxErrAbortCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3482,10 +6264,23 @@ namespace TxErrBusyChannelCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3496,10 +6291,23 @@ namespace RxTotalCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3510,10 +6318,23 @@ namespace RxUnicastCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3524,10 +6345,23 @@ namespace RxBroadcastCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3538,10 +6372,23 @@ namespace RxDataCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3552,10 +6399,23 @@ namespace RxDataPollCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3566,10 +6426,23 @@ namespace RxBeaconCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3580,10 +6453,23 @@ namespace RxBeaconRequestCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3594,10 +6480,23 @@ namespace RxOtherCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3608,10 +6507,23 @@ namespace RxAddressFilteredCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3622,10 +6534,23 @@ namespace RxDestAddrFilteredCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3636,10 +6561,23 @@ namespace RxDuplicatedCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3650,10 +6588,23 @@ namespace RxErrNoFrameCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3664,10 +6615,23 @@ namespace RxErrUnknownNeighborCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3678,10 +6642,23 @@ namespace RxErrInvalidSrcAddrCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3692,10 +6669,23 @@ namespace RxErrSecCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3706,10 +6696,23 @@ namespace RxErrFcsCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3720,10 +6723,23 @@ namespace RxErrOtherCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3734,10 +6750,23 @@ namespace ActiveTimestamp { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -3748,10 +6777,23 @@ namespace PendingTimestamp { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -3762,10 +6804,23 @@ namespace Delay { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3776,17 +6831,24 @@ namespace ChannelMask { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 4, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[4 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 4, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 4); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(4 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 4, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[4 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -3807,17 +6869,24 @@ namespace Bssid { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[6 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 6); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(6 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[6 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -3832,10 +6901,23 @@ namespace SecurityType { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -3846,10 +6928,23 @@ namespace WiFiVersion { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -3860,10 +6955,23 @@ namespace ChannelNumber { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -3874,10 +6982,23 @@ namespace Rssi { EmberAfStatus Get(chip::EndpointId endpoint, int8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT8S_ATTRIBUTE_TYPE); } @@ -3888,10 +7009,23 @@ namespace BeaconLostCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3902,10 +7036,23 @@ namespace BeaconRxCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3916,10 +7063,23 @@ namespace PacketMulticastRxCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3930,10 +7090,23 @@ namespace PacketMulticastTxCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3944,10 +7117,23 @@ namespace PacketUnicastRxCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3958,10 +7144,23 @@ namespace PacketUnicastTxCount { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -3972,10 +7171,23 @@ namespace CurrentMaxRate { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -3986,10 +7198,23 @@ namespace OverrunCount { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -4006,10 +7231,23 @@ namespace PHYRate { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -4020,10 +7258,23 @@ namespace FullDuplex { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -4034,10 +7285,23 @@ namespace PacketRxCount { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -4048,10 +7312,23 @@ namespace PacketTxCount { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -4062,10 +7339,23 @@ namespace TxErrCount { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -4076,10 +7366,23 @@ namespace CollisionCount { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -4090,10 +7393,23 @@ namespace OverrunCount { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -4104,10 +7420,23 @@ namespace CarrierDetect { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -4118,10 +7447,23 @@ namespace TimeSinceReset { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -4138,16 +7480,23 @@ namespace VendorName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -4161,10 +7510,23 @@ namespace VendorID { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BridgedDeviceBasic::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -4175,16 +7537,23 @@ namespace ProductName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -4198,16 +7567,23 @@ namespace UserLabel { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -4221,10 +7597,23 @@ namespace HardwareVersion { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BridgedDeviceBasic::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -4235,16 +7624,23 @@ namespace HardwareVersionString { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[64 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 64); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(64 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[64 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -4258,10 +7654,23 @@ namespace SoftwareVersion { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BridgedDeviceBasic::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -4272,16 +7681,23 @@ namespace SoftwareVersionString { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[64 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 64); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(64 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[64 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -4295,16 +7711,23 @@ namespace ManufacturingDate { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -4318,16 +7741,23 @@ namespace PartNumber { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[254 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 254); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(254 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[254 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -4341,16 +7771,23 @@ namespace ProductURL { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[254 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 254); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(254 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[254 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -4364,16 +7801,23 @@ namespace ProductLabel { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[64 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 64); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(64 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[64 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -4387,16 +7831,23 @@ namespace SerialNumber { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -4410,10 +7861,23 @@ namespace Reachable { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BridgedDeviceBasic::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BridgedDeviceBasic::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -4430,10 +7894,23 @@ namespace NumberOfPositions { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Switch::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Switch::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Switch::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4443,10 +7920,23 @@ namespace CurrentPosition { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Switch::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Switch::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Switch::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4456,10 +7946,23 @@ namespace MultiPressMax { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Switch::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Switch::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Switch::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4475,10 +7978,23 @@ namespace SupportedFabrics { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4489,10 +8005,23 @@ namespace CommissionedFabrics { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4503,10 +8032,23 @@ namespace CurrentFabricIndex { EmberAfStatus Get(chip::EndpointId endpoint, chip::FabricIndex * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::FabricIndex value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, (uint8_t *) &value, ZCL_FABRIC_IDX_ATTRIBUTE_TYPE); } @@ -4529,10 +8071,23 @@ namespace StateValue { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BooleanState::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BooleanState::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BooleanState::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -4548,10 +8103,23 @@ namespace CurrentMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ModeSelect::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ModeSelect::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ModeSelect::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4561,10 +8129,23 @@ namespace OnMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ModeSelect::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ModeSelect::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ModeSelect::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4574,10 +8155,23 @@ namespace StartUpMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ModeSelect::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ModeSelect::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ModeSelect::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4587,16 +8181,23 @@ namespace Description { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ModeSelect::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -4616,10 +8217,23 @@ namespace PhysicalClosedLimit { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -4630,10 +8244,23 @@ namespace MotorStepSize { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4644,10 +8271,23 @@ namespace Status { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -4658,10 +8298,23 @@ namespace ClosedLimit { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -4672,10 +8325,23 @@ namespace Mode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ShadeConfiguration::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -4692,10 +8358,23 @@ namespace LockState { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -4705,10 +8384,23 @@ namespace LockType { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -4718,10 +8410,23 @@ namespace ActuatorEnabled { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -4731,10 +8436,23 @@ namespace DoorState { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -4744,10 +8462,23 @@ namespace DoorOpenEvents { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -4757,10 +8488,23 @@ namespace DoorClosedEvents { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -4770,10 +8514,23 @@ namespace OpenPeriod { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -4783,10 +8540,23 @@ namespace NumLockRecordsSupported { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -4796,10 +8566,23 @@ namespace NumTotalUsersSupported { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -4809,10 +8592,23 @@ namespace NumPinUsersSupported { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -4822,10 +8618,23 @@ namespace NumRfidUsersSupported { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -4835,10 +8644,23 @@ namespace NumWeekdaySchedulesSupportedPerUser { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4848,10 +8670,23 @@ namespace NumYeardaySchedulesSupportedPerUser { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4861,10 +8696,23 @@ namespace NumHolidaySchedulesSupportedPerUser { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4874,10 +8722,23 @@ namespace MaxPinLength { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4887,10 +8748,23 @@ namespace MinPinLength { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4900,10 +8774,23 @@ namespace MaxRfidCodeLength { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4913,10 +8800,23 @@ namespace MinRfidCodeLength { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4926,10 +8826,23 @@ namespace EnableLogging { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -4939,16 +8852,23 @@ namespace Language { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 2, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[2 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DoorLock::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 2, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 2); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(2 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 2, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[2 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -4962,10 +8882,23 @@ namespace LedSettings { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -4975,10 +8908,23 @@ namespace AutoRelockTime { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -4988,10 +8934,23 @@ namespace SoundVolume { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -5001,10 +8960,23 @@ namespace OperatingMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -5014,10 +8986,23 @@ namespace SupportedOperatingModes { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -5027,10 +9012,23 @@ namespace DefaultConfigurationRegister { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -5040,10 +9038,23 @@ namespace EnableLocalProgramming { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -5053,10 +9064,23 @@ namespace EnableOneTouchLocking { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -5066,10 +9090,23 @@ namespace EnableInsideStatusLed { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -5079,10 +9116,23 @@ namespace EnablePrivacyModeButton { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -5092,10 +9142,23 @@ namespace WrongCodeEntryLimit { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -5105,10 +9168,23 @@ namespace UserCodeTemporaryDisableTime { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -5118,10 +9194,23 @@ namespace SendPinOverTheAir { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -5131,10 +9220,23 @@ namespace RequirePinForRfOperation { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -5144,10 +9246,23 @@ namespace ZigbeeSecurityLevel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -5157,10 +9272,23 @@ namespace AlarmMask { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -5170,10 +9298,23 @@ namespace KeypadOperationEventMask { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -5183,10 +9324,23 @@ namespace RfOperationEventMask { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -5196,10 +9350,23 @@ namespace ManualOperationEventMask { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -5209,10 +9376,23 @@ namespace RfidOperationEventMask { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -5222,10 +9402,23 @@ namespace KeypadProgrammingEventMask { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -5235,10 +9428,23 @@ namespace RfProgrammingEventMask { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -5248,10 +9454,23 @@ namespace RfidProgrammingEventMask { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::DoorLock::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DoorLock::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -5267,10 +9486,23 @@ namespace Type { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -5280,10 +9512,23 @@ namespace PhysicalClosedLimitLift { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5293,10 +9538,23 @@ namespace PhysicalClosedLimitTilt { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5306,10 +9564,23 @@ namespace CurrentPositionLift { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5319,10 +9590,23 @@ namespace CurrentPositionTilt { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5332,10 +9616,23 @@ namespace NumberOfActuationsLift { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5345,10 +9642,23 @@ namespace NumberOfActuationsTilt { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5358,10 +9668,23 @@ namespace ConfigStatus { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -5371,10 +9694,23 @@ namespace CurrentPositionLiftPercentage { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -5384,10 +9720,23 @@ namespace CurrentPositionTiltPercentage { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -5397,10 +9746,23 @@ namespace OperationalStatus { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -5410,10 +9772,23 @@ namespace TargetPositionLiftPercent100ths { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5423,10 +9798,23 @@ namespace TargetPositionTiltPercent100ths { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5436,10 +9824,23 @@ namespace EndProductType { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -5449,10 +9850,23 @@ namespace CurrentPositionLiftPercent100ths { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5462,10 +9876,23 @@ namespace CurrentPositionTiltPercent100ths { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5475,10 +9902,23 @@ namespace InstalledOpenLimitLift { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5488,10 +9928,23 @@ namespace InstalledClosedLimitLift { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5501,10 +9954,23 @@ namespace InstalledOpenLimitTilt { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5514,10 +9980,23 @@ namespace InstalledClosedLimitTilt { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5527,10 +10006,23 @@ namespace VelocityLift { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5540,10 +10032,23 @@ namespace AccelerationTimeLift { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5553,10 +10058,23 @@ namespace DecelerationTimeLift { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5566,10 +10084,23 @@ namespace Mode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -5579,16 +10110,23 @@ namespace IntermediateSetpointsLift { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[254 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 254); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(254 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[254 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -5602,16 +10140,23 @@ namespace IntermediateSetpointsTilt { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[254 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 254); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(254 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[254 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -5625,10 +10170,23 @@ namespace SafetyStatus { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::WindowCovering::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -5644,10 +10202,23 @@ namespace BarrierMovingState { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -5657,10 +10228,23 @@ namespace BarrierSafetyStatus { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -5670,10 +10254,23 @@ namespace BarrierCapabilities { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -5683,10 +10280,23 @@ namespace BarrierOpenEvents { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5696,10 +10306,23 @@ namespace BarrierCloseEvents { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5709,10 +10332,23 @@ namespace BarrierCommandOpenEvents { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5722,10 +10358,23 @@ namespace BarrierCommandCloseEvents { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5735,10 +10384,23 @@ namespace BarrierOpenPeriod { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5748,10 +10410,23 @@ namespace BarrierClosePeriod { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5761,10 +10436,23 @@ namespace BarrierPosition { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BarrierControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -5780,10 +10468,23 @@ namespace MaxPressure { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -5794,10 +10495,23 @@ namespace MaxSpeed { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5808,10 +10522,23 @@ namespace MaxFlow { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5822,10 +10549,23 @@ namespace MinConstPressure { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -5836,10 +10576,23 @@ namespace MaxConstPressure { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -5850,10 +10603,23 @@ namespace MinCompPressure { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -5864,10 +10630,23 @@ namespace MaxCompPressure { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -5878,10 +10657,23 @@ namespace MinConstSpeed { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5892,10 +10684,23 @@ namespace MaxConstSpeed { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5906,10 +10711,23 @@ namespace MinConstFlow { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5920,10 +10738,23 @@ namespace MaxConstFlow { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -5934,10 +10765,23 @@ namespace MinConstTemp { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -5948,10 +10792,23 @@ namespace MaxConstTemp { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -5962,10 +10819,23 @@ namespace PumpStatus { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -5976,10 +10846,23 @@ namespace EffectiveOperationMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -5990,10 +10873,23 @@ namespace EffectiveControlMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6004,10 +10900,23 @@ namespace Capacity { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6018,10 +10927,23 @@ namespace Speed { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -6032,10 +10954,23 @@ namespace LifetimeEnergyConsumed { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -6046,10 +10981,23 @@ namespace OperationMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6060,10 +11008,23 @@ namespace ControlMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6074,10 +11035,23 @@ namespace AlarmMask { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PumpConfigurationAndControl::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -6094,10 +11068,23 @@ namespace LocalTemperature { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6107,10 +11094,23 @@ namespace OutdoorTemperature { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6120,10 +11120,23 @@ namespace Occupancy { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -6133,10 +11146,23 @@ namespace AbsMinHeatSetpointLimit { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6146,10 +11172,23 @@ namespace AbsMaxHeatSetpointLimit { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6159,10 +11198,23 @@ namespace AbsMinCoolSetpointLimit { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6172,10 +11224,23 @@ namespace AbsMaxCoolSetpointLimit { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6185,10 +11250,23 @@ namespace PiCoolingDemand { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -6198,10 +11276,23 @@ namespace PiHeatingDemand { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -6211,10 +11302,23 @@ namespace HvacSystemTypeConfiguration { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -6224,10 +11328,23 @@ namespace LocalTemperatureCalibration { EmberAfStatus Get(chip::EndpointId endpoint, int8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT8S_ATTRIBUTE_TYPE); } @@ -6237,10 +11354,23 @@ namespace OccupiedCoolingSetpoint { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6250,10 +11380,23 @@ namespace OccupiedHeatingSetpoint { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6263,10 +11406,23 @@ namespace UnoccupiedCoolingSetpoint { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6276,10 +11432,23 @@ namespace UnoccupiedHeatingSetpoint { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6289,10 +11458,23 @@ namespace MinHeatSetpointLimit { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6302,10 +11484,23 @@ namespace MaxHeatSetpointLimit { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6315,10 +11510,23 @@ namespace MinCoolSetpointLimit { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6328,10 +11536,23 @@ namespace MaxCoolSetpointLimit { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6341,10 +11562,23 @@ namespace MinSetpointDeadBand { EmberAfStatus Get(chip::EndpointId endpoint, int8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT8S_ATTRIBUTE_TYPE); } @@ -6354,10 +11588,23 @@ namespace RemoteSensing { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -6367,10 +11614,23 @@ namespace ControlSequenceOfOperation { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6380,10 +11640,23 @@ namespace SystemMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6393,10 +11666,23 @@ namespace AlarmMask { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -6406,10 +11692,23 @@ namespace ThermostatRunningMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6419,10 +11718,23 @@ namespace StartOfWeek { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6432,10 +11744,23 @@ namespace NumberOfWeeklyTransitions { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -6445,10 +11770,23 @@ namespace NumberOfDailyTransitions { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -6458,10 +11796,23 @@ namespace TemperatureSetpointHold { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6471,10 +11822,23 @@ namespace TemperatureSetpointHoldDuration { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -6484,10 +11848,23 @@ namespace ThermostatProgrammingOperationMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -6497,10 +11874,23 @@ namespace HvacRelayState { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -6510,10 +11900,23 @@ namespace SetpointChangeSource { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6523,10 +11926,23 @@ namespace SetpointChangeAmount { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6536,10 +11952,23 @@ namespace SetpointChangeSourceTimestamp { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_EPOCH_S_ATTRIBUTE_TYPE); } @@ -6549,10 +11978,23 @@ namespace AcType { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6562,10 +12004,23 @@ namespace AcCapacity { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -6575,10 +12030,23 @@ namespace AcRefrigerantType { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6588,10 +12056,23 @@ namespace AcCompressor { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6601,10 +12082,23 @@ namespace AcErrorCode { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_BITMAP32_ATTRIBUTE_TYPE); } @@ -6614,10 +12108,23 @@ namespace AcLouverPosition { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6627,10 +12134,23 @@ namespace AcCoilTemperature { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -6640,10 +12160,23 @@ namespace AcCapacityFormat { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::Thermostat::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::Thermostat::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6659,10 +12192,23 @@ namespace FanMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FanControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::FanControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FanControl::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6672,10 +12218,23 @@ namespace FanModeSequence { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FanControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::FanControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FanControl::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6691,10 +12250,23 @@ namespace RelativeHumidity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -6705,10 +12277,23 @@ namespace DehumidificationCooling { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -6719,10 +12304,23 @@ namespace RhDehumidificationSetpoint { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -6733,10 +12331,23 @@ namespace RelativeHumidityMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6747,10 +12358,23 @@ namespace DehumidificationLockout { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6761,10 +12385,23 @@ namespace DehumidificationHysteresis { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -6775,10 +12412,23 @@ namespace DehumidificationMaxCool { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -6789,10 +12439,23 @@ namespace RelativeHumidityDisplay { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DehumidificationControl::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6809,11 +12472,23 @@ namespace TemperatureDisplayMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThermostatUserInterfaceConfiguration::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThermostatUserInterfaceConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThermostatUserInterfaceConfiguration::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6824,11 +12499,23 @@ namespace KeypadLockout { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThermostatUserInterfaceConfiguration::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThermostatUserInterfaceConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThermostatUserInterfaceConfiguration::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6839,11 +12526,23 @@ namespace ScheduleProgrammingVisibility { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ThermostatUserInterfaceConfiguration::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ThermostatUserInterfaceConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ThermostatUserInterfaceConfiguration::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6860,10 +12559,23 @@ namespace CurrentHue { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -6873,10 +12585,23 @@ namespace CurrentSaturation { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -6886,10 +12611,23 @@ namespace RemainingTime { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -6899,10 +12637,23 @@ namespace CurrentX { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -6912,10 +12663,23 @@ namespace CurrentY { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -6925,10 +12689,23 @@ namespace DriftCompensation { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6938,16 +12715,23 @@ namespace CompensationText { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[254 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ColorControl::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 254); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(254 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 254, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[254 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -6961,10 +12745,23 @@ namespace ColorTemperature { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -6974,10 +12771,23 @@ namespace ColorMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -6987,10 +12797,23 @@ namespace ColorControlOptions { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -7000,10 +12823,23 @@ namespace NumberOfPrimaries { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7013,10 +12849,23 @@ namespace Primary1X { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7026,10 +12875,23 @@ namespace Primary1Y { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7039,10 +12901,23 @@ namespace Primary1Intensity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7052,10 +12927,23 @@ namespace Primary2X { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7065,10 +12953,23 @@ namespace Primary2Y { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7078,10 +12979,23 @@ namespace Primary2Intensity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7091,10 +13005,23 @@ namespace Primary3X { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7104,10 +13031,23 @@ namespace Primary3Y { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7117,10 +13057,23 @@ namespace Primary3Intensity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7130,10 +13083,23 @@ namespace Primary4X { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7143,10 +13109,23 @@ namespace Primary4Y { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7156,10 +13135,23 @@ namespace Primary4Intensity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7169,10 +13161,23 @@ namespace Primary5X { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7182,10 +13187,23 @@ namespace Primary5Y { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7195,10 +13213,23 @@ namespace Primary5Intensity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7208,10 +13239,23 @@ namespace Primary6X { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7221,10 +13265,23 @@ namespace Primary6Y { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7234,10 +13291,23 @@ namespace Primary6Intensity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7247,10 +13317,23 @@ namespace WhitePointX { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7260,10 +13343,23 @@ namespace WhitePointY { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7273,10 +13369,23 @@ namespace ColorPointRX { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7286,10 +13395,23 @@ namespace ColorPointRY { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7299,10 +13421,23 @@ namespace ColorPointRIntensity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7312,10 +13447,23 @@ namespace ColorPointGX { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7325,10 +13473,23 @@ namespace ColorPointGY { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7338,10 +13499,23 @@ namespace ColorPointGIntensity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7351,10 +13525,23 @@ namespace ColorPointBX { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7364,10 +13551,23 @@ namespace ColorPointBY { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7377,10 +13577,23 @@ namespace ColorPointBIntensity { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7390,10 +13603,23 @@ namespace EnhancedCurrentHue { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7403,10 +13629,23 @@ namespace EnhancedColorMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -7416,10 +13655,23 @@ namespace ColorLoopActive { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7429,10 +13681,23 @@ namespace ColorLoopDirection { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7442,10 +13707,23 @@ namespace ColorLoopTime { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7455,10 +13733,23 @@ namespace ColorLoopStartEnhancedHue { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7468,10 +13759,23 @@ namespace ColorLoopStoredEnhancedHue { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7481,10 +13785,23 @@ namespace ColorCapabilities { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -7494,10 +13811,23 @@ namespace ColorTempPhysicalMin { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7507,10 +13837,23 @@ namespace ColorTempPhysicalMax { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7520,10 +13863,23 @@ namespace CoupleColorTempToLevelMinMireds { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7533,10 +13889,23 @@ namespace StartUpColorTemperatureMireds { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ColorControl::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ColorControl::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7552,10 +13921,23 @@ namespace PhysicalMinLevel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7566,10 +13948,23 @@ namespace PhysicalMaxLevel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7580,10 +13975,23 @@ namespace BallastStatus { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -7594,10 +14002,23 @@ namespace MinLevel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7608,10 +14029,23 @@ namespace MaxLevel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7622,10 +14056,23 @@ namespace PowerOnLevel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7636,10 +14083,23 @@ namespace PowerOnFadeTime { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7650,10 +14110,23 @@ namespace IntrinsicBallastFactor { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7664,10 +14137,23 @@ namespace BallastFactorAdjustment { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7678,10 +14164,23 @@ namespace LampQuality { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -7692,17 +14191,24 @@ namespace LampType { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -7716,17 +14222,24 @@ namespace LampManufacturer { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -7740,10 +14253,23 @@ namespace LampAlarmMode { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BallastConfiguration::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -7758,54 +14284,166 @@ namespace Attributes { namespace MeasuredValue { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - return emberAfReadServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (NumericAttributeTraits::IsNullValue(temp)) + { + value.SetNull(); + } + else + { + value.SetNonNull() = temp; + } + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ true, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + auto value = NumericAttributeTraits::kNullValue; + return emberAfWriteServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, reinterpret_cast(&value), + ZCL_INT16U_ATTRIBUTE_TYPE); +} + +EmberAfStatus Set(chip::EndpointId endpoint, const DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); +} + } // namespace MeasuredValue namespace MinMeasuredValue { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - return emberAfReadServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (NumericAttributeTraits::IsNullValue(temp)) + { + value.SetNull(); + } + else + { + value.SetNonNull() = temp; + } + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ true, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + auto value = NumericAttributeTraits::kNullValue; + return emberAfWriteServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, reinterpret_cast(&value), + ZCL_INT16U_ATTRIBUTE_TYPE); +} + +EmberAfStatus Set(chip::EndpointId endpoint, const DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); +} + } // namespace MinMeasuredValue namespace MaxMeasuredValue { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - return emberAfReadServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (NumericAttributeTraits::IsNullValue(temp)) + { + value.SetNull(); + } + else + { + value.SetNonNull() = temp; + } + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ true, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + auto value = NumericAttributeTraits::kNullValue; + return emberAfWriteServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, reinterpret_cast(&value), + ZCL_INT16U_ATTRIBUTE_TYPE); +} + +EmberAfStatus Set(chip::EndpointId endpoint, const DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); +} + } // namespace MaxMeasuredValue namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7814,16 +14452,49 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) namespace LightSensorType { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - return emberAfReadServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (NumericAttributeTraits::IsNullValue(temp)) + { + value.SetNull(); + } + else + { + value.SetNonNull() = temp; + } + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ true, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + auto value = NumericAttributeTraits::kNullValue; + return emberAfWriteServerAttribute(endpoint, Clusters::IlluminanceMeasurement::Id, Id, reinterpret_cast(&value), + ZCL_ENUM8_ATTRIBUTE_TYPE); +} + +EmberAfStatus Set(chip::EndpointId endpoint, const DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); +} + } // namespace LightSensorType } // namespace Attributes @@ -7836,10 +14507,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TemperatureMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TemperatureMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TemperatureMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -7850,10 +14534,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TemperatureMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TemperatureMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TemperatureMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -7864,10 +14561,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TemperatureMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TemperatureMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TemperatureMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -7878,10 +14588,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TemperatureMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TemperatureMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TemperatureMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7898,10 +14621,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -7912,10 +14648,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -7926,10 +14675,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -7940,10 +14702,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -7954,10 +14729,23 @@ namespace ScaledValue { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -7968,10 +14756,23 @@ namespace MinScaledValue { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -7982,10 +14783,23 @@ namespace MaxScaledValue { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -7996,10 +14810,23 @@ namespace ScaledTolerance { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -8010,10 +14837,23 @@ namespace Scale { EmberAfStatus Get(chip::EndpointId endpoint, int8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::PressureMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT8S_ATTRIBUTE_TYPE); } @@ -8030,10 +14870,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FlowMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::FlowMeasurement::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FlowMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -8043,10 +14896,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FlowMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::FlowMeasurement::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FlowMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -8056,10 +14922,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FlowMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::FlowMeasurement::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FlowMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -8069,10 +14948,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FlowMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::FlowMeasurement::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FlowMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -8088,10 +14980,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::RelativeHumidityMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::RelativeHumidityMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::RelativeHumidityMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -8102,10 +15007,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::RelativeHumidityMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::RelativeHumidityMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::RelativeHumidityMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -8116,10 +15034,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::RelativeHumidityMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::RelativeHumidityMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::RelativeHumidityMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -8130,10 +15061,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::RelativeHumidityMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::RelativeHumidityMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::RelativeHumidityMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -8150,10 +15094,23 @@ namespace Occupancy { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -8164,10 +15121,23 @@ namespace OccupancySensorType { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -8177,10 +15147,23 @@ namespace OccupancySensorTypeBitmap { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -8191,10 +15174,23 @@ namespace PirOccupiedToUnoccupiedDelay { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -8204,10 +15200,23 @@ namespace PirUnoccupiedToOccupiedDelay { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -8217,10 +15226,23 @@ namespace PirUnoccupiedToOccupiedThreshold { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -8230,10 +15252,23 @@ namespace UltrasonicOccupiedToUnoccupiedDelay { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -8243,10 +15278,23 @@ namespace UltrasonicUnoccupiedToOccupiedDelay { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -8256,10 +15304,23 @@ namespace UltrasonicUnoccupiedToOccupiedThreshold { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -8269,10 +15330,23 @@ namespace PhysicalContactOccupiedToUnoccupiedDelay { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -8282,10 +15356,23 @@ namespace PhysicalContactUnoccupiedToOccupiedDelay { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -8295,10 +15382,23 @@ namespace PhysicalContactUnoccupiedToOccupiedThreshold { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OccupancySensing::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -8314,11 +15414,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::CarbonMonoxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::CarbonMonoxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::CarbonMonoxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8329,11 +15441,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::CarbonMonoxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::CarbonMonoxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::CarbonMonoxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8344,11 +15468,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::CarbonMonoxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::CarbonMonoxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::CarbonMonoxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8359,11 +15495,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::CarbonMonoxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::CarbonMonoxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::CarbonMonoxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8380,11 +15528,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8395,11 +15555,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8410,11 +15582,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8425,11 +15609,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8446,11 +15642,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthyleneConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthyleneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthyleneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8461,11 +15669,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthyleneConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthyleneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthyleneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8476,11 +15696,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthyleneConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthyleneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthyleneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8491,11 +15723,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthyleneConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthyleneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthyleneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8512,11 +15756,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthyleneOxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthyleneOxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthyleneOxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8527,11 +15783,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthyleneOxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthyleneOxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthyleneOxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8542,11 +15810,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthyleneOxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthyleneOxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthyleneOxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8557,11 +15837,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::EthyleneOxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthyleneOxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::EthyleneOxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8578,11 +15870,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::HydrogenConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::HydrogenConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::HydrogenConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8593,11 +15897,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::HydrogenConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::HydrogenConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::HydrogenConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8608,11 +15924,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::HydrogenConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::HydrogenConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::HydrogenConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8623,11 +15951,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::HydrogenConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::HydrogenConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::HydrogenConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8644,11 +15984,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::HydrogenSulphideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::HydrogenSulphideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::HydrogenSulphideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8659,11 +16011,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::HydrogenSulphideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::HydrogenSulphideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::HydrogenSulphideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8674,11 +16038,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::HydrogenSulphideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::HydrogenSulphideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::HydrogenSulphideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8689,11 +16065,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::HydrogenSulphideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::HydrogenSulphideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::HydrogenSulphideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8710,11 +16098,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::NitricOxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::NitricOxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::NitricOxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8725,11 +16125,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::NitricOxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::NitricOxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::NitricOxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8740,11 +16152,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::NitricOxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::NitricOxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::NitricOxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8755,11 +16179,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::NitricOxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::NitricOxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::NitricOxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8776,11 +16212,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::NitrogenDioxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::NitrogenDioxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::NitrogenDioxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8791,11 +16239,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::NitrogenDioxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::NitrogenDioxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::NitrogenDioxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8806,11 +16266,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::NitrogenDioxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::NitrogenDioxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::NitrogenDioxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8821,11 +16293,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::NitrogenDioxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::NitrogenDioxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::NitrogenDioxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8842,11 +16326,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OxygenConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OxygenConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OxygenConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8857,11 +16353,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OxygenConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OxygenConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OxygenConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8872,11 +16380,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OxygenConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OxygenConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OxygenConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8887,11 +16407,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OxygenConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OxygenConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OxygenConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8908,10 +16440,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OzoneConcentrationMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OzoneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OzoneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8922,10 +16467,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OzoneConcentrationMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OzoneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OzoneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8936,10 +16494,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OzoneConcentrationMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OzoneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OzoneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8950,10 +16521,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::OzoneConcentrationMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OzoneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::OzoneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8970,11 +16554,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SulfurDioxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SulfurDioxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SulfurDioxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -8985,11 +16581,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SulfurDioxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SulfurDioxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SulfurDioxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9000,11 +16608,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SulfurDioxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SulfurDioxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SulfurDioxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9015,11 +16635,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SulfurDioxideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SulfurDioxideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SulfurDioxideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9036,11 +16668,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DissolvedOxygenConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DissolvedOxygenConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DissolvedOxygenConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9051,11 +16695,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DissolvedOxygenConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DissolvedOxygenConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DissolvedOxygenConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9066,11 +16722,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DissolvedOxygenConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DissolvedOxygenConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DissolvedOxygenConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9081,11 +16749,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::DissolvedOxygenConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::DissolvedOxygenConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::DissolvedOxygenConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9102,11 +16782,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BromateConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BromateConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BromateConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9117,11 +16809,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BromateConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BromateConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BromateConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9132,11 +16836,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BromateConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BromateConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BromateConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9147,11 +16863,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BromateConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BromateConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BromateConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9168,11 +16896,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChloraminesConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChloraminesConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChloraminesConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9183,11 +16923,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChloraminesConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChloraminesConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChloraminesConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9198,11 +16950,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChloraminesConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChloraminesConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChloraminesConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9213,11 +16977,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChloraminesConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChloraminesConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChloraminesConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9234,11 +17010,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChlorineConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChlorineConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChlorineConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9249,11 +17037,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChlorineConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChlorineConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChlorineConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9264,11 +17064,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChlorineConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChlorineConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChlorineConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9279,11 +17091,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChlorineConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChlorineConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChlorineConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9300,11 +17124,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FecalColiformAndEColiConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::FecalColiformAndEColiConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FecalColiformAndEColiConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9315,11 +17151,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FecalColiformAndEColiConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::FecalColiformAndEColiConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FecalColiformAndEColiConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9330,11 +17178,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FecalColiformAndEColiConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::FecalColiformAndEColiConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FecalColiformAndEColiConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9345,11 +17205,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FecalColiformAndEColiConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::FecalColiformAndEColiConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FecalColiformAndEColiConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9366,11 +17238,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FluorideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::FluorideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FluorideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9381,11 +17265,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FluorideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::FluorideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FluorideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9396,11 +17292,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FluorideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::FluorideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FluorideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9411,11 +17319,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::FluorideConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::FluorideConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::FluorideConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9432,11 +17352,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::HaloaceticAcidsConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::HaloaceticAcidsConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::HaloaceticAcidsConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9447,11 +17379,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::HaloaceticAcidsConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::HaloaceticAcidsConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::HaloaceticAcidsConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9462,11 +17406,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::HaloaceticAcidsConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::HaloaceticAcidsConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::HaloaceticAcidsConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9477,11 +17433,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::HaloaceticAcidsConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::HaloaceticAcidsConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::HaloaceticAcidsConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9498,11 +17466,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TotalTrihalomethanesConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TotalTrihalomethanesConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TotalTrihalomethanesConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9513,11 +17493,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TotalTrihalomethanesConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TotalTrihalomethanesConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TotalTrihalomethanesConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9528,11 +17520,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TotalTrihalomethanesConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TotalTrihalomethanesConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TotalTrihalomethanesConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9543,11 +17547,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TotalTrihalomethanesConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TotalTrihalomethanesConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TotalTrihalomethanesConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9564,11 +17580,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TotalColiformBacteriaConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TotalColiformBacteriaConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TotalColiformBacteriaConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9579,11 +17607,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TotalColiformBacteriaConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TotalColiformBacteriaConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TotalColiformBacteriaConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9594,11 +17634,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TotalColiformBacteriaConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TotalColiformBacteriaConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TotalColiformBacteriaConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9609,11 +17661,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TotalColiformBacteriaConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TotalColiformBacteriaConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TotalColiformBacteriaConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9630,11 +17694,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TurbidityConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TurbidityConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TurbidityConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9645,11 +17721,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TurbidityConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TurbidityConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TurbidityConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9660,11 +17748,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TurbidityConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TurbidityConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TurbidityConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9675,11 +17775,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TurbidityConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TurbidityConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TurbidityConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9696,11 +17808,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::CopperConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::CopperConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::CopperConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9711,11 +17835,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::CopperConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::CopperConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::CopperConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9726,11 +17862,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::CopperConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::CopperConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::CopperConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9741,11 +17889,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::CopperConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::CopperConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::CopperConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9762,10 +17922,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LeadConcentrationMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::LeadConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LeadConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9776,10 +17949,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LeadConcentrationMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::LeadConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LeadConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9790,10 +17976,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LeadConcentrationMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::LeadConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LeadConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9804,10 +18003,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::LeadConcentrationMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::LeadConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::LeadConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9824,11 +18036,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ManganeseConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ManganeseConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ManganeseConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9839,11 +18063,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ManganeseConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ManganeseConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ManganeseConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9854,11 +18090,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ManganeseConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ManganeseConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ManganeseConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9869,11 +18117,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ManganeseConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ManganeseConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ManganeseConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9890,11 +18150,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SulfateConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SulfateConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SulfateConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9905,11 +18177,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SulfateConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SulfateConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SulfateConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9920,11 +18204,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SulfateConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SulfateConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SulfateConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9935,11 +18231,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SulfateConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SulfateConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SulfateConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9956,11 +18264,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BromodichloromethaneConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BromodichloromethaneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BromodichloromethaneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9971,11 +18291,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BromodichloromethaneConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BromodichloromethaneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BromodichloromethaneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -9986,11 +18318,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BromodichloromethaneConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BromodichloromethaneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BromodichloromethaneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10001,11 +18345,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BromodichloromethaneConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BromodichloromethaneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BromodichloromethaneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10022,11 +18378,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BromoformConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BromoformConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BromoformConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10037,11 +18405,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BromoformConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BromoformConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BromoformConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10052,11 +18432,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BromoformConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BromoformConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BromoformConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10067,11 +18459,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::BromoformConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::BromoformConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::BromoformConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10088,11 +18492,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChlorodibromomethaneConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChlorodibromomethaneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChlorodibromomethaneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10103,11 +18519,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChlorodibromomethaneConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChlorodibromomethaneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChlorodibromomethaneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10118,11 +18546,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChlorodibromomethaneConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChlorodibromomethaneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChlorodibromomethaneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10133,11 +18573,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChlorodibromomethaneConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChlorodibromomethaneConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChlorodibromomethaneConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10154,11 +18606,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChloroformConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChloroformConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChloroformConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10169,11 +18633,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChloroformConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChloroformConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChloroformConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10184,11 +18660,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChloroformConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChloroformConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChloroformConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10199,11 +18687,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ChloroformConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ChloroformConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ChloroformConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10220,11 +18720,23 @@ namespace MeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SodiumConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SodiumConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SodiumConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10235,11 +18747,23 @@ namespace MinMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SodiumConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SodiumConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SodiumConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10250,11 +18774,23 @@ namespace MaxMeasuredValue { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SodiumConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SodiumConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SodiumConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10265,11 +18801,23 @@ namespace Tolerance { EmberAfStatus Get(chip::EndpointId endpoint, float * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SodiumConcentrationMeasurement::Id, Id, (uint8_t *) value, - sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SodiumConcentrationMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, float value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SodiumConcentrationMeasurement::Id, Id, (uint8_t *) &value, ZCL_SINGLE_ATTRIBUTE_TYPE); } @@ -10286,10 +18834,23 @@ namespace ZoneState { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -10299,10 +18860,23 @@ namespace ZoneType { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) &value, ZCL_ENUM16_ATTRIBUTE_TYPE); } @@ -10312,10 +18886,23 @@ namespace ZoneStatus { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -10325,10 +18912,23 @@ namespace IasCieAddress { EmberAfStatus Get(chip::EndpointId endpoint, chip::NodeId * value) { - return emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::NodeId value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) &value, ZCL_NODE_ID_ATTRIBUTE_TYPE); } @@ -10338,10 +18938,23 @@ namespace ZoneId { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -10351,10 +18964,23 @@ namespace NumberOfZoneSensitivityLevelsSupported { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -10364,10 +18990,23 @@ namespace CurrentZoneSensitivityLevel { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::IasZone::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::IasZone::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -10383,10 +19022,23 @@ namespace MaxDuration { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::IasWd::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::IasWd::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::IasWd::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -10402,16 +19054,23 @@ namespace WakeOnLanMacAddress { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::WakeOnLan::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -10431,16 +19090,23 @@ namespace TvChannelLineup { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TvChannel::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -10454,16 +19120,23 @@ namespace CurrentTvChannel { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TvChannel::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -10483,10 +19156,23 @@ namespace CurrentNavigatorTarget { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TargetNavigator::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TargetNavigator::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TargetNavigator::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -10502,10 +19188,23 @@ namespace PlaybackState { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -10515,10 +19214,23 @@ namespace StartTime { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -10528,10 +19240,23 @@ namespace Duration { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -10541,10 +19266,23 @@ namespace PositionUpdatedAt { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -10554,10 +19292,23 @@ namespace Position { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -10567,10 +19318,23 @@ namespace PlaybackSpeed { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -10580,10 +19344,23 @@ namespace SeekRangeEnd { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -10593,10 +19370,23 @@ namespace SeekRangeStart { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::MediaPlayback::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -10612,10 +19402,23 @@ namespace CurrentMediaInput { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::MediaInput::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::MediaInput::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::MediaInput::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -10637,10 +19440,23 @@ namespace CurrentAudioOutput { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::AudioOutput::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::AudioOutput::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::AudioOutput::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -10656,10 +19472,23 @@ namespace CatalogVendorId { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplicationLauncher::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplicationLauncher::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplicationLauncher::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -10670,10 +19499,23 @@ namespace ApplicationId { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplicationLauncher::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplicationLauncher::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplicationLauncher::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -10690,16 +19532,23 @@ namespace VendorName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplicationBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -10713,10 +19562,23 @@ namespace VendorId { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -10726,16 +19588,23 @@ namespace ApplicationName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplicationBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -10749,10 +19618,23 @@ namespace ProductId { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -10762,16 +19644,23 @@ namespace ApplicationId { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplicationBasic::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 32); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(32 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[32 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -10785,10 +19674,23 @@ namespace CatalogVendorId { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -10798,10 +19700,23 @@ namespace ApplicationStatus { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -10817,10 +19732,23 @@ namespace Boolean { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -10830,10 +19758,23 @@ namespace Bitmap8 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -10843,10 +19784,23 @@ namespace Bitmap16 { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -10856,10 +19810,23 @@ namespace Bitmap32 { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_BITMAP32_ATTRIBUTE_TYPE); } @@ -10869,10 +19836,23 @@ namespace Bitmap64 { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_BITMAP64_ATTRIBUTE_TYPE); } @@ -10882,10 +19862,23 @@ namespace Int8u { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -10895,10 +19888,23 @@ namespace Int16u { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -10908,10 +19914,23 @@ namespace Int32u { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -10921,10 +19940,23 @@ namespace Int64u { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_INT64U_ATTRIBUTE_TYPE); } @@ -10934,10 +19966,23 @@ namespace Int8s { EmberAfStatus Get(chip::EndpointId endpoint, int8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_INT8S_ATTRIBUTE_TYPE); } @@ -10947,10 +19992,23 @@ namespace Int16s { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -10960,10 +20018,23 @@ namespace Int32s { EmberAfStatus Get(chip::EndpointId endpoint, int32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_INT32S_ATTRIBUTE_TYPE); } @@ -10973,10 +20044,23 @@ namespace Int64s { EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_INT64S_ATTRIBUTE_TYPE); } @@ -10986,10 +20070,23 @@ namespace Enum8 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_ENUM8_ATTRIBUTE_TYPE); } @@ -10999,10 +20096,23 @@ namespace Enum16 { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_ENUM16_ATTRIBUTE_TYPE); } @@ -11012,16 +20122,23 @@ namespace OctetString { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 10, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[10 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TestCluster::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 10, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 10); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(10 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 10, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[10 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11035,16 +20152,23 @@ namespace LongOctetString { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 1000, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[1000 + 2]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, zclString, sizeof(zclString)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfLongStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 1000, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[2], 1000); - value.reduce_size(emberAfLongStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(1000 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 1000, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[1000 + 2]; emberAfCopyInt16u(zclString, 0, static_cast(value.size())); @@ -11058,16 +20182,23 @@ namespace CharString { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 10, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[10 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TestCluster::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 10, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 10); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(10 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 10, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[10 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11081,16 +20212,23 @@ namespace LongCharString { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 1000, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[1000 + 2]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, zclString, sizeof(zclString)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfLongStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 1000, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[2], 1000); - value.reduce_size(emberAfLongStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(1000 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 1000, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[1000 + 2]; emberAfCopyInt16u(zclString, 0, static_cast(value.size())); @@ -11104,10 +20242,23 @@ namespace EpochUs { EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_EPOCH_US_ATTRIBUTE_TYPE); } @@ -11117,10 +20268,23 @@ namespace EpochS { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_EPOCH_S_ATTRIBUTE_TYPE); } @@ -11130,10 +20294,23 @@ namespace VendorId { EmberAfStatus Get(chip::EndpointId endpoint, chip::VendorId * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::VendorId value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_VENDOR_ID_ATTRIBUTE_TYPE); } @@ -11143,10 +20320,23 @@ namespace Unsupported { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - return emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::TestCluster::Id, Id, reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::TestCluster::Id, Id, (uint8_t *) &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } @@ -11162,17 +20352,24 @@ namespace CompanyName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11187,10 +20384,23 @@ namespace CompanyId { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplianceIdentification::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11201,17 +20411,24 @@ namespace BrandName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11226,10 +20443,23 @@ namespace BrandId { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplianceIdentification::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11240,17 +20470,24 @@ namespace Model { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11265,17 +20502,24 @@ namespace PartNumber { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11290,17 +20534,24 @@ namespace ProductRevision { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[6 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 6); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(6 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[6 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11315,17 +20566,24 @@ namespace SoftwareRevision { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[6 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 6); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(6 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[6 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11340,17 +20598,24 @@ namespace ProductTypeName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 2, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[2 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 2, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 2); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(2 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 2, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[2 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11365,10 +20630,23 @@ namespace ProductTypeId { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplianceIdentification::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11379,10 +20657,23 @@ namespace CecedSpecificationVersion { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplianceIdentification::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplianceIdentification::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -11399,17 +20690,24 @@ namespace CompanyName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::MeterIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11423,10 +20721,23 @@ namespace MeterTypeId { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::MeterIdentification::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::MeterIdentification::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::MeterIdentification::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11437,10 +20748,23 @@ namespace DataQualityId { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::MeterIdentification::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::MeterIdentification::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::MeterIdentification::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11451,17 +20775,24 @@ namespace CustomerName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::MeterIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11475,17 +20806,24 @@ namespace Model { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::MeterIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11499,17 +20837,24 @@ namespace PartNumber { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::MeterIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11523,17 +20868,24 @@ namespace ProductRevision { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[6 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::MeterIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 6); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(6 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[6 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11547,17 +20899,24 @@ namespace SoftwareRevision { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) { - VerifyOrReturnError(value.size() == 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[6 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::MeterIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 6); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) { + static_assert(6 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 6, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[6 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11571,17 +20930,24 @@ namespace UtilityName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::MeterIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11595,17 +20961,24 @@ namespace Pod { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::MeterIdentification::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_INVALID_VALUE; + } + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); memcpy(value.data(), &zclString[1], 16); - value.reduce_size(emberAfStringLength(zclString)); + value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { + static_assert(16 != NumericAttributeTraits::kNullValue, "value.size() might be too big"); VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_INVALID_ARGUMENT); uint8_t zclString[16 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); @@ -11625,10 +20998,23 @@ namespace LogMaxSize { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplianceStatistics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplianceStatistics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplianceStatistics::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -11639,10 +21025,23 @@ namespace LogQueueMaxSize { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ApplianceStatistics::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ApplianceStatistics::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ApplianceStatistics::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -11659,10 +21058,23 @@ namespace MeasurementType { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_BITMAP32_ATTRIBUTE_TYPE); } @@ -11673,10 +21085,23 @@ namespace DcVoltage { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -11687,10 +21112,23 @@ namespace DcVoltageMin { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -11701,10 +21139,23 @@ namespace DcVoltageMax { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -11715,10 +21166,23 @@ namespace DcCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -11729,10 +21193,23 @@ namespace DcCurrentMin { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -11743,10 +21220,23 @@ namespace DcCurrentMax { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -11757,10 +21247,23 @@ namespace DcPower { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -11771,10 +21274,23 @@ namespace DcPowerMin { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -11785,10 +21301,23 @@ namespace DcPowerMax { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -11799,10 +21328,23 @@ namespace DcVoltageMultiplier { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11813,10 +21355,23 @@ namespace DcVoltageDivisor { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11827,10 +21382,23 @@ namespace DcCurrentMultiplier { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11841,10 +21409,23 @@ namespace DcCurrentDivisor { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11855,10 +21436,23 @@ namespace DcPowerMultiplier { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11869,10 +21463,23 @@ namespace DcPowerDivisor { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11883,10 +21490,23 @@ namespace AcFrequency { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11897,10 +21517,23 @@ namespace AcFrequencyMin { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11911,10 +21544,23 @@ namespace AcFrequencyMax { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11925,10 +21571,23 @@ namespace NeutralCurrent { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -11939,10 +21598,23 @@ namespace TotalActivePower { EmberAfStatus Get(chip::EndpointId endpoint, int32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT32S_ATTRIBUTE_TYPE); } @@ -11953,10 +21625,23 @@ namespace TotalReactivePower { EmberAfStatus Get(chip::EndpointId endpoint, int32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT32S_ATTRIBUTE_TYPE); } @@ -11967,10 +21652,23 @@ namespace TotalApparentPower { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -11981,10 +21679,23 @@ namespace Measured1stHarmonicCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -11995,10 +21706,23 @@ namespace Measured3rdHarmonicCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12009,10 +21733,23 @@ namespace Measured5thHarmonicCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12023,10 +21760,23 @@ namespace Measured7thHarmonicCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12037,10 +21787,23 @@ namespace Measured9thHarmonicCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12051,10 +21814,23 @@ namespace Measured11thHarmonicCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12065,10 +21841,23 @@ namespace MeasuredPhase1stHarmonicCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12079,10 +21868,23 @@ namespace MeasuredPhase3rdHarmonicCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12093,10 +21895,23 @@ namespace MeasuredPhase5thHarmonicCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12107,10 +21922,23 @@ namespace MeasuredPhase7thHarmonicCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12121,10 +21949,23 @@ namespace MeasuredPhase9thHarmonicCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12135,10 +21976,23 @@ namespace MeasuredPhase11thHarmonicCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12149,10 +22003,23 @@ namespace AcFrequencyMultiplier { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12163,10 +22030,23 @@ namespace AcFrequencyDivisor { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12177,10 +22057,23 @@ namespace PowerMultiplier { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -12191,10 +22084,23 @@ namespace PowerDivisor { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT32U_ATTRIBUTE_TYPE); } @@ -12205,10 +22111,23 @@ namespace HarmonicCurrentMultiplier { EmberAfStatus Get(chip::EndpointId endpoint, int8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT8S_ATTRIBUTE_TYPE); } @@ -12219,10 +22138,23 @@ namespace PhaseHarmonicCurrentMultiplier { EmberAfStatus Get(chip::EndpointId endpoint, int8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT8S_ATTRIBUTE_TYPE); } @@ -12233,10 +22165,23 @@ namespace InstantaneousVoltage { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12247,10 +22192,23 @@ namespace InstantaneousLineCurrent { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12261,10 +22219,23 @@ namespace InstantaneousActiveCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12275,10 +22246,23 @@ namespace InstantaneousReactiveCurrent { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12289,10 +22273,23 @@ namespace InstantaneousPower { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12303,10 +22300,23 @@ namespace RmsVoltage { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12317,10 +22327,23 @@ namespace RmsVoltageMin { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12331,10 +22354,23 @@ namespace RmsVoltageMax { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12345,10 +22381,23 @@ namespace RmsCurrent { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12359,10 +22408,23 @@ namespace RmsCurrentMin { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12373,10 +22435,23 @@ namespace RmsCurrentMax { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12387,10 +22462,23 @@ namespace ActivePower { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12401,10 +22489,23 @@ namespace ActivePowerMin { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12415,10 +22516,23 @@ namespace ActivePowerMax { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12429,10 +22543,23 @@ namespace ReactivePower { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12443,10 +22570,23 @@ namespace ApparentPower { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12457,10 +22597,23 @@ namespace PowerFactor { EmberAfStatus Get(chip::EndpointId endpoint, int8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT8S_ATTRIBUTE_TYPE); } @@ -12471,10 +22624,23 @@ namespace AverageRmsVoltageMeasurementPeriod { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12485,10 +22651,23 @@ namespace AverageRmsUnderVoltageCounter { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12499,10 +22678,23 @@ namespace RmsExtremeOverVoltagePeriod { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12513,10 +22705,23 @@ namespace RmsExtremeUnderVoltagePeriod { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12527,10 +22732,23 @@ namespace RmsVoltageSagPeriod { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12541,10 +22759,23 @@ namespace RmsVoltageSwellPeriod { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12555,10 +22786,23 @@ namespace AcVoltageMultiplier { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12569,10 +22813,23 @@ namespace AcVoltageDivisor { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12583,10 +22840,23 @@ namespace AcCurrentMultiplier { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12597,10 +22867,23 @@ namespace AcCurrentDivisor { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12611,10 +22894,23 @@ namespace AcPowerMultiplier { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12625,10 +22921,23 @@ namespace AcPowerDivisor { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12639,10 +22948,23 @@ namespace OverloadAlarmsMask { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_BITMAP8_ATTRIBUTE_TYPE); } @@ -12653,10 +22975,23 @@ namespace VoltageOverload { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12667,10 +23002,23 @@ namespace CurrentOverload { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12681,10 +23029,23 @@ namespace AcOverloadAlarmsMask { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_BITMAP16_ATTRIBUTE_TYPE); } @@ -12695,10 +23056,23 @@ namespace AcVoltageOverload { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12709,10 +23083,23 @@ namespace AcCurrentOverload { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12723,10 +23110,23 @@ namespace AcActivePowerOverload { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12737,10 +23137,23 @@ namespace AcReactivePowerOverload { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12751,10 +23164,23 @@ namespace AverageRmsOverVoltage { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12765,10 +23191,23 @@ namespace AverageRmsUnderVoltage { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12779,10 +23218,23 @@ namespace RmsExtremeOverVoltage { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12793,10 +23245,23 @@ namespace RmsExtremeUnderVoltage { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12807,10 +23272,23 @@ namespace RmsVoltageSag { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12821,10 +23299,23 @@ namespace RmsVoltageSwell { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12835,10 +23326,23 @@ namespace LineCurrentPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12849,10 +23353,23 @@ namespace ActiveCurrentPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12863,10 +23380,23 @@ namespace ReactiveCurrentPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12877,10 +23407,23 @@ namespace RmsVoltagePhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12891,10 +23434,23 @@ namespace RmsVoltageMinPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12905,10 +23461,23 @@ namespace RmsVoltageMaxPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12919,10 +23488,23 @@ namespace RmsCurrentPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12933,10 +23515,23 @@ namespace RmsCurrentMinPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12947,10 +23542,23 @@ namespace RmsCurrentMaxPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12961,10 +23569,23 @@ namespace ActivePowerPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12975,10 +23596,23 @@ namespace ActivePowerMinPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -12989,10 +23623,23 @@ namespace ActivePowerMaxPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -13003,10 +23650,23 @@ namespace ReactivePowerPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -13017,10 +23677,23 @@ namespace ApparentPowerPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13031,10 +23704,23 @@ namespace PowerFactorPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, int8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT8S_ATTRIBUTE_TYPE); } @@ -13045,10 +23731,23 @@ namespace AverageRmsVoltageMeasurementPeriodPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13059,10 +23758,23 @@ namespace AverageRmsOverVoltageCounterPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13073,10 +23785,23 @@ namespace AverageRmsUnderVoltageCounterPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13087,10 +23812,23 @@ namespace RmsExtremeOverVoltagePeriodPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13101,10 +23839,23 @@ namespace RmsExtremeUnderVoltagePeriodPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13115,10 +23866,23 @@ namespace RmsVoltageSagPeriodPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13129,10 +23893,23 @@ namespace RmsVoltageSwellPeriodPhaseB { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13143,10 +23920,23 @@ namespace LineCurrentPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13157,10 +23947,23 @@ namespace ActiveCurrentPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -13171,10 +23974,23 @@ namespace ReactiveCurrentPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -13185,10 +24001,23 @@ namespace RmsVoltagePhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13199,10 +24028,23 @@ namespace RmsVoltageMinPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13213,10 +24055,23 @@ namespace RmsVoltageMaxPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13227,10 +24082,23 @@ namespace RmsCurrentPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13241,10 +24109,23 @@ namespace RmsCurrentMinPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13255,10 +24136,23 @@ namespace RmsCurrentMaxPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13269,10 +24163,23 @@ namespace ActivePowerPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -13283,10 +24190,23 @@ namespace ActivePowerMinPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -13297,10 +24217,23 @@ namespace ActivePowerMaxPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -13311,10 +24244,23 @@ namespace ReactivePowerPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, int16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); } @@ -13325,10 +24271,23 @@ namespace ApparentPowerPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13339,10 +24298,23 @@ namespace PowerFactorPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, int8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, int8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT8S_ATTRIBUTE_TYPE); } @@ -13353,10 +24325,23 @@ namespace AverageRmsVoltageMeasurementPeriodPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13367,10 +24352,23 @@ namespace AverageRmsOverVoltageCounterPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13381,10 +24379,23 @@ namespace AverageRmsUnderVoltageCounterPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13395,10 +24406,23 @@ namespace RmsExtremeOverVoltagePeriodPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13409,10 +24433,23 @@ namespace RmsExtremeUnderVoltagePeriodPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13423,10 +24460,23 @@ namespace RmsVoltageSagPeriodPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13437,10 +24487,23 @@ namespace RmsVoltageSwellPeriodPhaseC { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::ElectricalMeasurement::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13463,10 +24526,23 @@ namespace EmberSampleAttribute { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -13477,10 +24553,23 @@ namespace EmberSampleAttribute2 { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster::Id, Id, (uint8_t *) &value, ZCL_INT8U_ATTRIBUTE_TYPE); } @@ -13497,10 +24586,23 @@ namespace EmberSampleAttribute3 { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster2::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster2::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster2::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -13511,10 +24613,23 @@ namespace EmberSampleAttribute4 { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - return emberAfReadServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster2::Id, Id, (uint8_t *) value, sizeof(*value)); + NumericAttributeTraits::StorageType temp; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster2::Id, Id, + reinterpret_cast(&temp), sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + *value = temp; + return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_INVALID_ARGUMENT; + } return emberAfWriteServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster2::Id, Id, (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); } 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 0130eb536d5adb..5009cddb196421 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 @@ -24,6 +24,7 @@ #pragma once +#include #include #include @@ -2902,18 +2903,24 @@ namespace IlluminanceMeasurement { namespace Attributes { namespace MeasuredValue { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int16u EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); +EmberAfStatus SetNull(chip::EndpointId endpoint); +EmberAfStatus Set(chip::EndpointId endpoint, const DataModel::Nullable & value); } // namespace MeasuredValue namespace MinMeasuredValue { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int16u EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); +EmberAfStatus SetNull(chip::EndpointId endpoint); +EmberAfStatus Set(chip::EndpointId endpoint, const DataModel::Nullable & value); } // namespace MinMeasuredValue namespace MaxMeasuredValue { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int16u EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); +EmberAfStatus SetNull(chip::EndpointId endpoint); +EmberAfStatus Set(chip::EndpointId endpoint, const DataModel::Nullable & value); } // namespace MaxMeasuredValue namespace Tolerance { @@ -2922,8 +2929,10 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); } // namespace Tolerance namespace LightSensorType { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // enum8 +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // enum8 EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); +EmberAfStatus SetNull(chip::EndpointId endpoint); +EmberAfStatus Set(chip::EndpointId endpoint, const DataModel::Nullable & value); } // namespace LightSensorType } // namespace Attributes