Skip to content

Commit

Permalink
Stop hardcoding the list of signed integer attribute types. (#35412)
Browse files Browse the repository at this point in the history
ZAP has this information.  We should just use that instead of duplicating it.

Fixes #35147
  • Loading branch information
bzbarsky-apple authored Sep 4, 2024
1 parent e2edc0c commit e18f910
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/app/util/attribute-metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@ struct EmberAfAttributeMetadata
/**
* Check wether this attribute is signed based on its type according to the spec.
*/
bool IsSignedIntegerAttribute() const
{
return (attributeType >= ZCL_INT8S_ATTRIBUTE_TYPE && attributeType <= ZCL_INT64S_ATTRIBUTE_TYPE) ||
attributeType == ZCL_TEMPERATURE_ATTRIBUTE_TYPE;
}
bool IsSignedIntegerAttribute() const { return chip::app::IsSignedAttributeType(attributeType); }

/**
* Check whether this attribute has a define min and max.
Expand Down
20 changes: 20 additions & 0 deletions src/app/zap-templates/templates/app/attribute-type.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,29 @@
// Prevent multiple inclusion
#pragma once

#include <cstdint>

// ZCL attribute types
enum {
{{#zcl_atomics}}
{{ident}}ZCL_{{asDelimitedMacro name}}_ATTRIBUTE_TYPE = {{asHex atomicId 2}}, // {{description}}
{{/zcl_atomics}}
};

namespace chip {
namespace app {
inline bool IsSignedAttributeType(uint8_t attributeType)
{
switch (attributeType) {
{{#zcl_atomics}}
{{#if isSigned}}
case ZCL_{{asDelimitedMacro name}}_ATTRIBUTE_TYPE:
return true;
{{/if}}
{{/zcl_atomics}}
default:
return false;
}
}
} // namespace app
} // namespace chip
41 changes: 41 additions & 0 deletions zzz_generated/app-common/app-common/zap-generated/attribute-type.h

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

0 comments on commit e18f910

Please sign in to comment.