blob: b79fa746c2bea37cbc3e1af79ccebaa9ca7476c0 [file] [log] [blame]
{{> header excludeZapComment=true}}
#import "MTRAttributeTLVValueDecoder_Internal.h"
#import "MTRStructsObjc.h"
#include <app/data-model/Decode.h>
#include <app/data-model/DecodableList.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <lib/support/TypeTraits.h>
using namespace chip;
using namespace chip::app;
id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader & aReader, CHIP_ERROR * aError)
{
switch (aPath.mClusterId)
{
{{#chip_client_clusters includeAll=true}}
case Clusters::{{asUpperCamelCase name}}::Id: {
using namespace Clusters::{{asUpperCamelCase name}};
switch (aPath.mAttributeId)
{
{{#chip_server_cluster_attributes}}
case Attributes::{{asUpperCamelCase name}}::Id: {
using TypeInfo = Attributes::{{asUpperCamelCase name}}::TypeInfo;
TypeInfo::DecodableType cppValue;
*aError = DataModel::Decode(aReader, cppValue);
if (*aError != CHIP_NO_ERROR)
{
return nil;
}
{{asObjectiveCType type parent.name}} value;
{{>decode_value target="value" source="cppValue" cluster=parent.name errorCode="*aError = err; return nil;" depth=0}}
return value;
}
{{/chip_server_cluster_attributes}}
default:
*aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
break;
}
break;
}
{{/chip_client_clusters}}
default: {
*aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
break;
}
}
return nil;
}