Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Type information for Attributes.

Create a 'TypeInfo' struct for each attribute in the generated cluster
objects that contains both the type of the attribute as well as its
Attribute and Cluster ID. This will be useful later when implementing
Reads/Writes that utilize this information during template
specialization to avoid the caller/application having to provide this
information.
  • Loading branch information
mrjerryjohns committed Oct 11, 2021
1 parent 58177cd commit ab48324
Show file tree
Hide file tree
Showing 7 changed files with 14,650 additions and 4,921 deletions.
2 changes: 1 addition & 1 deletion scripts/tools/zap_regen_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def getSpecificTemplatesTargets():

def getTargets():
targets = []
targets.extend(getGlobalTemplatesTargets())
#targets.extend(getGlobalTemplatesTargets())
targets.extend(getSpecificTemplatesTargets())
return targets

Expand Down
38 changes: 38 additions & 0 deletions src/app/zap-templates/templates/app/cluster-objects.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <app-common/zap-generated/enums.h>
#include <app-common/zap-generated/ids/Commands.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app-common/zap-generated/ids/Attributes.h>

namespace chip {
namespace app {
Expand Down Expand Up @@ -130,6 +131,43 @@ public:
} // namespace Commands
{{/last}}
{{/zcl_commands}}

{{#zcl_attributes_server}}
{{#if (hasSpecificAttributes)}}
{{#first}}
namespace Attributes {
{{/first}}
{{#if clusterRef}}
namespace {{asUpperCamelCase label}} {
{{#if arrayType}}
struct TypeInfo {
using Type = DataModel::List<{{#if_is_enum type}}{{arrayType}}{{else}}{{zapTypeToEncodableClusterObjectType arrayType}}{{/if_is_enum}}>;
static constexpr ClusterId GetClusterId() { return {{asUpperCamelCase parent.name}}::Id; }
static constexpr AttributeId GetAttributeId() { return Attributes::{{asUpperCamelCase label}}::Id; }
};

struct DecodableTypeInfo {
using Type = DataModel::DecodableList<{{#if_is_enum type}}{{arrayType}}{{else}}{{zapTypeToDecodableClusterObjectType arrayType}}{{/if_is_enum}}>;
static constexpr ClusterId GetClusterId() { return {{asUpperCamelCase parent.name}}::Id; }
static constexpr AttributeId GetAttributeId() { return Attributes::{{asUpperCamelCase label}}::Id; }

};
{{else}}
struct TypeInfo {
using Type = {{zapTypeToEncodableClusterObjectType type}};
static constexpr ClusterId GetClusterId() { return {{asUpperCamelCase parent.name}}::Id; }
static constexpr AttributeId GetAttributeId() { return Attributes::{{asUpperCamelCase label}}::Id; }
};

using DecodableTypeInfo = TypeInfo;
{{/if}}
} // namespace for {{asUpperCamelCase label}}
{{/if}}
{{#last}}
} // Attributes
{{/last}}
{{/if}}
{{/zcl_attributes_server}}
} // namespace {{asUpperCamelCase name}}
{{/zcl_clusters}}

Expand Down
6 changes: 6 additions & 0 deletions src/app/zap-templates/templates/app/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,13 @@ function zapTypeToClusterObjectType(type, isDecodable)
return 'uint24_t';
case 'INT32U':
return 'uint32_t';
case 'INT56U':
case 'int56u':
case 'INT64U':
return 'uint64_t';
case 'single':
case 'SINGLE':
return 'float';
}

function fn(pkgId)
Expand All @@ -428,6 +433,7 @@ function zapTypeToClusterObjectType(type, isDecodable)
case 'uint32_t':
case 'int64_t':
case 'uint64_t':
case 'float':
return zclType;
default:
if (isDecodable) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/zap-templates/zcl/data-model/silabs/general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ limitations under the License.
<attribute side="server" code="0x0003" define="SCENE_VALID" type="BOOLEAN" min="0x00" max="0x01" writable="false" default="0x00" optional="false">scene valid</attribute>
<attribute side="server" code="0x0004" define="SCENE_NAME_SUPPORT" type="BITMAP8" min="0x00" max="0x80" writable="false" optional="false">name support</attribute>
<!-- NAME_SUPPORT -->
<attribute side="server" code="0x0005" define="LAST_CONFIGURED_BY" type="EUI64" writable="false" optional="true">last configured by</attribute>
<attribute side="server" code="0x0005" define="LAST_CONFIGURED_BY" type="NODE_ID" writable="false" optional="true">last configured by</attribute>
<command source="client" code="0x00" name="AddScene" optional="false" cli="zcl scenes add">
<description>
Add a scene to the scene table. Extension field sets are supported, and are inputed as arrays of the form [[cluster ID] [length] [value0...n] ...]
Expand Down

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

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

Loading

0 comments on commit ab48324

Please sign in to comment.