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 c2dfed70cfee7e..ca8b77d70de4c3 100644 --- a/src/app/zap-templates/templates/app/attributes/Accessors-src.zapt +++ b/src/app/zap-templates/templates/app/attributes/Accessors-src.zapt @@ -14,6 +14,7 @@ #include #include #include +#include namespace chip { namespace app { @@ -38,6 +39,13 @@ namespace {{asUpperCamelCase label}} { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, {{accessorGetterType this}} value) { {{~#if (isString type)}} + {{#if isNullable}} + if (value.IsNull()) { + ChipLogError(Zcl, "Null Nullable passed to {{asUpperCamelCase parent.label}}::{{asUpperCamelCase label}}::Get"); + return Protocols::InteractionModel::Status::Failure; + } + + {{/if}} {{~#*inline "lengthType"}}uint{{#if (isShortString type)}}8{{else}}16{{/if}}_t{{/inline}} uint8_t zclString[{{maxLength}} + {{>sizingBytes}}]; Protocols::InteractionModel::Status status = emberAfReadAttribute(endpoint, {{>clusterId}}, Id, zclString, sizeof(zclString)); @@ -53,7 +61,7 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, {{accessorGet {{/if}} } {{#if isNullable}} - auto & span = value.SetNonNull(); + auto & span = value.Value(); {{/if}} {{~#*inline "value"}}{{#if isNullable}}span{{else}}value{{/if}}{{/inline}} VerifyOrReturnError({{>value}}.size() == {{maxLength}}, Protocols::InteractionModel::Status::InvalidDataType); 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 539b26eefb5e5a..ba32e7c0f9fd01 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 @@ -31,6 +31,7 @@ #include #include #include +#include namespace chip { namespace app { @@ -4216,6 +4217,12 @@ namespace LastNetworkID { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nullable & value) { + if (value.IsNull()) + { + ChipLogError(Zcl, "Null Nullable passed to NetworkCommissioning::LastNetworkID::Get"); + return Protocols::InteractionModel::Status::Failure; + } + uint8_t zclString[32 + 1]; Protocols::InteractionModel::Status status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, zclString, sizeof(zclString)); @@ -4226,7 +4233,7 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nu value.SetNull(); return Protocols::InteractionModel::Status::Success; } - auto & span = value.SetNonNull(); + auto & span = value.Value(); VerifyOrReturnError(span.size() == 32, Protocols::InteractionModel::Status::InvalidDataType); memcpy(span.data(), &zclString[1], 32); @@ -12233,6 +12240,12 @@ namespace AliroReaderVerificationKey { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nullable & value) { + if (value.IsNull()) + { + ChipLogError(Zcl, "Null Nullable passed to DoorLock::AliroReaderVerificationKey::Get"); + return Protocols::InteractionModel::Status::Failure; + } + uint8_t zclString[65 + 1]; Protocols::InteractionModel::Status status = emberAfReadAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, sizeof(zclString)); @@ -12243,7 +12256,7 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nu value.SetNull(); return Protocols::InteractionModel::Status::Success; } - auto & span = value.SetNonNull(); + auto & span = value.Value(); VerifyOrReturnError(span.size() == 65, Protocols::InteractionModel::Status::InvalidDataType); memcpy(span.data(), &zclString[1], 65); @@ -12283,6 +12296,12 @@ namespace AliroReaderGroupIdentifier { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nullable & value) { + if (value.IsNull()) + { + ChipLogError(Zcl, "Null Nullable passed to DoorLock::AliroReaderGroupIdentifier::Get"); + return Protocols::InteractionModel::Status::Failure; + } + uint8_t zclString[16 + 1]; Protocols::InteractionModel::Status status = emberAfReadAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, sizeof(zclString)); @@ -12293,7 +12312,7 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nu value.SetNull(); return Protocols::InteractionModel::Status::Success; } - auto & span = value.SetNonNull(); + auto & span = value.Value(); VerifyOrReturnError(span.size() == 16, Protocols::InteractionModel::Status::InvalidDataType); memcpy(span.data(), &zclString[1], 16); @@ -12365,6 +12384,12 @@ namespace AliroGroupResolvingKey { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nullable & value) { + if (value.IsNull()) + { + ChipLogError(Zcl, "Null Nullable passed to DoorLock::AliroGroupResolvingKey::Get"); + return Protocols::InteractionModel::Status::Failure; + } + uint8_t zclString[16 + 1]; Protocols::InteractionModel::Status status = emberAfReadAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, sizeof(zclString)); @@ -12375,7 +12400,7 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nu value.SetNull(); return Protocols::InteractionModel::Status::Success; } - auto & span = value.SetNonNull(); + auto & span = value.Value(); VerifyOrReturnError(span.size() == 16, Protocols::InteractionModel::Status::InvalidDataType); memcpy(span.data(), &zclString[1], 16); @@ -17112,6 +17137,12 @@ namespace ActivePresetHandle { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nullable & value) { + if (value.IsNull()) + { + ChipLogError(Zcl, "Null Nullable passed to Thermostat::ActivePresetHandle::Get"); + return Protocols::InteractionModel::Status::Failure; + } + uint8_t zclString[16 + 1]; Protocols::InteractionModel::Status status = emberAfReadAttribute(endpoint, Clusters::Thermostat::Id, Id, zclString, sizeof(zclString)); @@ -17122,7 +17153,7 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nu value.SetNull(); return Protocols::InteractionModel::Status::Success; } - auto & span = value.SetNonNull(); + auto & span = value.Value(); VerifyOrReturnError(span.size() == 16, Protocols::InteractionModel::Status::InvalidDataType); memcpy(span.data(), &zclString[1], 16); @@ -17162,6 +17193,12 @@ namespace ActiveScheduleHandle { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nullable & value) { + if (value.IsNull()) + { + ChipLogError(Zcl, "Null Nullable passed to Thermostat::ActiveScheduleHandle::Get"); + return Protocols::InteractionModel::Status::Failure; + } + uint8_t zclString[16 + 1]; Protocols::InteractionModel::Status status = emberAfReadAttribute(endpoint, Clusters::Thermostat::Id, Id, zclString, sizeof(zclString)); @@ -17172,7 +17209,7 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nu value.SetNull(); return Protocols::InteractionModel::Status::Success; } - auto & span = value.SetNonNull(); + auto & span = value.Value(); VerifyOrReturnError(span.size() == 16, Protocols::InteractionModel::Status::InvalidDataType); memcpy(span.data(), &zclString[1], 16); @@ -31764,6 +31801,12 @@ namespace NullableOctetString { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nullable & value) { + if (value.IsNull()) + { + ChipLogError(Zcl, "Null Nullable passed to UnitTesting::NullableOctetString::Get"); + return Protocols::InteractionModel::Status::Failure; + } + uint8_t zclString[10 + 1]; Protocols::InteractionModel::Status status = emberAfReadAttribute(endpoint, Clusters::UnitTesting::Id, Id, zclString, sizeof(zclString)); @@ -31774,7 +31817,7 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nu value.SetNull(); return Protocols::InteractionModel::Status::Success; } - auto & span = value.SetNonNull(); + auto & span = value.Value(); VerifyOrReturnError(span.size() == 10, Protocols::InteractionModel::Status::InvalidDataType); memcpy(span.data(), &zclString[1], 10); @@ -31814,6 +31857,12 @@ namespace NullableCharString { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nullable & value) { + if (value.IsNull()) + { + ChipLogError(Zcl, "Null Nullable passed to UnitTesting::NullableCharString::Get"); + return Protocols::InteractionModel::Status::Failure; + } + uint8_t zclString[10 + 1]; Protocols::InteractionModel::Status status = emberAfReadAttribute(endpoint, Clusters::UnitTesting::Id, Id, zclString, sizeof(zclString)); @@ -31824,7 +31873,7 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nu value.SetNull(); return Protocols::InteractionModel::Status::Success; } - auto & span = value.SetNonNull(); + auto & span = value.Value(); VerifyOrReturnError(span.size() == 10, Protocols::InteractionModel::Status::InvalidDataType); memcpy(span.data(), &zclString[1], 10);