Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -13021,6 +13021,7 @@ This module contains the API for templating. For more detailed instructions, rea
* [~if_is_short_string(type)](#module_Templating API_ static zcl helpers..if_is_short_string) ⇒
* [~if_is_long_string(type)](#module_Templating API_ static zcl helpers..if_is_long_string) ⇒
* [~if_is_atomic(type:)](#module_Templating API_ static zcl helpers..if_is_atomic) ⇒
* [~if_attribute_quality(quality, options)](#module_Templating API_ static zcl helpers..if_attribute_quality) ⇒
* [~if_is_bitmap(type)](#module_Templating API_ static zcl helpers..if_is_bitmap) ⇒
* [~if_is_enum(type)](#module_Templating API_ static zcl helpers..if_is_enum) ⇒
* [~if_is_struct(type)](#module_Templating API_ static zcl helpers..if_is_struct) ⇒
Expand Down Expand Up @@ -13607,10 +13608,13 @@ From `exports.map.attribute` in `src-electron/db/db-mapping.js`:
- entryTypeElseType
- id
- isArray
- isAtomic
- isChangeOmitted
- isFabricSensitive
- isNullable
- isOptional
- isQuieterReporting
- isSourceAttribution
- isReadable
- isReadableAttribute
- isReportable
Expand Down Expand Up @@ -14033,6 +14037,41 @@ type is not atomic
| --- | --- | --- |
| type: | <code>\*</code> | string |

<a name="module_Templating API_ static zcl helpers..if_attribute_quality"></a>

### Templating API: static zcl helpers~if\_attribute\_quality(quality, options) ⇒
Block helper that renders its body when the current attribute carries a
given quality (Matter spec section 7.7), and the inverse (`{{else}}`) block
otherwise. Meant to be used inside an attribute iteration context (e.g.
`{{#zcl_attributes}}`) where `this` is an attribute object.

Supported quality names:
- 'fixed' : attribute value is fixed (persistence === 'fixed')
- 'nonVolatile' : attribute is stored in non-volatile memory
- 'changeOmitted' : attribute omits change reporting (C)
- 'quieterReporting' : attribute uses quieter reporting (Q)
- 'sourceAttribution' : attribute carries source attribution (A)
- 'atomic' : attribute must be written atomically (T)
- 'nullable' : attribute is nullable (X)
- 'scene' : attribute is scene required (S)

example:
{{#zcl_attributes}}
{{#if_attribute_quality "quieterReporting"}}
{{label}} uses quieter reporting
{{else}}
{{label}} does not use quieter reporting
{{/if_attribute_quality}}
{{/zcl_attributes}}

**Kind**: inner method of [<code>Templating API: static zcl helpers</code>](#module_Templating API_ static zcl helpers)
**Returns**: rendered block content.

| Param | Type | Description |
| --- | --- | --- |
| quality | <code>\*</code> | name of the quality to check for |
| options | <code>\*</code> | |

<a name="module_Templating API_ static zcl helpers..if_is_bitmap"></a>

### Templating API: static zcl helpers~if\_is\_bitmap(type) ⇒
Expand Down
39 changes: 39 additions & 0 deletions docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -3857,6 +3857,7 @@ This module contains the API for templating. For more detailed instructions, rea
* [~if_is_short_string(type)](#module_Templating API_ static zcl helpers..if_is_short_string) ⇒
* [~if_is_long_string(type)](#module_Templating API_ static zcl helpers..if_is_long_string) ⇒
* [~if_is_atomic(type:)](#module_Templating API_ static zcl helpers..if_is_atomic) ⇒
* [~if_attribute_quality(quality, options)](#module_Templating API_ static zcl helpers..if_attribute_quality) ⇒
* [~if_is_bitmap(type)](#module_Templating API_ static zcl helpers..if_is_bitmap) ⇒
* [~if_is_enum(type)](#module_Templating API_ static zcl helpers..if_is_enum) ⇒
* [~if_is_struct(type)](#module_Templating API_ static zcl helpers..if_is_struct) ⇒
Expand Down Expand Up @@ -4443,10 +4444,13 @@ From `exports.map.attribute` in `src-electron/db/db-mapping.js`:
- entryTypeElseType
- id
- isArray
- isAtomic
- isChangeOmitted
- isFabricSensitive
- isNullable
- isOptional
- isQuieterReporting
- isSourceAttribution
- isReadable
- isReadableAttribute
- isReportable
Expand Down Expand Up @@ -4869,6 +4873,41 @@ type is not atomic
| --- | --- | --- |
| type: | <code>\*</code> | string |

<a name="module_Templating API_ static zcl helpers..if_attribute_quality"></a>

### Templating API: static zcl helpers~if\_attribute\_quality(quality, options) ⇒
Block helper that renders its body when the current attribute carries a
given quality (Matter spec section 7.7), and the inverse (`{{else}}`) block
otherwise. Meant to be used inside an attribute iteration context (e.g.
`{{#zcl_attributes}}`) where `this` is an attribute object.

Supported quality names:
- 'fixed' : attribute value is fixed (persistence === 'fixed')
- 'nonVolatile' : attribute is stored in non-volatile memory
- 'changeOmitted' : attribute omits change reporting (C)
- 'quieterReporting' : attribute uses quieter reporting (Q)
- 'sourceAttribution' : attribute carries source attribution (A)
- 'atomic' : attribute must be written atomically (T)
- 'nullable' : attribute is nullable (X)
- 'scene' : attribute is scene required (S)

example:
{{#zcl_attributes}}
{{#if_attribute_quality "quieterReporting"}}
{{label}} uses quieter reporting
{{else}}
{{label}} does not use quieter reporting
{{/if_attribute_quality}}
{{/zcl_attributes}}

**Kind**: inner method of [<code>Templating API: static zcl helpers</code>](#module_Templating API_ static zcl helpers)
**Returns**: rendered block content.

| Param | Type | Description |
| --- | --- | --- |
| quality | <code>\*</code> | name of the quality to check for |
| options | <code>\*</code> | |

<a name="module_Templating API_ static zcl helpers..if_is_bitmap"></a>

### Templating API: static zcl helpers~if\_is\_bitmap(type) ⇒
Expand Down
3 changes: 3 additions & 0 deletions src-electron/db/db-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ exports.map = {
apiMaturity: x.API_MATURITY,
isChangeOmitted: dbApi.fromDbBool(x.IS_CHANGE_OMITTED),
persistence: x.PERSISTENCE,
isQuieterReporting: dbApi.fromDbBool(x.IS_QUIETER_REPORTING),
isSourceAttribution: dbApi.fromDbBool(x.IS_SOURCE_ATTRIBUTION),
isAtomic: dbApi.fromDbBool(x.IS_ATOMIC),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add these for endpointTypeAttributeExtended as well

entryTypeElseType: x.ARRAY_TYPE ? x.ARRAY_TYPE : x.TYPE // added for convenience between types and entry types from arrays. Precedence set using entryType then type
}
},
Expand Down
13 changes: 11 additions & 2 deletions src-electron/db/query-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,19 @@ INSERT INTO ATTRIBUTE (
REMOVED_IN_REF,
API_MATURITY,
IS_CHANGE_OMITTED,
PERSISTENCE
PERSISTENCE,
Comment thread
paulr34 marked this conversation as resolved.
IS_QUIETER_REPORTING,
IS_SOURCE_ATTRIBUTION,
IS_ATOMIC
) VALUES (
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
(SELECT SPEC_ID FROM SPEC WHERE CODE = ? AND PACKAGE_REF = ?),
(SELECT SPEC_ID FROM SPEC WHERE CODE = ? AND PACKAGE_REF = ?),
?,
?,
?,
?,
?,
?
)`

Expand Down Expand Up @@ -269,7 +275,10 @@ function attributeMap(clusterId, packageId, attributes) {
packageId,
attribute.apiMaturity,
dbApi.toDbBool(attribute.isChangeOmitted),
attribute.persistence
attribute.persistence,
dbApi.toDbBool(attribute.isQuieterReporting),
dbApi.toDbBool(attribute.isSourceAttribution),
dbApi.toDbBool(attribute.isAtomic)
])
}

Expand Down
35 changes: 28 additions & 7 deletions src-electron/db/query-zcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,10 @@ SELECT
API_MATURITY,
PACKAGE_REF,
IS_CHANGE_OMITTED,
PERSISTENCE
PERSISTENCE,
IS_QUIETER_REPORTING,
IS_SOURCE_ATTRIBUTION,
IS_ATOMIC
FROM ATTRIBUTE
WHERE (CLUSTER_REF = ? OR CLUSTER_REF IS NULL)
AND PACKAGE_REF IN (${dbApi.toInClause(packageIds)})
Expand Down Expand Up @@ -775,7 +778,10 @@ SELECT
MUST_USE_TIMED_WRITE,
API_MATURITY,
IS_CHANGE_OMITTED,
PERSISTENCE
PERSISTENCE,
IS_QUIETER_REPORTING,
IS_SOURCE_ATTRIBUTION,
IS_ATOMIC
FROM ATTRIBUTE
WHERE
SIDE = ?
Expand Down Expand Up @@ -844,7 +850,10 @@ SELECT
A.MUST_USE_TIMED_WRITE,
A.API_MATURITY,
A.IS_CHANGE_OMITTED,
A.PERSISTENCE
A.PERSISTENCE,
A.IS_QUIETER_REPORTING,
A.IS_SOURCE_ATTRIBUTION,
A.IS_ATOMIC
FROM
ATTRIBUTE AS A,
CLUSTER AS C
Expand Down Expand Up @@ -900,7 +909,10 @@ SELECT
MUST_USE_TIMED_WRITE,
API_MATURITY,
IS_CHANGE_OMITTED,
PERSISTENCE
PERSISTENCE,
IS_QUIETER_REPORTING,
IS_SOURCE_ATTRIBUTION,
IS_ATOMIC
FROM ATTRIBUTE
WHERE ATTRIBUTE_ID = ?`,
[id]
Expand Down Expand Up @@ -969,7 +981,10 @@ SELECT
A.MUST_USE_TIMED_WRITE,
A.API_MATURITY,
A.IS_CHANGE_OMITTED,
A.PERSISTENCE
A.PERSISTENCE,
A.IS_QUIETER_REPORTING,
A.IS_SOURCE_ATTRIBUTION,
A.IS_ATOMIC
FROM ATTRIBUTE AS A
WHERE ATTRIBUTE_ID = ?`,
[clusterRef, clusterRef, attributeId]
Expand Down Expand Up @@ -1021,7 +1036,10 @@ SELECT
A.API_MATURITY,
C.CODE AS CLUSTER_CODE,
A.IS_CHANGE_OMITTED,
A.PERSISTENCE
A.PERSISTENCE,
A.IS_QUIETER_REPORTING,
A.IS_SOURCE_ATTRIBUTION,
A.IS_ATOMIC
FROM
ATTRIBUTE AS A
LEFT JOIN
Expand Down Expand Up @@ -1079,7 +1097,10 @@ SELECT
MUST_USE_TIMED_WRITE,
API_MATURITY,
IS_CHANGE_OMITTED,
PERSISTENCE
PERSISTENCE,
IS_QUIETER_REPORTING,
IS_SOURCE_ATTRIBUTION,
IS_ATOMIC
FROM ATTRIBUTE
WHERE SIDE = ?
AND PACKAGE_REF IN (${dbApi.toInClause(packageIds)})
Expand Down
3 changes: 3 additions & 0 deletions src-electron/db/zap-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ CREATE TABLE IF NOT EXISTS "ATTRIBUTE" (
"API_MATURITY" text,
"IS_CHANGE_OMITTED" integer,
"PERSISTENCE" text,
"IS_QUIETER_REPORTING" integer,
"IS_SOURCE_ATTRIBUTION" integer,
"IS_ATOMIC" integer,
"MANUFACTURER_CODE_DERIVED" AS (COALESCE(MANUFACTURER_CODE, 0)),
foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE,
foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE,
Expand Down
70 changes: 70 additions & 0 deletions src-electron/generator/helper-zcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1010,10 +1010,13 @@ function zcl_global_commands(options) {
* - entryTypeElseType
* - id
* - isArray
* - isAtomic
* - isChangeOmitted
* - isFabricSensitive
* - isNullable
* - isOptional
* - isQuieterReporting
* - isSourceAttribution
* - isReadable
* - isReadableAttribute
* - isReportable
Expand Down Expand Up @@ -1943,6 +1946,72 @@ async function if_is_atomic(type, options) {
}
}

/**
* Block helper that renders its body when the current attribute carries a
* given quality (Matter spec section 7.7), and the inverse (`{{else}}`) block
* otherwise. Meant to be used inside an attribute iteration context (e.g.
* `{{#zcl_attributes}}`) where `this` is an attribute object.
*
* Supported quality names:
* - 'fixed' : attribute value is fixed (persistence === 'fixed')
* - 'nonVolatile' : attribute is stored in non-volatile memory
* - 'changeOmitted' : attribute omits change reporting (C)
* - 'quieterReporting' : attribute uses quieter reporting (Q)
* - 'sourceAttribution' : attribute carries source attribution (A)
* - 'atomic' : attribute must be written atomically (T)
* - 'nullable' : attribute is nullable (X)
* - 'scene' : attribute is scene required (S)
*
* example:
* {{#zcl_attributes}}
* {{#if_attribute_quality "quieterReporting"}}
* {{label}} uses quieter reporting
* {{else}}
* {{label}} does not use quieter reporting
* {{/if_attribute_quality}}
* {{/zcl_attributes}}
*
* @param {*} quality name of the quality to check for
* @param {*} options
* @returns rendered block content.
*/
function if_attribute_quality(quality, options) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't believe a helper like this is needed. wondering if existing attribute helpers having these properties would be good enough.
@andreilitvin @bzbarsky-apple @hasty could you let @paulr34 know if you needed any specific helpers?

let hasQuality = false
if (this != null) {
switch (quality) {
case 'fixed':

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all hardcoded strings and extend existing enums or create a new one if necessary.

hasQuality = this.persistence === dbEnum.persistence.fixed
break
case 'nonVolatile':
hasQuality = this.persistence === dbEnum.persistence.nonVolatile
break
case 'changeOmitted':
hasQuality = !!this.isChangeOmitted
break
case 'quieterReporting':
hasQuality = !!this.isQuieterReporting
break
case 'sourceAttribution':
hasQuality = !!this.isSourceAttribution
break
case 'atomic':
case 'atomicWrite':
hasQuality = !!this.isAtomic
break
case 'nullable':
hasQuality = !!this.isNullable
break
case 'scene':
hasQuality = !!this.isSceneRequired
break
default:
hasQuality = false
break
}
}
return hasQuality ? options.fn(this) : options.inverse(this)
}
Comment thread
paulr34 marked this conversation as resolved.

/**
* If helper that checks if a type is a bitmap
*
Expand Down Expand Up @@ -3374,6 +3443,7 @@ exports.asUnderlyingZclType = dep(asUnderlyingZclType, {
to: 'as_underlying_zcl_type'
})

exports.if_attribute_quality = if_attribute_quality
exports.if_is_bitmap = if_is_bitmap

exports.if_is_enum = if_is_enum
Expand Down
9 changes: 8 additions & 1 deletion src-electron/zcl/zcl-loader-silabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,14 @@ function prepareCluster(cluster, context, isExtension = false) {
mustUseTimedWrite: attribute.$.mustUseTimedWrite == 'true',
apiMaturity: conformParser.getApiMaturityFromXML(attribute),
isChangeOmitted: quality ? quality.changeOmitted == 'true' : false,
persistence: quality ? quality.persistence : null
persistence: quality ? quality.persistence : null,
isQuieterReporting: quality
? quality.quieterReporting == 'true'
: false,
isSourceAttribution: quality
? quality.sourceAttribution == 'true'
: false,
isAtomic: quality ? quality.atomicWrite == 'true' : false
}
att.access = extractAccessIntoArray(attribute)
if (att.manufacturerCode == null) {
Expand Down
10 changes: 10 additions & 0 deletions src-shared/db-enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ const storagePolicy = {

exports.storagePolicy = storagePolicy

// Attribute persistence quality (Matter spec section 7.7).
// Encodes both the "Fixed" (F) and "Non-Volatile" (N) qualities.
const persistence = {
volatile: 'volatile',
nonVolatile: 'nonVolatile',
fixed: 'fixed'
}
Comment thread
paulr34 marked this conversation as resolved.

exports.persistence = persistence

// When SDK supports a custom device, these are the default values for it.
exports.customDevice = {
domain: 'Custom',
Expand Down
Loading
Loading