Skip to content

Commit

Permalink
Adding smallestEndpointIdentifier to token_attributes helper (#933)
Browse files Browse the repository at this point in the history
JIRA: ZAPP-1036
  • Loading branch information
brdandu authored Feb 15, 2023
1 parent 19626e3 commit 3c82477
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions src-electron/db/db-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ exports.map = {
), // Is Attribute mfg specific or not
endpointId: x.ENDPOINT_IDENTIFIER, // Endpoint type attribute's endpoint Id
tokenId: x.TOKEN_ID, // Endpoint type attribute's token id
smallestEndpointIdentifier: x.SMALLEST_ENDPOINT_IDENTIFIER, // Smallest endpoint Id in which the attribute is present
}
},

Expand Down
24 changes: 13 additions & 11 deletions src-electron/db/query-attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ async function selectAttributeDetailsFromEnabledClusters(
tokenizedAttributeSize: x.TOKENIZED_ATTRIBUTE_SIZE,
maxAttributeSize: x.MAX_ATTRIBUTE_SIZE,
maxTokenAttributeSize: x.MAX_TOKEN_ATTRIBUTE_SIZE,
smallestEndpointIdentifier: x.SMALLEST_ENDPOINT_IDENTIFIER,
isString: x.IS_STRING,
isManufacturingSpecific: dbApi.toDbBool(
x.MANUFACTURER_CODE | x.CLUSTER_MANUFACTURER_CODE
Expand Down Expand Up @@ -496,15 +495,7 @@ async function selectAttributeDetailsFromEnabledClusters(
END
ELSE
0
END) OVER () AS MAX_TOKEN_ATTRIBUTE_SIZE,
(
SELECT
MIN(ENDPOINT_IDENTIFIER)
FROM
ENDPOINT
WHERE
ENDPOINT_TYPE_ATTRIBUTE.ENDPOINT_TYPE_REF = ENDPOINT.ENDPOINT_TYPE_REF
) AS SMALLEST_ENDPOINT_IDENTIFIER
END) OVER () AS MAX_TOKEN_ATTRIBUTE_SIZE
FROM ATTRIBUTE
INNER JOIN ENDPOINT_TYPE_ATTRIBUTE
ON ATTRIBUTE.ATTRIBUTE_ID = ENDPOINT_TYPE_ATTRIBUTE.ATTRIBUTE_REF
Expand Down Expand Up @@ -1031,11 +1022,22 @@ async function selectAllUserTokenAttributes(
ATTRIBUTE.MANUFACTURER_CODE,
ATTRIBUTE.DEFINE,
ATTRIBUTE.SIDE,
ATTRIBUTE.TYPE,
CLUSTER.NAME AS CLUSTER_NAME,
CLUSTER.CODE AS CLUSTER_CODE,
CLUSTER.MANUFACTURER_CODE AS CLUSTER_MANUFACTURER_CODE,
ENDPOINT_TYPE_ATTRIBUTE.SINGLETON,
ENDPOINT.ENDPOINT_IDENTIFIER,
ENDPOINT.ENDPOINT_TYPE_REF
ENDPOINT.ENDPOINT_TYPE_REF,
MIN
(ENDPOINT.ENDPOINT_IDENTIFIER)
OVER
(PARTITION BY
CLUSTER.CODE,
CLUSTER.MANUFACTURER_CODE,
ATTRIBUTE.CODE,
ATTRIBUTE.MANUFACTURER_CODE,
ATTRIBUTE.SIDE) AS SMALLEST_ENDPOINT_IDENTIFIER
FROM
ATTRIBUTE
INNER JOIN
Expand Down
6 changes: 3 additions & 3 deletions test/gen-template/zigbee/zap-tokens-version-2.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ DEFINE_BASIC_TOKEN({{define}}_{{../endpointIdentifier}}, tokType_{{as_snake_case
uint8_t epNetwork; \
{{/if_compare}}
{{/first}}
{{#if_compare 'NVM' storageOption operator='=='}}
{{/all_user_cluster_generated_attributes}}
{{#token_attributes}}
{{#if isSingleton}}
halCommonGetToken((tokType_{{as_snake_case define}} *)ptr, TOKEN_{{define}}_SINGLETON); \
emberAfWrite{{#if isManufacturingSpecific}}ManufacturerSpecific{{/if}}{{as_camel_cased side false}}Attribute({{smallestEndpointIdentifier}}, ZCL_{{as_delimited_macro clusterName}}_CLUSTER_ID, ZCL_{{define}}_ATTRIBUTE_ID, {{#if isManufacturingSpecific}}{{as_hex mfgCode 4}}, {{/if}}(uint8_t*)ptr, ZCL_{{as_delimited_macro type}}_ATTRIBUTE_TYPE); \
{{/if}}
{{/if_compare}}
{{/all_user_cluster_generated_attributes}}
{{/token_attributes}}
{{#token_attribute_endpoints isSingleton=0}}
{{#token_attributes endpointTypeRef isSingleton=0}}
{{#first}}
Expand Down

0 comments on commit 3c82477

Please sign in to comment.