diff --git a/docs/api.md b/docs/api.md index bc6fd6a394..80a276f033 100644 --- a/docs/api.md +++ b/docs/api.md @@ -40,12 +40,12 @@
This module provides queries for device types.
This module provides queries for endpoint configuration.
-This module provides queries for endpoint type.
This module provides queries for endpoint configuration.
+This module provides queries for enums.
This module provides queries related to packages.
This module provides session related queries.
-This module provides queries for ZCL static entities inside a single session. Things like: all visible clusters, etc.
This module provides session related queries.
+This module provides queries for enums.
This module provides the REST API to the IDE component handling.
This module provides the REST API to the session initialization
+This module provides the REST API to the static zcl queries.
Gathers the data type information of an entry based on data type name along with its actual type from disciminator table.
Gathers the data type information based on data type name and +clusterId along with its actual type from disciminator table.
+Gathers All the data types
Select an number matched by name.
Select a number matched by name and clusterId
+Select an number matched by id.
Generates array of { index , mfgCode } pairs, matching the indexes in attribute table.
This helper supports an "order" CSV string, such as: + "direction,endpoint,clusterId,attributeId,mask,mfgCode,minmax" +The string above is a default value, and it determines in what order are the fields generated.
+Attribute collection works like this: 1.) Go over all the clusters that exist. @@ -714,6 +729,33 @@ Use it as: {{future name="NAME"}}
span all attributes from all clusters from all endpointTypes. This helper function allows the template to increment the token ID within the tokens context.Util function that extracts all the token attribute information.
+Get information about all the token attributes in the configuration or this +helper can be used within an endpoint block helper to fetch the +corresponding token attributes based on endpoint type given. +Available Options: +isSingleton: 0/1, option can be used to filter attributes based on singleton +or non-singleton(Available with endpointTypeRef only)
+This helper can return all token associated clusters across endpoints or +this helper can be used within an endpoint block helper to fetch the +corresponding token associated clusters. +Available Options: +isSingleton: 0/1, option can be used to filter clusters based on singleton +or non-singleton attributes.
+Get all endpoints which have token attributes in the configuration. +AvailableOptions:
+Function that actually loads the data out of a state object. Session at this point is blank, and has no packages.
Reads the data from the file and resolves with the state object if all is good.
-Writes the data from the file into a new session. -NOTE: This function does NOT initialize session packages.
-Resolves with a promise that imports session key values.
Parses JSON file and creates a state object out of it, which is passed further down the chain.
Reads the data from the file and resolves with the state object if all is good.
+Writes the data from the file into a new session. +NOTE: This function does NOT initialize session packages.
+Start session specific validation.
Default startup method.
This function returns Properties, Templates and Dirty-Sessions
-This function creates a new session with its packages according to selected Properties and Templates
-This function reloads previous session by user selected session's id
-Perform a file->open operation.
Toplevel function that loads the xml library file and orchestrates the promise chain.
Records the toplevel package information and resolves into packageId
-Records the version into the database.
-Toplevel function that loads the zcl file and passes it off to the correct zcl loader.
-Loads individual zcl.json metafile.
-Load individual custom XML files.
-Promises to qualify whether zcl file needs to be reloaded. -If yes, the it will resolve with {filePath, data, packageId} -If not, then it will resolve with {error}
-Promises to perform a post loading step.
-Promises to read the JSON file and resolve all the data.
Toplevel function that loads the toplevel metafile and orchestrates the promise chain.
Records the toplevel package information and resolves into packageId
+Records the version into the database.
+Toplevel function that loads the zcl file and passes it off to the correct zcl loader.
+Loads individual zcl.json metafile.
+Load individual custom XML files.
+Promises to qualify whether zcl file needs to be reloaded. +If yes, the it will resolve with {filePath, data, packageId} +If not, then it will resolve with {error}
+Promises to perform a post loading step.
+DB API: zcl database access
](#module*DB API* zcl database access)
-### DB API: zcl database access~put(key, packageId, data)
+### DB API: zcl database access~put(key, packageId, data) ⇒
Puts a data object into the cache under a given key/packageId
-**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: Returns true on success.
| Param | Type |
| --------- | --------------- |
@@ -1633,7 +1674,7 @@ Puts a data object into the cache under a given key/packageId
Returns a data object under a given key/packageId.
**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
-**Returns**: cached object or null if none is present
+**Returns**: cached object or undefined if none is present or expired.
| Param | Type |
| --------- | --------------- |
@@ -1654,6 +1695,46 @@ Returns true if a given key/packageId cache exists.
| key | \*
|
| packageId | \*
|
+
+
+### DB API: zcl database access~cacheQuery(key, packageId) ⇒
+
+Cache input / output of provided queryFunction
+The queryFunction is assumed to have the following signature:
+
+async function queryFunction(db, ...) {...}
+
+The DB handle is ignored and the remaining arguments are used as the cache key.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: true or false, depending on whether the cache is present.
+
+| Param | Type |
+| --------- | --------------- |
+| key | \*
|
+| packageId | \*
|
+
+
+
+### DB API: zcl database access~cacheStats()
+
+Returns the cache statistics.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~enable()
+
+Enable the Database Query cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~disable()
+
+Disable the database cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
### DB API: zcl database access~selectAtomicType(db, packageId, typeName)
@@ -1694,6 +1775,22 @@ Retrieves all the bitmaps in the database.
| ----- | --------------- |
| db | \*
|
+
+
+### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a bitmap matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: bitmap information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectAllEnums(db, packageId) ⇒
@@ -1780,6 +1877,22 @@ Select an enum matched by name.
| name | \*
|
| packageIds | \*
|
+
+
+### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select an enum matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: enum information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectSessionClusterByCode(db, sessionId) ⇒
@@ -1836,6 +1949,22 @@ Returns the command available to this session by the code.
| db | \*
|
| sessionId | \*
|
+
+
+### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a struct matched by name and clusterId
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: struct information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒
@@ -2107,22 +2236,29 @@ This module provides queries for atomic type queries.
- [DB API: zcl database access](#module*DB API* zcl database access)
- [~clear()](#module*DB API* zcl database access..clear)
- - [~put(key, packageId, data)](#module*DB API* zcl database access..put)
+ - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒
- [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒
- [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒
+ - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒
+ - [~cacheStats()](#module*DB API* zcl database access..cacheStats)
+ - [~enable()](#module*DB API* zcl database access..enable)
+ - [~disable()](#module*DB API* zcl database access..disable)
- [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType)
- [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById)
- [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒
+ - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒
- [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒
- [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒
- [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒
- [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒
- [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒
- [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒
+ - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒
- [~selectSessionClusterByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒
- [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒
- [~selectSessionAttributeByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒
- [~selectSessionCommandByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒
+ - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒
- [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒
- [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒
- [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒
@@ -2150,11 +2286,12 @@ Clears the entire cache.
**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
-### DB API: zcl database access~put(key, packageId, data)
+### DB API: zcl database access~put(key, packageId, data) ⇒
Puts a data object into the cache under a given key/packageId
-**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: Returns true on success.
| Param | Type |
| --------- | --------------- |
@@ -2169,7 +2306,7 @@ Puts a data object into the cache under a given key/packageId
Returns a data object under a given key/packageId.
**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
-**Returns**: cached object or null if none is present
+**Returns**: cached object or undefined if none is present or expired.
| Param | Type |
| --------- | --------------- |
@@ -2190,6 +2327,46 @@ Returns true if a given key/packageId cache exists.
| key | \*
|
| packageId | \*
|
+
+
+### DB API: zcl database access~cacheQuery(key, packageId) ⇒
+
+Cache input / output of provided queryFunction
+The queryFunction is assumed to have the following signature:
+
+async function queryFunction(db, ...) {...}
+
+The DB handle is ignored and the remaining arguments are used as the cache key.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: true or false, depending on whether the cache is present.
+
+| Param | Type |
+| --------- | --------------- |
+| key | \*
|
+| packageId | \*
|
+
+
+
+### DB API: zcl database access~cacheStats()
+
+Returns the cache statistics.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~enable()
+
+Enable the Database Query cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~disable()
+
+Disable the database cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
### DB API: zcl database access~selectAtomicType(db, packageId, typeName)
@@ -2230,6 +2407,22 @@ Retrieves all the bitmaps in the database.
| ----- | --------------- |
| db | \*
|
+
+
+### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a bitmap matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: bitmap information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectAllEnums(db, packageId) ⇒
@@ -2316,6 +2509,22 @@ Select an enum matched by name.
| name | \*
|
| packageIds | \*
|
+
+
+### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select an enum matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: enum information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectSessionClusterByCode(db, sessionId) ⇒
@@ -2372,6 +2581,22 @@ Returns the command available to this session by the code.
| db | \*
|
| sessionId | \*
|
+
+
+### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a struct matched by name and clusterId
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: struct information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒
@@ -2637,22 +2862,29 @@ This module provides queries for enums.
- [DB API: zcl database access](#module*DB API* zcl database access)
- [~clear()](#module*DB API* zcl database access..clear)
- - [~put(key, packageId, data)](#module*DB API* zcl database access..put)
+ - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒
- [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒
- [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒
+ - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒
+ - [~cacheStats()](#module*DB API* zcl database access..cacheStats)
+ - [~enable()](#module*DB API* zcl database access..enable)
+ - [~disable()](#module*DB API* zcl database access..disable)
- [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType)
- [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById)
- [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒
+ - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒
- [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒
- [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒
- [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒
- [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒
- [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒
- [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒
+ - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒
- [~selectSessionClusterByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒
- [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒
- [~selectSessionAttributeByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒
- [~selectSessionCommandByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒
+ - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒
- [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒
- [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒
- [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒
@@ -2680,11 +2912,12 @@ Clears the entire cache.
**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
-### DB API: zcl database access~put(key, packageId, data)
+### DB API: zcl database access~put(key, packageId, data) ⇒
Puts a data object into the cache under a given key/packageId
-**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: Returns true on success.
| Param | Type |
| --------- | --------------- |
@@ -2699,7 +2932,7 @@ Puts a data object into the cache under a given key/packageId
Returns a data object under a given key/packageId.
**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
-**Returns**: cached object or null if none is present
+**Returns**: cached object or undefined if none is present or expired.
| Param | Type |
| --------- | --------------- |
@@ -2720,6 +2953,46 @@ Returns true if a given key/packageId cache exists.
| key | \*
|
| packageId | \*
|
+
+
+### DB API: zcl database access~cacheQuery(key, packageId) ⇒
+
+Cache input / output of provided queryFunction
+The queryFunction is assumed to have the following signature:
+
+async function queryFunction(db, ...) {...}
+
+The DB handle is ignored and the remaining arguments are used as the cache key.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: true or false, depending on whether the cache is present.
+
+| Param | Type |
+| --------- | --------------- |
+| key | \*
|
+| packageId | \*
|
+
+
+
+### DB API: zcl database access~cacheStats()
+
+Returns the cache statistics.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~enable()
+
+Enable the Database Query cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~disable()
+
+Disable the database cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
### DB API: zcl database access~selectAtomicType(db, packageId, typeName)
@@ -2760,6 +3033,22 @@ Retrieves all the bitmaps in the database.
| ----- | --------------- |
| db | \*
|
+
+
+### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a bitmap matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: bitmap information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectAllEnums(db, packageId) ⇒
@@ -2846,6 +3135,22 @@ Select an enum matched by name.
| name | \*
|
| packageIds | \*
|
+
+
+### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select an enum matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: enum information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectSessionClusterByCode(db, sessionId) ⇒
@@ -2902,6 +3207,22 @@ Returns the command available to this session by the code.
| db | \*
|
| sessionId | \*
|
+
+
+### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a struct matched by name and clusterId
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: struct information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒
@@ -3289,18 +3610,18 @@ we have to link the foreign keys.
| ----- | --------------- |
| db | \*
|
-
-
-## DB API: endpoint configuration queries against the database.
-
-This module provides queries for endpoint configuration.
-
## DB API: endpoint type queries against the database.
This module provides queries for endpoint type.
+
+
+## DB API: endpoint configuration queries against the database.
+
+This module provides queries for endpoint configuration.
+
## DB API: zcl database access
@@ -3309,22 +3630,29 @@ This module provides queries for enums.
- [DB API: zcl database access](#module*DB API* zcl database access)
- [~clear()](#module*DB API* zcl database access..clear)
- - [~put(key, packageId, data)](#module*DB API* zcl database access..put)
+ - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒
- [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒
- [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒
+ - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒
+ - [~cacheStats()](#module*DB API* zcl database access..cacheStats)
+ - [~enable()](#module*DB API* zcl database access..enable)
+ - [~disable()](#module*DB API* zcl database access..disable)
- [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType)
- [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById)
- [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒
+ - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒
- [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒
- [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒
- [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒
- [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒
- [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒
- [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒
+ - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒
- [~selectSessionClusterByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒
- [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒
- [~selectSessionAttributeByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒
- [~selectSessionCommandByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒
+ - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒
- [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒
- [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒
- [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒
@@ -3352,11 +3680,12 @@ Clears the entire cache.
**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
-### DB API: zcl database access~put(key, packageId, data)
+### DB API: zcl database access~put(key, packageId, data) ⇒
Puts a data object into the cache under a given key/packageId
-**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: Returns true on success.
| Param | Type |
| --------- | --------------- |
@@ -3371,7 +3700,7 @@ Puts a data object into the cache under a given key/packageId
Returns a data object under a given key/packageId.
**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
-**Returns**: cached object or null if none is present
+**Returns**: cached object or undefined if none is present or expired.
| Param | Type |
| --------- | --------------- |
@@ -3392,6 +3721,46 @@ Returns true if a given key/packageId cache exists.
| key | \*
|
| packageId | \*
|
+
+
+### DB API: zcl database access~cacheQuery(key, packageId) ⇒
+
+Cache input / output of provided queryFunction
+The queryFunction is assumed to have the following signature:
+
+async function queryFunction(db, ...) {...}
+
+The DB handle is ignored and the remaining arguments are used as the cache key.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: true or false, depending on whether the cache is present.
+
+| Param | Type |
+| --------- | --------------- |
+| key | \*
|
+| packageId | \*
|
+
+
+
+### DB API: zcl database access~cacheStats()
+
+Returns the cache statistics.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~enable()
+
+Enable the Database Query cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~disable()
+
+Disable the database cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
### DB API: zcl database access~selectAtomicType(db, packageId, typeName)
@@ -3432,6 +3801,22 @@ Retrieves all the bitmaps in the database.
| ----- | --------------- |
| db | \*
|
+
+
+### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a bitmap matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: bitmap information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectAllEnums(db, packageId) ⇒
@@ -3518,6 +3903,22 @@ Select an enum matched by name.
| name | \*
|
| packageIds | \*
|
+
+
+### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select an enum matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: enum information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectSessionClusterByCode(db, sessionId) ⇒
@@ -3574,6 +3975,22 @@ Returns the command available to this session by the code.
| db | \*
|
| sessionId | \*
|
+
+
+### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a struct matched by name and clusterId
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: struct information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒
@@ -4278,12 +4695,6 @@ This module provides notification related queries.
This module provides queries related to packages.
-
-
-## DB API: session related queries.
-
-This module provides session related queries.
-
## DB API: zcl database access
@@ -4294,22 +4705,29 @@ all visible clusters, etc.
- [DB API: zcl database access](#module*DB API* zcl database access)
- [~clear()](#module*DB API* zcl database access..clear)
- - [~put(key, packageId, data)](#module*DB API* zcl database access..put)
+ - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒
- [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒
- [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒
+ - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒
+ - [~cacheStats()](#module*DB API* zcl database access..cacheStats)
+ - [~enable()](#module*DB API* zcl database access..enable)
+ - [~disable()](#module*DB API* zcl database access..disable)
- [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType)
- [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById)
- [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒
+ - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒
- [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒
- [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒
- [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒
- [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒
- [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒
- [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒
+ - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒
- [~selectSessionClusterByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒
- [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒
- [~selectSessionAttributeByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒
- [~selectSessionCommandByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒
+ - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒
- [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒
- [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒
- [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒
@@ -4337,11 +4755,12 @@ Clears the entire cache.
**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
-### DB API: zcl database access~put(key, packageId, data)
+### DB API: zcl database access~put(key, packageId, data) ⇒
Puts a data object into the cache under a given key/packageId
-**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: Returns true on success.
| Param | Type |
| --------- | --------------- |
@@ -4356,7 +4775,7 @@ Puts a data object into the cache under a given key/packageId
Returns a data object under a given key/packageId.
**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
-**Returns**: cached object or null if none is present
+**Returns**: cached object or undefined if none is present or expired.
| Param | Type |
| --------- | --------------- |
@@ -4377,6 +4796,46 @@ Returns true if a given key/packageId cache exists.
| key | \*
|
| packageId | \*
|
+
+
+### DB API: zcl database access~cacheQuery(key, packageId) ⇒
+
+Cache input / output of provided queryFunction
+The queryFunction is assumed to have the following signature:
+
+async function queryFunction(db, ...) {...}
+
+The DB handle is ignored and the remaining arguments are used as the cache key.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: true or false, depending on whether the cache is present.
+
+| Param | Type |
+| --------- | --------------- |
+| key | \*
|
+| packageId | \*
|
+
+
+
+### DB API: zcl database access~cacheStats()
+
+Returns the cache statistics.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~enable()
+
+Enable the Database Query cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~disable()
+
+Disable the database cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
### DB API: zcl database access~selectAtomicType(db, packageId, typeName)
@@ -4417,6 +4876,22 @@ Retrieves all the bitmaps in the database.
| ----- | --------------- |
| db | \*
|
+
+
+### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a bitmap matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: bitmap information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectAllEnums(db, packageId) ⇒
@@ -4503,6 +4978,22 @@ Select an enum matched by name.
| name | \*
|
| packageIds | \*
|
+
+
+### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select an enum matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: enum information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectSessionClusterByCode(db, sessionId) ⇒
@@ -4559,6 +5050,22 @@ Returns the command available to this session by the code.
| db | \*
|
| sessionId | \*
|
+
+
+### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a struct matched by name and clusterId
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: struct information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒
@@ -4810,6 +5317,12 @@ Query for attributes by side.
| side | \*
|
| packageId | \*
|
+
+
+## DB API: session related queries.
+
+This module provides session related queries.
+
## DB API: zcl database access
@@ -4818,22 +5331,29 @@ This module provides queries for enums.
- [DB API: zcl database access](#module*DB API* zcl database access)
- [~clear()](#module*DB API* zcl database access..clear)
- - [~put(key, packageId, data)](#module*DB API* zcl database access..put)
+ - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒
- [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒
- [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒
+ - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒
+ - [~cacheStats()](#module*DB API* zcl database access..cacheStats)
+ - [~enable()](#module*DB API* zcl database access..enable)
+ - [~disable()](#module*DB API* zcl database access..disable)
- [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType)
- [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById)
- [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒
+ - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒
- [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒
- [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒
- [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒
- [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒
- [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒
- [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒
+ - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒
- [~selectSessionClusterByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒
- [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒
- [~selectSessionAttributeByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒
- [~selectSessionCommandByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒
+ - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒
- [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒
- [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒
- [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒
@@ -4861,11 +5381,12 @@ Clears the entire cache.
**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
-### DB API: zcl database access~put(key, packageId, data)
+### DB API: zcl database access~put(key, packageId, data) ⇒
Puts a data object into the cache under a given key/packageId
-**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: Returns true on success.
| Param | Type |
| --------- | --------------- |
@@ -4880,7 +5401,7 @@ Puts a data object into the cache under a given key/packageId
Returns a data object under a given key/packageId.
**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
-**Returns**: cached object or null if none is present
+**Returns**: cached object or undefined if none is present or expired.
| Param | Type |
| --------- | --------------- |
@@ -4901,6 +5422,46 @@ Returns true if a given key/packageId cache exists.
| key | \*
|
| packageId | \*
|
+
+
+### DB API: zcl database access~cacheQuery(key, packageId) ⇒
+
+Cache input / output of provided queryFunction
+The queryFunction is assumed to have the following signature:
+
+async function queryFunction(db, ...) {...}
+
+The DB handle is ignored and the remaining arguments are used as the cache key.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: true or false, depending on whether the cache is present.
+
+| Param | Type |
+| --------- | --------------- |
+| key | \*
|
+| packageId | \*
|
+
+
+
+### DB API: zcl database access~cacheStats()
+
+Returns the cache statistics.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~enable()
+
+Enable the Database Query cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~disable()
+
+Disable the database cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
### DB API: zcl database access~selectAtomicType(db, packageId, typeName)
@@ -4941,6 +5502,22 @@ Retrieves all the bitmaps in the database.
| ----- | --------------- |
| db | \*
|
+
+
+### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a bitmap matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: bitmap information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectAllEnums(db, packageId) ⇒
@@ -5027,6 +5604,22 @@ Select an enum matched by name.
| name | \*
|
| packageIds | \*
|
+
+
+### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select an enum matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: enum information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectSessionClusterByCode(db, sessionId) ⇒
@@ -5083,6 +5676,22 @@ Returns the command available to this session by the code.
| db | \*
|
| sessionId | \*
|
+
+
+### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a struct matched by name and clusterId
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: struct information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒
@@ -5342,22 +5951,29 @@ This module provides queries for ZCL static queries.
- [DB API: zcl database access](#module*DB API* zcl database access)
- [~clear()](#module*DB API* zcl database access..clear)
- - [~put(key, packageId, data)](#module*DB API* zcl database access..put)
+ - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒
- [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒
- [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒
+ - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒
+ - [~cacheStats()](#module*DB API* zcl database access..cacheStats)
+ - [~enable()](#module*DB API* zcl database access..enable)
+ - [~disable()](#module*DB API* zcl database access..disable)
- [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType)
- [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById)
- [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒
+ - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒
- [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒
- [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒
- [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒
- [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒
- [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒
- [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒
+ - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒
- [~selectSessionClusterByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒
- [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒
- [~selectSessionAttributeByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒
- [~selectSessionCommandByCode(db, sessionId)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒
+ - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒
- [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒
- [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒
- [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒
@@ -5385,11 +6001,12 @@ Clears the entire cache.
**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
-### DB API: zcl database access~put(key, packageId, data)
+### DB API: zcl database access~put(key, packageId, data) ⇒
Puts a data object into the cache under a given key/packageId
-**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: Returns true on success.
| Param | Type |
| --------- | --------------- |
@@ -5404,7 +6021,7 @@ Puts a data object into the cache under a given key/packageId
Returns a data object under a given key/packageId.
**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
-**Returns**: cached object or null if none is present
+**Returns**: cached object or undefined if none is present or expired.
| Param | Type |
| --------- | --------------- |
@@ -5425,29 +6042,69 @@ Returns true if a given key/packageId cache exists.
| key | \*
|
| packageId | \*
|
-
+
-### DB API: zcl database access~selectAtomicType(db, packageId, typeName)
+### DB API: zcl database access~cacheQuery(key, packageId) ⇒
-Locates atomic type based on a type name. Query is not case sensitive.
+Cache input / output of provided queryFunction
+The queryFunction is assumed to have the following signature:
-**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+async function queryFunction(db, ...) {...}
+
+The DB handle is ignored and the remaining arguments are used as the cache key.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: true or false, depending on whether the cache is present.
| Param | Type |
| --------- | --------------- |
-| db | \*
|
+| key | \*
|
| packageId | \*
|
-| typeName | \*
|
-
+
-### DB API: zcl database access~selectAtomicById(db, packageId)
+### DB API: zcl database access~cacheStats()
-Retrieves atomic type by a given Id.
+Returns the cache statistics.
-**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
-| Param | Type |
+### DB API: zcl database access~enable()
+
+Enable the Database Query cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~disable()
+
+Disable the database cache
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+
+### DB API: zcl database access~selectAtomicType(db, packageId, typeName)
+
+Locates atomic type based on a type name. Query is not case sensitive.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+| Param | Type |
+| --------- | --------------- |
+| db | \*
|
+| packageId | \*
|
+| typeName | \*
|
+
+
+
+### DB API: zcl database access~selectAtomicById(db, packageId)
+
+Retrieves atomic type by a given Id.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+
+| Param | Type |
| --------- | --------------- |
| db | \*
|
| packageId | \*
|
@@ -5465,6 +6122,22 @@ Retrieves all the bitmaps in the database.
| ----- | --------------- |
| db | \*
|
+
+
+### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a bitmap matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: bitmap information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectAllEnums(db, packageId) ⇒
@@ -5551,6 +6224,22 @@ Select an enum matched by name.
| name | \*
|
| packageIds | \*
|
+
+
+### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select an enum matched by name and clusterId.
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: enum information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectSessionClusterByCode(db, sessionId) ⇒
@@ -5607,6 +6296,22 @@ Returns the command available to this session by the code.
| db | \*
|
| sessionId | \*
|
+
+
+### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Select a struct matched by name and clusterId
+
+**Kind**: inner method of [DB API: zcl database access
](#module*DB API* zcl database access)
+**Returns**: struct information or undefined
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| name | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+
### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒
@@ -7285,7 +7990,7 @@ This module contains the API for templating. For more detailed instructions, rea
- [~user_cluster_commands_all_endpoints(options)](#module*Templating API* user-data specific helpers..user_cluster_commands_all_endpoints)
- [~user_cluster_has_enabled_command(name, side)](#module*Templating API* user-data specific helpers..user_cluster_has_enabled_command) ⇒
- [~all_user_cluster_commands_irrespective_of_manufaturing_specification(options)](#module*Templating API* user-data specific helpers..all_user_cluster_commands_irrespective_of_manufaturing_specification) ⇒
- - [~all_user_cluster_attributes_irrespective_of_manufatucuring_specification(options)](#module*Templating API* user-data specific helpers..all_user_cluster_attributes_irrespective_of_manufatucuring_specification) ⇒
+ - [~enabled_attributes_for_cluster_and_side(name, side, options)](#module*Templating API* user-data specific helpers..enabled_attributes_for_cluster_and_side) ⇒
- [~user_session_key(options)](#module*Templating API* user-data specific helpers..user_session_key) ⇒
- [~if_command_discovery_enabled()](#module*Templating API* user-data specific helpers..if_command_discovery_enabled)
- [~is_command_default_response_enabled(command, options)](#module*Templating API* user-data specific helpers..is_command_default_response_enabled) ⇒
@@ -7644,20 +8349,29 @@ and non-manufacturing specific cluster commands.
| ------- |
| options |
-
+
-### Templating API: user-data specific helpers~all_user_cluster_attributes_irrespective_of_manufatucuring_specification(options) ⇒
+### Templating API: user-data specific helpers~enabled_attributes_for_cluster_and_side(name, side, options) ⇒
Creates endpoint type cluster attribute iterator. This fetches all
-manufacturing and non-manufaturing specific attributes which have been enabled
-on added endpoints
+manufacturing-specific and standard attributes which have been enabled on
+added endpoints based on the name and side of the cluster. When side
+is not mentioned then client and server attributes are returned.
+Available Options:
+
+- removeKeys: Removes one or more keys from the map(for eg keys in db-mapping.js)
+ for eg:(#enabled_attributes_for_cluster_and_side
+ [cluster-name], [cluster-side], removeKeys='isOptional, isNullable')
+ will remove 'isOptional' and 'isNullable' from the results
**Kind**: inner method of [Templating API: user-data specific helpers
](#module*Templating API* user-data specific helpers)
**Returns**: Promise of the resolved blocks iterating over manufacturing specific
-and non-manufacturing specific cluster attributes.
+and standard cluster attributes.
| Param |
| ------- |
+| name |
+| side |
| options |
@@ -8421,12 +9135,13 @@ This module contains the API for templating. For more detailed instructions, rea
- [~command_mask(commmandSource, clusterSide, isIncomingEnabled, isOutgoingEnabled, manufacturingCode, prefixForMask)](#module*Templating API* static zcl helpers..command_mask) ⇒
- [~command_mask_sub_helper(commandMask, str)](#module*Templating API* static zcl helpers..command_mask_sub_helper) ⇒
- [~format_zcl_string_as_characters_for_generated_defaults(stringVal, sizeOfString)](#module*Templating API* static zcl helpers..format_zcl_string_as_characters_for_generated_defaults) ⇒
- - [~get_sign_and_size_of_zcl_type(type, context, options)](#module*Templating API* static zcl helpers..get_sign_and_size_of_zcl_type) ⇒
- [~as_type_min_value(type, options)](#module*Templating API* static zcl helpers..as_type_min_value) ⇒
- [~as_type_max_value(type, options)](#module*Templating API* static zcl helpers..as_type_max_value) ⇒
- [~structs_with_clusters(options)](#module*Templating API* static zcl helpers..structs_with_clusters)
- [~as_zcl_type_size(type, options)](#module*Templating API* static zcl helpers..as_zcl_type_size) ⇒
- [~if_compare(leftValue, rightValue, options)](#module*Templating API* static zcl helpers..if_compare) ⇒ Object
+ - [~if_is_data_type_signed(type, clusterId, options)](#module*Templating API* static zcl helpers..if_is_data_type_signed) ⇒
+ - [~as_zcl_data_type_size(type, clusterId, options)](#module*Templating API* static zcl helpers..as_zcl_data_type_size) ⇒
@@ -8757,6 +9472,11 @@ that belong to that cluster.
Iterator over the server attributes. If it is used at toplevel, if iterates over all the server attributes
in the database. If used within zcl_cluster context, it iterates over all the server attributes
that belong to that cluster.
+Available Options:
+
+- removeKeys: Removes one or more keys from the map(for eg keys in db-mapping.js)
+ for eg: (#zcl_attributes_server removeKeys='isOptional, isNullable') will remove 'isOptional'
+ from the results
**Kind**: inner method of [Templating API: static zcl helpers
](#module*Templating API* static zcl helpers)
**Returns**: Promise of attribute iteration.
@@ -9417,6 +10137,10 @@ will return: 0x00, 0x00, 0x38, 0x40,
**Kind**: inner method of [Templating API: static zcl helpers
](#module*Templating API* static zcl helpers)
**Returns**: Formatted attribute value based on given arguments
+Available options:
+
+- endian: Specify 'big' or 'little' endian format
+- isCommaTerminated: '0' or '1' for output to have a ',' at the end
| Param |
| ------------- |
@@ -9430,6 +10154,9 @@ will return: 0x00, 0x00, 0x38, 0x40,
Given the attributes of a zcl attribute. Creates an attribute mask based on
the given options
+Available options:
+isClusterCodeMfgSpecific: 0/1, This is to determine if cluster code needs to
+be used to determine if a cluster is mfg specific or not.
**Kind**: inner method of [Templating API: static zcl helpers
](#module*Templating API* static zcl helpers)
**Returns**: attribute mask based on given values
@@ -9489,6 +10216,12 @@ for example:
will return as follows:
3, 'a', 'b', 'c' 0, 0
+Available Options:
+
+- isOctet: 0/1 can be used to return results correctly for octet strings
+- isCommaTerminated: 0/1 can be used to return result with/without ',' at
+ the end
+
**Kind**: inner method of [Templating API: static zcl helpers
](#module*Templating API* static zcl helpers)
**Returns**: Formatted string for generated defaults starting with the lenth of a
string then each character and then filler for the size allocated for the
@@ -9499,30 +10232,6 @@ string. Long strings prefixed by 2 byte length field.
| stringVal |
| sizeOfString |
-
-
-### Templating API: static zcl helpers~get_sign_and_size_of_zcl_type(type, context, options) ⇒
-
-Given a zcl device type returns its sign, size and zcl data type info stored
-in the database table.
-Note: Enums and Bitmaps are considered to be unsigned.
-
-**Kind**: inner method of [Templating API: static zcl helpers
](#module*Templating API* static zcl helpers)
-**Returns**: returns sign, size and info of zcl device type
-Available Options:
-
-- size: Determine whether to calculate the size of zcl device type in bits
- or bytes
- for eg: get_sign_and_size_of_zcl_type('int8u' this size='bits') will return
- the size in bits which will be 8. If not mentioned then it will return the size
- in bytes i.e. 1 in this case.
-
-| Param | Type |
-| ------- | --------------- |
-| type | \*
|
-| context | \*
|
-| options | \*
|
-
### Templating API: static zcl helpers~as_type_min_value(type, options) ⇒
@@ -9613,6 +10322,43 @@ Content when comparison returns false
| rightValue | \*
|
| options | \*
|
+
+
+### Templating API: static zcl helpers~if_is_data_type_signed(type, clusterId, options) ⇒
+
+Check if the given type is signed or not based on the type name and cluster
+id.
+
+**Kind**: inner method of [Templating API: static zcl helpers
](#module*Templating API* static zcl helpers)
+**Returns**: Promise of content
+
+| Param | Type |
+| --------- | --------------- |
+| type | \*
|
+| clusterId | \*
|
+| options | \*
|
+
+
+
+### Templating API: static zcl helpers~as_zcl_data_type_size(type, clusterId, options) ⇒
+
+Fetches the size of the data type based on type name and cluster id given
+Note: size is zero for structs
+Available Options:
+
+- roundUpToPowerOfTwo: Rounds the size up to the nearest power of 2
+- sizeIn: By default size is returned in bytes but it can be returned in bits
+ by mentioning sizeIn="bits"
+
+**Kind**: inner method of [Templating API: static zcl helpers
](#module*Templating API* static zcl helpers)
+**Returns**: size of the data type
+
+| Param | Type |
+| --------- | --------------- |
+| type | \*
|
+| clusterId | \*
|
+| options | \*
|
+
## Templating API: Overridable functions.
@@ -11044,6 +11790,7 @@ This module provides the REST API to the admin functions.
- [REST API: admin functions](#module*REST API* admin functions)
- [~httpPostSql(db, app)](#module*REST API* admin functions..httpPostSql) ⇒
- [~httpGetVersion(db)](#module*REST API* admin functions..httpGetVersion) ⇒
+ - [~httpGetCache(db)](#module*REST API* admin functions..httpGetCache)
@@ -11098,6 +11845,29 @@ Response JSON:
| ----- | --------------- |
| db | \*
|
+
+
+### REST API: admin functions~httpGetCache(db)
+
+API: /cache
+Response JSON:
+
++ { + keys: 0, // global key count + hits: 0, // global hit count + misses: 0, // global miss count + ksize: 0, // global key size count in approximately bytes + vsize: 0 // global value size count in approximately bytes + } ++ +**Kind**: inner method of [
REST API: admin functions
](#module*REST API* admin functions)
+
+| Param | Type |
+| ----- | --------------- |
+| db | \*
|
+
## REST API: endpoint
@@ -11350,6 +12120,71 @@ Enable components by 'componentId' or corresponding components specified, via 'd
| ----- | --------------- |
| db | \*
|
+
+
+## REST API: initialization functions
+
+This module provides the REST API to the session initialization
+
+- [REST API: initialization functions](#module*REST API* initialization functions)
+ - [~packagesAndSessions(db)](#module*REST API* initialization functions..packagesAndSessions) ⇒
+ - [~initializeSession(db, options:)](#module*REST API* initialization functions..initializeSession) ⇒
+ - [~loadPreviousSessions(db)](#module*REST API* initialization functions..loadPreviousSessions) ⇒
+ - [~init(db)](#module*REST API* initialization functions..init) ⇒
+
+
+
+### REST API: initialization functions~packagesAndSessions(db) ⇒
+
+This function returns Properties, Templates and Dirty-Sessions
+
+**Kind**: inner method of [REST API: initialization functions
](#module*REST API* initialization functions)
+**Returns**: Properties, Templates and Dirty-Sessions.
+
+| Param | Type |
+| ----- | --------------- |
+| db | \*
|
+
+
+
+### REST API: initialization functions~initializeSession(db, options:) ⇒
+
+This function creates a new session with its packages according to selected Properties and Templates
+
+**Kind**: inner method of [REST API: initialization functions
](#module*REST API* initialization functions)
+**Returns**: A success message.
+
+| Param | Type | Description |
+| -------- | --------------- | -------------------------------------- |
+| db | \*
| |
+| options: | \*
| object containing 'zcl' and 'template' |
+
+
+
+### REST API: initialization functions~loadPreviousSessions(db) ⇒
+
+This function reloads previous session by user selected session's id
+
+**Kind**: inner method of [REST API: initialization functions
](#module*REST API* initialization functions)
+**Returns**: A success message.
+
+| Param | Type |
+| ----- | --------------- |
+| db | \*
|
+
+
+
+### REST API: initialization functions~init(db) ⇒
+
+Init function from the App.vue
+
+**Kind**: inner method of [REST API: initialization functions
](#module*REST API* initialization functions)
+**Returns**: A success message.
+
+| Param | Type |
+| ----- | --------------- |
+| db | \*
|
+
## REST API: static zcl functions
@@ -12038,6 +12873,7 @@ logger is used for printouts.
- [~isSignedInteger(type)](#module*JS API* type related utilities..isSignedInteger) ⇒
- [~isOneBytePrefixedString(type)](#module*JS API* type related utilities..isOneBytePrefixedString) ⇒
- [~isTwoBytePrefixedString(type)](#module*JS API* type related utilities..isTwoBytePrefixedString) ⇒
+ - [~getSignAndSizeOfZclType(type, context, options)](#module*JS API* type related utilities..getSignAndSizeOfZclType) ⇒
@@ -12192,6 +13028,30 @@ Checks if type is a two-byte lengh string.
| ----- | --------------- |
| type | \*
|
+
+
+### JS API: type related utilities~getSignAndSizeOfZclType(type, context, options) ⇒
+
+Given a zcl device type returns its sign, size and zcl data type info stored
+in the database table.
+Note: Enums and Bitmaps are considered to be unsigned.
+
+**Kind**: inner method of [JS API: type related utilities
](#module*JS API* type related utilities)
+**Returns**: returns sign, size and info of zcl device type
+Available Options:
+
+- size: Determine whether to calculate the size of zcl device type in bits
+ or bytes
+ for eg: getSignAndSizeOfZclType('int8u' this size='bits') will return
+ the size in bits which will be 8. If not mentioned then it will return the size
+ in bytes i.e. 1 in this case.
+
+| Param | Type |
+| ------- | --------------- |
+| type | \*
|
+| context | \*
|
+| options | \*
|
+
## JS API: random utilities
@@ -12491,6 +13351,7 @@ This module provides the API to access various zcl utilities.
- [~clusterComparator(a, b)](#module*REST API* various zcl utilities..clusterComparator) ⇒
- [~attributeComparator(a, b)](#module*REST API* various zcl utilities..attributeComparator) ⇒
- [~commandComparator(a, b)](#module*REST API* various zcl utilities..commandComparator) ⇒
+ - [~eventComparator(a, b)](#module*REST API* various zcl utilities..eventComparator) ⇒
- [~sortStructsByDependency(structs)](#module*REST API* various zcl utilities..sortStructsByDependency) ⇒
- [~calculateBytes(res, options, db, packageIds, isStructType)](#module*REST API* various zcl utilities..calculateBytes)
- [~optionsHashOrDefault(options, optionsKey, defaultValue)](#module*REST API* various zcl utilities..optionsHashOrDefault)
@@ -12503,6 +13364,7 @@ This module provides the API to access various zcl utilities.
- [~dataTypeHelper(type, options, packageIds, db, resolvedType, overridable)](#module*REST API* various zcl utilities..dataTypeHelper) ⇒
- [~asUnderlyingZclTypeWithPackageId(type, options, packageIds, currentInstance)](#module*REST API* various zcl utilities..asUnderlyingZclTypeWithPackageId)
- [~determineType(db, type, packageIds)](#module*REST API* various zcl utilities..determineType)
+ - [~zcl_data_type_size_and_sign(type, dataType, clusterId, packageIds, context)](#module*REST API* various zcl utilities..zcl_data_type_size_and_sign) ⇒
@@ -12546,6 +13408,20 @@ Comparator for sorting commands.
| a | \*
|
| b | \*
|
+
+
+### REST API: various zcl utilities~eventComparator(a, b) ⇒
+
+Comparator for sorting events.
+
+**Kind**: inner method of [REST API: various zcl utilities
](#module*REST API* various zcl utilities)
+**Returns**: -1, 0 or 1
+
+| Param | Type |
+| ----- | --------------- |
+| a | \*
|
+| b | \*
|
+
### REST API: various zcl utilities~sortStructsByDependency(structs) ⇒
@@ -12736,6 +13612,21 @@ Base type for struct is a null.
| type | \*
|
| packageIds | \*
|
+
+
+### REST API: various zcl utilities~zcl_data_type_size_and_sign(type, dataType, clusterId, packageIds, context) ⇒
+
+**Kind**: inner method of [REST API: various zcl utilities
](#module*REST API* various zcl utilities)
+**Returns**: The size and sign of a zcl data type
+
+| Param | Type |
+| ---------- | --------------- |
+| type | \*
|
+| dataType | \*
|
+| clusterId | \*
|
+| packageIds | \*
|
+| context | \*
|
+
## renderer_api
@@ -13310,6 +14201,23 @@ with its actual type from disciminator table.
| name |
| packageIds |
+
+
+## selectDataTypeByNameAndClusterId(db, name, clusterId, packageIds) ⇒
+
+Gathers the data type information based on data type name and
+clusterId along with its actual type from disciminator table.
+
+**Kind**: global function
+**Returns**: Data type information
+
+| Param |
+| ---------- |
+| db |
+| name |
+| clusterId |
+| packageIds |
+
## selectAllDataTypes(db, packageId) ⇒
@@ -13356,6 +14264,21 @@ Select an number matched by name.
| name |
| packageIds |
+
+
+## selectNumberByNameAndClusterId(db, name, packageIds) ⇒
+
+Select a number matched by name and clusterId
+
+**Kind**: global function
+**Returns**: number information or undefined
+
+| Param |
+| ---------- |
+| db |
+| name |
+| packageIds |
+
## selectNumberById(db, name) ⇒
@@ -13752,6 +14675,20 @@ the indexes in attribute table.
| ------- | --------------- |
| options | \*
|
+
+
+## endpoint_reporting_config_defaults(options)
+
+This helper supports an "order" CSV string, such as:
+"direction,endpoint,clusterId,attributeId,mask,mfgCode,minmax"
+The string above is a default value, and it determines in what order are the fields generated.
+
+**Kind**: global function
+
+| Param | Type |
+| ------- | --------------- |
+| options | \*
|
+
## collectAttributes()
@@ -13881,9 +14818,83 @@ span all attributes from all clusters from all endpointTypes. This helper
function allows the template to increment the token ID within the tokens context.
**Kind**: global function
-
+
-## get_cli_size(size, type, allowZclTypes) ⇒
+## token_attribute_util(context, options) ⇒
+
+Util function that extracts all the token attribute information.
+
+**Kind**: global function
+**Returns**: Information on all token attributes in the configuration.
+
+| Param | Type |
+| ------- | --------------- |
+| context | \*
|
+| options | \*
|
+
+
+
+## token_attributes(endpointTypeRef, options) ⇒
+
+Get information about all the token attributes in the configuration or this
+helper can be used within an endpoint block helper to fetch the
+corresponding token attributes based on endpoint type given.
+Available Options:
+isSingleton: 0/1, option can be used to filter attributes based on singleton
+or non-singleton(Available with endpointTypeRef only)
+
+**Kind**: global function
+**Returns**: singleton and non-singleton token attributes along with their
+endpoint information. Singleton attributes are only returned once whereas
+non-singleton attributes are returned per endpoint. However if used within
+an endpoint block helper it returns token_attributes for a given endpoint
+type.
+
+| Param | Type |
+| --------------- | --------------- |
+| endpointTypeRef | \*
|
+| options | \*
|
+
+
+
+## token_attribute_clusters(endpointTypeRef, options) ⇒
+
+This helper can return all token associated clusters across endpoints or
+this helper can be used within an endpoint block helper to fetch the
+corresponding token associated clusters.
+Available Options:
+isSingleton: 0/1, option can be used to filter clusters based on singleton
+or non-singleton attributes.
+
+**Kind**: global function
+**Returns**: Token associated clusters for a particular endpoint type or all
+token associated clusters across endpoints.
+
+| Param | Type |
+| --------------- | --------------- |
+| endpointTypeRef | \*
|
+| options | \*
|
+
+
+
+## token_attribute_endpoints(options) ⇒
+
+Get all endpoints which have token attributes in the configuration.
+AvailableOptions:
+
+- isSingleton: 0/1, option can be used to filter endpoints based on singleton
+ or non-singleton.
+
+**Kind**: global function
+**Returns**: all endpoints with token attributes
+
+| Param | Type |
+| ------- | --------------- |
+| options | \*
|
+
+
+
+## get_cli_size(size, type, allowZclTypes) ⇒
**Kind**: global function
**Returns**: The size in bits for a cli type based on allowZclTypes
@@ -14175,34 +15186,6 @@ Session at this point is blank, and has no packages.
| state | \*
|
| sessionId | \*
|
-
-
-## readDataFromFile(filePath) ⇒
-
-Reads the data from the file and resolves with the state object if all is good.
-
-**Kind**: global function
-**Returns**: Promise of file reading.
-
-| Param | Type |
-| -------- | --------------- |
-| filePath | \*
|
-
-
-
-## importDataFromFile(db, filePath) ⇒
-
-Writes the data from the file into a new session.
-NOTE: This function does NOT initialize session packages.
-
-**Kind**: global function
-**Returns**: a promise that resolves with the import result object that contains: sessionId, errors, warnings.
-
-| Param | Type |
-| -------- | --------------- |
-| db | \*
|
-| filePath | \*
|
-
## importSessionKeyValues(db, sessionId, keyValuePairs)
@@ -14278,6 +15261,34 @@ Parses JSON file and creates a state object out of it, which is passed further d
| filePath | \*
|
| data | \*
|
+
+
+## readDataFromFile(filePath) ⇒
+
+Reads the data from the file and resolves with the state object if all is good.
+
+**Kind**: global function
+**Returns**: Promise of file reading.
+
+| Param | Type |
+| -------- | --------------- |
+| filePath | \*
|
+
+
+
+## importDataFromFile(db, filePath) ⇒
+
+Writes the data from the file into a new session.
+NOTE: This function does NOT initialize session packages.
+
+**Kind**: global function
+**Returns**: a promise that resolves with the import result object that contains: sessionId, errors, warnings.
+
+| Param | Type |
+| -------- | --------------- |
+| db | \*
|
+| filePath | \*
|
+
## initSessionTimers()
@@ -14451,46 +15462,6 @@ Default startup method.
| quitFunction | \*
|
| argv | \*
|
-
-
-## packagesAndSessions(db) ⇒
-
-This function returns Properties, Templates and Dirty-Sessions
-
-**Kind**: global function
-**Returns**: Properties, Templates and Dirty-Sessions.
-
-| Param | Type |
-| ----- | --------------- |
-| db | \*
|
-
-
-
-## initializeSession(db, options:) ⇒
-
-This function creates a new session with its packages according to selected Properties and Templates
-
-**Kind**: global function
-**Returns**: A success message.
-
-| Param | Type | Description |
-| -------- | --------------- | -------------------------------------- |
-| db | \*
| |
-| options: | \*
| object containing 'zcl' and 'template' |
-
-
-
-## loadPreviousSessions(db) ⇒
-
-This function reloads previous session by user selected session's id
-
-**Kind**: global function
-**Returns**: A success message.
-
-| Param | Type |
-| ----- | --------------- |
-| db | \*
|
-
## doOpen(menuItem, browserWindow, event)
@@ -15131,118 +16102,6 @@ and orchestrates the promise chain.
| db | \*
| |
| ctx | \*
| Context of loading. |
-
-
-## recordToplevelPackage(db, metadataFile, crc) ⇒
-
-Records the toplevel package information and resolves into packageId
-
-**Kind**: global function
-**Returns**: packageId
-
-| Param | Type |
-| ------------ | --------------- |
-| db | \*
|
-| metadataFile | \*
|
-| crc | \*
|
-
-
-
-## recordVersion(db, ctx)
-
-Records the version into the database.
-
-**Kind**: global function
-
-| Param | Type |
-| ----- | --------------- |
-| db | \*
|
-| ctx | \*
|
-
-
-
-## loadZclMetafiles(db, metadataFile) ⇒
-
-Toplevel function that loads the zcl file and passes it off to the correct zcl loader.
-
-**Kind**: global function
-**Returns**: Array of loaded packageIds.
-
-| Param | Type | Description |
-| ------------ | --------------- | -------------- |
-| db | \*
| |
-| metadataFile | \*
| array of paths |
-
-
-
-## loadZcl(db, metadataFile) ⇒
-
-Loads individual zcl.json metafile.
-
-**Kind**: global function
-**Returns**: Context object that contains .db and .packageId
-
-| Param | Type |
-| ------------ | --------------- |
-| db | \*
|
-| metadataFile | \*
|
-
-
-
-## loadIndividualFile(db, filePath, sessionId)
-
-Load individual custom XML files.
-
-**Kind**: global function
-
-| Param | Type | Description |
-| --------- | --------------- | ----------------------------------------------------- |
-| db | \*
| |
-| filePath | \*
| |
-| sessionId | \*
| Current session within which we're loading this file. |
-
-
-
-## qualifyZclFile(db, info, parentPackageId) ⇒
-
-Promises to qualify whether zcl file needs to be reloaded.
-If yes, the it will resolve with {filePath, data, packageId}
-If not, then it will resolve with {error}
-
-**Kind**: global function
-**Returns**: Promise that resolves int he object of data.
-
-| Param | Type |
-| --------------- | --------------- |
-| db | \*
|
-| info | \*
|
-| parentPackageId | \*
|
-
-
-
-## processZclPostLoading(db) ⇒
-
-Promises to perform a post loading step.
-
-**Kind**: global function
-**Returns**: Promise to deal with the post-loading cleanup.
-
-| Param | Type |
-| ----- | --------------- |
-| db | \*
|
-
-
-
-## getDiscriminatorMap(db, packageIds) ⇒
-
-**Kind**: global function
-**Returns**: data type discriminator map
-
-| Param | Type |
-| ---------- | --------------- |
-| db | \*
|
-| packageIds | \*
|
-
## collectDataFromJsonFile(ctx) ⇒
@@ -16021,3 +16880,115 @@ and orchestrates the promise chain.
| ----- | --------------- | ----------------------- |
| db | \*
| |
| ctx | \*
| The context of loading. |
+
+
+
+## recordToplevelPackage(db, metadataFile, crc) ⇒
+
+Records the toplevel package information and resolves into packageId
+
+**Kind**: global function
+**Returns**: packageId
+
+| Param | Type |
+| ------------ | --------------- |
+| db | \*
|
+| metadataFile | \*
|
+| crc | \*
|
+
+
+
+## recordVersion(db, ctx)
+
+Records the version into the database.
+
+**Kind**: global function
+
+| Param | Type |
+| ----- | --------------- |
+| db | \*
|
+| ctx | \*
|
+
+
+
+## loadZclMetafiles(db, metadataFile) ⇒
+
+Toplevel function that loads the zcl file and passes it off to the correct zcl loader.
+
+**Kind**: global function
+**Returns**: Array of loaded packageIds.
+
+| Param | Type | Description |
+| ------------ | --------------- | -------------- |
+| db | \*
| |
+| metadataFile | \*
| array of paths |
+
+
+
+## loadZcl(db, metadataFile) ⇒
+
+Loads individual zcl.json metafile.
+
+**Kind**: global function
+**Returns**: Context object that contains .db and .packageId
+
+| Param | Type |
+| ------------ | --------------- |
+| db | \*
|
+| metadataFile | \*
|
+
+
+
+## loadIndividualFile(db, filePath, sessionId)
+
+Load individual custom XML files.
+
+**Kind**: global function
+
+| Param | Type | Description |
+| --------- | --------------- | ----------------------------------------------------- |
+| db | \*
| |
+| filePath | \*
| |
+| sessionId | \*
| Current session within which we're loading this file. |
+
+
+
+## qualifyZclFile(db, info, parentPackageId) ⇒
+
+Promises to qualify whether zcl file needs to be reloaded.
+If yes, the it will resolve with {filePath, data, packageId}
+If not, then it will resolve with {error}
+
+**Kind**: global function
+**Returns**: Promise that resolves int he object of data.
+
+| Param | Type |
+| --------------- | --------------- |
+| db | \*
|
+| info | \*
|
+| parentPackageId | \*
|
+
+
+
+## processZclPostLoading(db) ⇒
+
+Promises to perform a post loading step.
+
+**Kind**: global function
+**Returns**: Promise to deal with the post-loading cleanup.
+
+| Param | Type |
+| ----- | --------------- |
+| db | \*
|
+
+
+
+## getDiscriminatorMap(db, packageIds) ⇒
+
+**Kind**: global function
+**Returns**: data type discriminator map
+
+| Param | Type |
+| ---------- | --------------- |
+| db | \*
|
+| packageIds | \*
|
diff --git a/src-electron/db/db-mapping.js b/src-electron/db/db-mapping.js
index ec75213ba9..a533b77ba1 100644
--- a/src-electron/db/db-mapping.js
+++ b/src-electron/db/db-mapping.js
@@ -23,6 +23,7 @@
const dbApi = require('./db-api.js')
const dbEnums = require('../../src-shared/db-enum.js')
+const bin = require('../util/bin')
exports.map = {
package: (x) => {
@@ -93,7 +94,7 @@ exports.map = {
manufacturerCode: x.MANUFACTURER_CODE,
name: x.NAME,
label: x.NAME,
- type: x.TYPE,
+ type: x.TYPE != 'array' ? x.TYPE : x.ARRAY_TYPE,
side: x.SIDE,
define: x.DEFINE,
min: x.MIN,
@@ -105,15 +106,20 @@ exports.map = {
reportableChange: x.REPORTABLE_CHANGE,
reportableChangeLength: x.REPORTABLE_CHANGE_LENGTH,
isWritable: dbApi.fromDbBool(x.IS_WRITABLE),
+ isWritableAttribute: dbApi.fromDbBool(x.IS_WRITABLE),
isNullable: dbApi.fromDbBool(x.IS_NULLABLE),
defaultValue: x.DEFAULT_VALUE,
isOptional: dbApi.fromDbBool(x.IS_OPTIONAL),
isReportable:
x.REPORTING_POLICY == dbEnums.reportingPolicy.mandatory ||
x.REPORTING_POLICY == dbEnums.reportingPolicy.suggested,
+ isReportableAttribute:
+ x.REPORTING_POLICY == dbEnums.reportingPolicy.mandatory ||
+ x.REPORTING_POLICY == dbEnums.reportingPolicy.suggested,
reportingPolicy: x.REPORTING_POLICY,
isSceneRequired: dbApi.fromDbBool(x.IS_SCENE_REQUIRED),
entryType: x.ARRAY_TYPE,
+ isArray: x.ARRAY_TYPE ? 1 : 0,
mustUseTimedWrite: dbApi.fromDbBool(x.MUST_USE_TIMED_WRITE),
}
},
@@ -475,36 +481,61 @@ exports.map = {
endpointTypeAttributeExtended: (x) => {
if (x == null) return undefined
return {
- endpointTypeRef: x.ENDPOINT_TYPE_REF,
- clusterRef: x.CLUSTER_REF,
+ arrayType: x.ARRAY_TYPE,
attributeRef: x.ATTRIBUTE_REF,
- included: dbApi.fromDbBool(x.INCLUDED),
- storageOption: x.STORAGE_OPTION,
- singleton: dbApi.fromDbBool(x.SINGLETON),
bounded: dbApi.fromDbBool(x.BOUNDED),
- defaultValue: x.DEFAULT_VALUE,
- includedReportable: dbApi.fromDbBool(x.INCLUDED_REPORTABLE),
- minInterval: x.MIN_INTERVAL,
- maxInterval: x.MAX_INTERVAL,
- reportableChange: x.REPORTABLE_CHANGE,
- name: x.NAME, // Attribute Name
- code: x.CODE, // Attribute Code
- side: x.SIDE, // Attribute Side
- define: x.DEFINE, // Attribute define
- type: x.TYPE, // Attribute type
- mfgCode: x.MANUFACTURER_CODE
- ? x.MANUFACTURER_CODE
- : x.CLUSTER_MANUFACTURER_CODE, // Attribute manufacturer code
+ clusterDefine: x.CLUSTER_DEFINE,
clusterMfgCode: x.CLUSTER_MANUFACTURER_CODE,
clusterName: x.CLUSTER_NAME,
- clusterDefine: x.CLUSTER_DEFINE,
- isSingleton: dbApi.fromDbBool(x.SINGLETON), // Endpoint type attribute is singleton or not
+ clusterRef: x.CLUSTER_REF,
+ clusterSide: x.SIDE,
+ code: x.CODE, // Attribute Code
+ defaultValue: x.DEFAULT_VALUE,
+ define: x.DEFINE, // Attribute define
+ endpointId: x.ENDPOINT_IDENTIFIER, // Endpoint type attribute's endpoint Id
+ endpointTypeRef: x.ENDPOINT_TYPE_REF,
+ entryType: x.ARRAY_TYPE,
+ hexCode: '0x' + bin.int16ToHex(x['CODE'] ? x['CODE'] : 0), // Attribute code in hex
+ id: x.ATTRIBUTE_ID, // Attribute id
+ included: dbApi.fromDbBool(x.INCLUDED),
+ includedReportable: dbApi.fromDbBool(x.INCLUDED_REPORTABLE), // Is attribute reportable
+ isArray: x.IS_ARRAY, // Is attribute of type array
+ isBound: dbApi.fromDbBool(x.BOUNDED), // Is endpoint type attribute bounded
+ isClusterEnabled: x.ENABLED,
+ isGlobalAttribute: x.IS_GLOBAL_ATTRIBUTE, // Is attribute global
+ isIncluded: dbApi.fromDbBool(x.INCLUDED), // Is endpoint type attribute included
isManufacturingSpecific: dbApi.toDbBool(
x.MANUFACTURER_CODE | x.CLUSTER_MANUFACTURER_CODE
), // 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
+ isNullable: dbApi.fromDbBool(x.IS_NULLABLE), // Is attribute nullable
+ isOptionalAttribute: dbApi.fromDbBool(x.IS_OPTIONAL),
+ isReportableAttribute: dbApi.fromDbBool(x.INCLUDED_REPORTABLE), // Is attribute reportable
+ isSceneRequired: dbApi.fromDbBool(x.IS_SCENE_REQUIRED),
+ isSingleton: dbApi.fromDbBool(x.SINGLETON), // Endpoint type attribute is singleton or not
+ isWritable: dbApi.fromDbBool(x.IS_WRITABLE), // Is attribute writable
+ isWritableAttribute: dbApi.fromDbBool(x.IS_WRITABLE), // Is attribute writable
+ manufacturerCode: x.MANUFACTURER_CODE
+ ? x.MANUFACTURER_CODE
+ : x.CLUSTER_MANUFACTURER_CODE, // Attribute manufacturer code
+ max: x.MAX, // Attribute max value
+ maxInterval: x.MAX_INTERVAL,
+ maxLength: x.MAX_LENGTH, // Attribute max length
+ mfgCode: x.MANUFACTURER_CODE
+ ? x.MANUFACTURER_CODE
+ : x.CLUSTER_MANUFACTURER_CODE, // Attribute manufacturer code
+ min: x.MIN, // Attribute min value
+ minInterval: x.MIN_INTERVAL,
+ minLength: x.MIN_LENGTH, // Attribute min length
+ mustUseTimedWrite: dbApi.fromDbBool(x.MUST_USE_TIMED_WRITE),
+ name: x.NAME, // Attribute Name
+ reportableChange: x.REPORTABLE_CHANGE,
+ side: x.SIDE, // Attribute Side
+ singleton: dbApi.fromDbBool(x.SINGLETON),
smallestEndpointIdentifier: x.SMALLEST_ENDPOINT_IDENTIFIER, // Smallest endpoint Id in which the attribute is present
+ storage: x.STORAGE_OPTION,
+ storageOption: x.STORAGE_OPTION,
+ tokenId: x.TOKEN_ID, // Endpoint type attribute's token id
+ type: x.TYPE != 'array' ? x.TYPE : x.ARRAY_TYPE, // Attribute type
}
},
diff --git a/src-electron/db/query-attribute.js b/src-electron/db/query-attribute.js
index 39b22fc009..32b840dc13 100644
--- a/src-electron/db/query-attribute.js
+++ b/src-electron/db/query-attribute.js
@@ -24,21 +24,6 @@ const dbApi = require('./db-api.js')
const dbMapping = require('./db-mapping.js')
const dbCache = require('./db-cache')
-function attributeExportMapping(x) {
- return {
- id: x.ATTRIBUTE_ID,
- name: x.NAME,
- code: x.CODE,
- side: x.SIDE,
- type: x.TYPE,
- define: x.DEFINE,
- mfgCode: x.MANUFACTURER_CODE,
- clusterSide: x.SIDE,
- clusterName: x.CLUSTER_NAME,
- isClusterEnabled: x.ENABLED,
- }
-}
-
/**
* Promises to select all endpoint type attributes filtered by EndpointTypeRef and ClusterRef.
*
@@ -147,13 +132,19 @@ async function duplicateEndpointTypeAttribute(
* @param {*} db
* @param {*} endpointTypeId
* @param {*} packageIds
+ * @param {*} side
* @returns Promise that resolves with the attribute data.
*/
async function selectAllAttributeDetailsFromEnabledClusters(
db,
endpointsAndClusters,
- packageIds
+ packageIds,
+ side = null
) {
+ let sideFilter = ''
+ if (side) {
+ sideFilter = ` AND ATTRIBUTE.SIDE = '${side}' `
+ }
let endpointTypeClusterRef = endpointsAndClusters
.map((ep) => ep.endpointTypeClusterRef)
.toString()
@@ -171,21 +162,59 @@ async function selectAllAttributeDetailsFromEnabledClusters(
ATTRIBUTE.MANUFACTURER_CODE,
ENDPOINT_TYPE_CLUSTER.SIDE,
CLUSTER.NAME AS CLUSTER_NAME,
- ENDPOINT_TYPE_CLUSTER.ENABLED
+ ENDPOINT_TYPE_CLUSTER.ENABLED,
+ CASE
+ WHEN
+ ATTRIBUTE.ARRAY_TYPE IS NOT NULL
+ THEN
+ 1
+ ELSE
+ 0
+ END AS IS_ARRAY,
+ ATTRIBUTE.IS_WRITABLE,
+ ATTRIBUTE.IS_NULLABLE,
+ ATTRIBUTE.MAX_LENGTH,
+ ATTRIBUTE.MIN_LENGTH,
+ ATTRIBUTE.MIN,
+ ATTRIBUTE.MAX,
+ ATTRIBUTE.ARRAY_TYPE,
+ ATTRIBUTE.MUST_USE_TIMED_WRITE,
+ ATTRIBUTE.IS_SCENE_REQUIRED,
+ ATTRIBUTE.IS_OPTIONAL,
+ CASE
+ WHEN
+ ATTRIBUTE.CLUSTER_REF IS NULL
+ THEN
+ 1
+ ELSE
+ 0
+ END AS IS_GLOBAL_ATTRIBUTE,
+ ENDPOINT_TYPE_ATTRIBUTE.INCLUDED_REPORTABLE,
+ ENDPOINT_TYPE_ATTRIBUTE.STORAGE_OPTION,
+ ENDPOINT_TYPE_ATTRIBUTE.SINGLETON,
+ ENDPOINT_TYPE_ATTRIBUTE.BOUNDED,
+ ENDPOINT_TYPE_ATTRIBUTE.INCLUDED,
+ ENDPOINT_TYPE_ATTRIBUTE.DEFAULT_VALUE,
+ ENDPOINT_TYPE_ATTRIBUTE.MIN_INTERVAL,
+ ENDPOINT_TYPE_ATTRIBUTE.MAX_INTERVAL,
+ ENDPOINT_TYPE_ATTRIBUTE.REPORTABLE_CHANGE
FROM ATTRIBUTE
INNER JOIN ENDPOINT_TYPE_ATTRIBUTE
ON ATTRIBUTE.ATTRIBUTE_ID = ENDPOINT_TYPE_ATTRIBUTE.ATTRIBUTE_REF
- INNER JOIN CLUSTER
- ON ATTRIBUTE.CLUSTER_REF = CLUSTER.CLUSTER_ID
INNER JOIN ENDPOINT_TYPE_CLUSTER
- ON CLUSTER.CLUSTER_ID = ENDPOINT_TYPE_CLUSTER.CLUSTER_REF
+ ON ENDPOINT_TYPE_ATTRIBUTE.ENDPOINT_TYPE_CLUSTER_REF = ENDPOINT_TYPE_CLUSTER.ENDPOINT_TYPE_CLUSTER_ID
+ INNER JOIN CLUSTER
+ ON ENDPOINT_TYPE_CLUSTER.CLUSTER_REF = CLUSTER.CLUSTER_ID
WHERE ENDPOINT_TYPE_CLUSTER.CLUSTER_REF IN (${endpointTypeClusterRef})
AND ENDPOINT_TYPE_ATTRIBUTE.INCLUDED = 1
- AND ATTRIBUTE.PACKAGE_REF IN (${dbApi.toInClause(packageIds)})
- GROUP BY ATTRIBUTE.NAME
+ AND ENDPOINT_TYPE_CLUSTER.ENABLED = 1
+ AND ATTRIBUTE.PACKAGE_REF IN (${dbApi.toInClause(packageIds)})
+ ${sideFilter}
+ GROUP BY CLUSTER.MANUFACTURER_CODE, CLUSTER.CODE, ATTRIBUTE.MANUFACTURER_CODE, ATTRIBUTE.CODE, ATTRIBUTE.SIDE
+ ORDER BY ATTRIBUTE.CODE
`
)
- .then((rows) => rows.map(attributeExportMapping))
+ .then((rows) => rows.map(dbMapping.map.endpointTypeAttributeExtended))
}
/**
@@ -248,7 +277,7 @@ async function selectAttributeDetailsFromAllEndpointTypesAndClustersUtil(
GROUP BY ATTRIBUTE.NAME
`
)
- .then((rows) => rows.map(attributeExportMapping))
+ .then((rows) => rows.map(dbMapping.map.endpointTypeAttributeExtended))
}
/**
diff --git a/src-electron/db/query-bitmap.js b/src-electron/db/query-bitmap.js
index c9220f4a86..9c05d3060f 100644
--- a/src-electron/db/query-bitmap.js
+++ b/src-electron/db/query-bitmap.js
@@ -23,6 +23,7 @@
const dbApi = require('./db-api')
const dbCache = require('./db-cache')
const dbMapping = require('./db-mapping')
+const queryUtil = require('./query-util')
/**
* Retrieves all the bitmaps in the database.
@@ -68,6 +69,39 @@ WHERE (DATA_TYPE.NAME = ? OR DATA_TYPE.NAME = ?) AND DATA_TYPE.PACKAGE_REF IN ($
.then(dbMapping.map.bitmap)
}
+/**
+ * Select a bitmap matched by name and clusterId.
+ * @param {*} db
+ * @param {*} name
+ * @param {*} clusterId
+ * @param {*} packageIds
+ * @returns bitmap information or undefined
+ */
+async function selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) {
+ let queryWithoutClusterId = queryUtil.sqlQueryForDataTypeByNameAndClusterId(
+ 'bitmap',
+ null,
+ packageIds
+ )
+ let queryWithClusterId = queryUtil.sqlQueryForDataTypeByNameAndClusterId(
+ 'bitmap',
+ clusterId,
+ packageIds
+ )
+
+ let res = await dbApi
+ .dbAll(db, queryWithoutClusterId, [name, name.toLowerCase()])
+ .then((rows) => rows.map(dbMapping.map.bitmap))
+
+ if (res && res.length == 1) {
+ return res[0]
+ } else {
+ return dbApi
+ .dbGet(db, queryWithClusterId, [name, name.toLowerCase(), clusterId])
+ .then(dbMapping.map.bitmap)
+ }
+}
+
async function selectBitmapById(db, id) {
return dbApi
.dbGet(
@@ -88,3 +122,6 @@ WHERE BITMAP_ID = ?`,
exports.selectBitmapById = selectBitmapById
exports.selectAllBitmaps = selectAllBitmaps
exports.selectBitmapByName = dbCache.cacheQuery(selectBitmapByName)
+exports.selectBitmapByNameAndClusterId = dbCache.cacheQuery(
+ selectBitmapByNameAndClusterId
+)
diff --git a/src-electron/db/query-data-type.js b/src-electron/db/query-data-type.js
index 926bc2384a..83c0a76091 100644
--- a/src-electron/db/query-data-type.js
+++ b/src-electron/db/query-data-type.js
@@ -94,6 +94,71 @@ async function selectDataTypeByName(db, name, packageIds) {
.then(dbMapping.map.dataType)
}
+/**
+ * Gathers the data type information based on data type name and
+ * clusterId along with its actual type from disciminator table.
+ * @param db
+ * @param name
+ * @param clusterId
+ * @param packageIds
+ * @returns Data type information
+ */
+async function selectDataTypeByNameAndClusterId(
+ db,
+ name,
+ clusterId,
+ packageIds
+) {
+ let selectQueryString = `
+ SELECT
+ DATA_TYPE.DATA_TYPE_ID,
+ DATA_TYPE.NAME AS NAME,
+ DATA_TYPE.DESCRIPTION,
+ DATA_TYPE.DISCRIMINATOR_REF,
+ DATA_TYPE.PACKAGE_REF,
+ DISCRIMINATOR.NAME AS DISCRIMINATOR_NAME
+ FROM
+ DATA_TYPE
+ INNER JOIN
+ DISCRIMINATOR
+ ON
+ DATA_TYPE.DISCRIMINATOR_REF = DISCRIMINATOR.DISCRIMINATOR_ID `
+
+ let clusterQueryExtension = `
+ INNER JOIN
+ DATA_TYPE_CLUSTER
+ ON
+ DATA_TYPE.DATA_TYPE_ID = DATA_TYPE_CLUSTER.DATA_TYPE_REF `
+
+ let whereClause = `
+ WHERE
+ (DATA_TYPE.NAME = ? OR DATA_TYPE.NAME = ?)
+ AND DATA_TYPE.PACKAGE_REF IN (${dbApi.toInClause(packageIds)}) `
+
+ let whereClauseClusterExtension = `
+ AND DATA_TYPE_CLUSTER.CLUSTER_REF = ?`
+
+ let queryWithoutClusterId = selectQueryString + whereClause
+ let queryWithClusterId =
+ selectQueryString +
+ clusterQueryExtension +
+ whereClause +
+ whereClauseClusterExtension
+
+ let smallCaseName = name.toLowerCase()
+ let res = await dbApi
+ .dbAll(db, queryWithoutClusterId, [name, smallCaseName])
+ .then((rows) => rows.map(dbMapping.map.dataType))
+
+ if (res && res.length == 1) {
+ return res[0]
+ } else {
+ return dbApi
+ .dbGet(db, queryWithClusterId, [name, smallCaseName, clusterId])
+ .then(dbMapping.map.dataType)
+ }
+}
+
/**
* Gathers All the data types
* @param db
@@ -186,3 +251,6 @@ exports.selectDataTypeById = selectDataTypeById
exports.selectDataTypeByName = dbCache.cacheQuery(selectDataTypeByName)
exports.selectAllDataTypes = selectAllDataTypes
exports.selectSizeFromType = selectSizeFromType
+exports.selectDataTypeByNameAndClusterId = dbCache.cacheQuery(
+ selectDataTypeByNameAndClusterId
+)
diff --git a/src-electron/db/query-enum.js b/src-electron/db/query-enum.js
index c1304d34e6..eb450c66d9 100644
--- a/src-electron/db/query-enum.js
+++ b/src-electron/db/query-enum.js
@@ -23,6 +23,7 @@
const dbApi = require('./db-api')
const dbCache = require('./db-cache')
const dbMapping = require('./db-mapping')
+const queryUtil = require('./query-util')
/**
* Retrieves all the enums in the database.
@@ -210,9 +211,45 @@ ORDER BY NAME`,
.then(dbMapping.map.enum)
}
+/**
+ * Select an enum matched by name and clusterId.
+ *
+ * @param {*} db
+ * @param {*} name
+ * @param {*} clusterId
+ * @param {*} packageIds
+ * @returns enum information or undefined
+ */
+async function selectEnumByNameAndClusterId(db, name, clusterId, packageIds) {
+ let queryWithoutClusterId = queryUtil.sqlQueryForDataTypeByNameAndClusterId(
+ 'enum',
+ null,
+ packageIds
+ )
+ let queryWithClusterId = queryUtil.sqlQueryForDataTypeByNameAndClusterId(
+ 'enum',
+ clusterId,
+ packageIds
+ )
+ let res = await dbApi
+ .dbAll(db, queryWithoutClusterId, [name, name.toLowerCase()])
+ .then((rows) => rows.map(dbMapping.map.enum))
+
+ if (res && res.length == 1) {
+ return res[0]
+ } else {
+ return dbApi
+ .dbGet(db, queryWithClusterId, [name, name.toLowerCase(), clusterId])
+ .then(dbMapping.map.enum)
+ }
+}
+
// exports
exports.selectAllEnums = selectAllEnums
exports.selectEnumByName = dbCache.cacheQuery(selectEnumByName)
+exports.selectEnumByNameAndClusterId = dbCache.cacheQuery(
+ selectEnumByNameAndClusterId
+)
exports.selectEnumById = selectEnumById
exports.selectClusterEnums = selectClusterEnums
exports.selectAllEnumItemsById = selectAllEnumItemsById
diff --git a/src-electron/db/query-number.js b/src-electron/db/query-number.js
index fa3a1a7898..490f3f6313 100644
--- a/src-electron/db/query-number.js
+++ b/src-electron/db/query-number.js
@@ -21,6 +21,7 @@
const dbApi = require('./db-api')
const dbMapping = require('./db-mapping')
const dbCache = require('./db-cache')
+const queryUtil = require('./query-util')
/**
* Select an number matched by name.
@@ -48,6 +49,38 @@ async function selectNumberByName(db, packageIds, name) {
.then(dbMapping.map.number)
}
+/**
+ * Select a number matched by name and clusterId
+ *
+ * @param db
+ * @param name
+ * @param packageIds
+ * @returns number information or undefined
+ */
+async function selectNumberByNameAndClusterId(db, name, clusterId, packageIds) {
+ let queryWithoutClusterId = queryUtil.sqlQueryForDataTypeByNameAndClusterId(
+ 'number',
+ null,
+ packageIds
+ )
+ let queryWithClusterId = queryUtil.sqlQueryForDataTypeByNameAndClusterId(
+ 'number',
+ clusterId,
+ packageIds
+ )
+ let res = await dbApi
+ .dbAll(db, queryWithoutClusterId, [name])
+ .then((rows) => rows.map(dbMapping.map.number))
+
+ if (res && res.length == 1) {
+ return res[0]
+ } else {
+ return dbApi
+ .dbGet(db, queryWithClusterId, [name, clusterId])
+ .then(dbMapping.map.number)
+ }
+}
+
/**
* Select an number matched by id.
*
@@ -99,5 +132,8 @@ async function selectAllNumbers(db, packageId) {
}
exports.selectNumberByName = dbCache.cacheQuery(selectNumberByName)
+exports.selectNumberByNameAndClusterId = dbCache.cacheQuery(
+ selectNumberByNameAndClusterId
+)
exports.selectAllNumbers = selectAllNumbers
exports.selectNumberById = selectNumberById
diff --git a/src-electron/db/query-struct.js b/src-electron/db/query-struct.js
index 6bb12b7c90..59a39ecb00 100644
--- a/src-electron/db/query-struct.js
+++ b/src-electron/db/query-struct.js
@@ -23,6 +23,7 @@
const dbApi = require('./db-api')
const dbCache = require('./db-cache')
const dbMapping = require('./db-mapping')
+const queryUtil = require('./query-util')
async function selectAllStructs(db, packageId) {
let rows = await dbApi.dbAll(
@@ -94,6 +95,38 @@ ORDER BY
.then(dbMapping.map.struct)
}
+/**
+ * Select a struct matched by name and clusterId
+ * @param {*} db
+ * @param {*} name
+ * @param {*} clusterId
+ * @param {*} packageIds
+ * @returns struct information or undefined
+ */
+async function selectStructByNameAndClusterId(db, name, clusterId, packageIds) {
+ let queryWithoutClusterId = queryUtil.sqlQueryForDataTypeByNameAndClusterId(
+ 'struct',
+ null,
+ packageIds
+ )
+ let queryWithClusterId = queryUtil.sqlQueryForDataTypeByNameAndClusterId(
+ 'struct',
+ clusterId,
+ packageIds
+ )
+ let res = await dbApi
+ .dbAll(db, queryWithoutClusterId, [name])
+ .then((rows) => rows.map(dbMapping.map.struct))
+
+ if (res && res.length == 1) {
+ return res[0]
+ } else {
+ return dbApi
+ .dbGet(db, queryWithClusterId, [name, clusterId])
+ .then(dbMapping.map.struct)
+ }
+}
+
/**
* Get all structs which have a cluster associated with them. If a struct is
* present in more than one cluster then it can be grouped by struct name to
@@ -144,5 +177,8 @@ WHERE
exports.selectStructById = selectStructById
exports.selectAllStructs = selectAllStructs
exports.selectStructByName = dbCache.cacheQuery(selectStructByName)
+exports.selectStructByNameAndClusterId = dbCache.cacheQuery(
+ selectStructByNameAndClusterId
+)
exports.selectStructsWithClusterAssociation =
selectStructsWithClusterAssociation
diff --git a/src-electron/db/query-util.js b/src-electron/db/query-util.js
new file mode 100644
index 0000000000..732ade4d02
--- /dev/null
+++ b/src-electron/db/query-util.js
@@ -0,0 +1,79 @@
+/**
+ *
+ * Copyright (c) 2021 Silicon Labs
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This module provides a place for creating generic queries which are common
+ * across different query files.
+ *
+ * @module DB API: zcl database access
+ */
+const dbApi = require('./db-api')
+
+function sqlQueryForDataTypeByNameAndClusterId(
+ typeDiscriminator,
+ clusterId = null,
+ packageIds
+) {
+ let typeTableName = typeDiscriminator.toUpperCase()
+ let numberExtensionString =
+ typeDiscriminator == 'number' ? 'NUMBER.IS_SIGNED, ' : ''
+ let checkLowerCaseString =
+ typeDiscriminator != 'number' && typeDiscriminator != 'struct'
+ ? 'OR DATA_TYPE.NAME = ?'
+ : ''
+ let structExtensionString =
+ typeDiscriminator == 'struct'
+ ? 'STRUCT.IS_FABRIC_SCOPED, DATA_TYPE.DISCRIMINATOR_REF, '
+ : ''
+ let selectQueryString = `
+ SELECT
+ ${typeTableName}.${typeTableName}_ID,
+ ${structExtensionString}
+ DATA_TYPE.NAME AS NAME,
+ ${numberExtensionString}
+ ${typeTableName}.SIZE AS SIZE
+ FROM ${typeTableName}
+ INNER JOIN
+ DATA_TYPE
+ ON
+ ${typeTableName}.${typeTableName}_ID = DATA_TYPE.DATA_TYPE_ID `
+
+ let clusterQueryExtension = `
+ INNER JOIN
+ DATA_TYPE_CLUSTER
+ ON
+ DATA_TYPE_CLUSTER.DATA_TYPE_REF = ${typeTableName}.${typeTableName}_ID `
+
+ let whereClause = `
+ WHERE
+ (DATA_TYPE.NAME = ? ${checkLowerCaseString})
+ AND DATA_TYPE.PACKAGE_REF IN (${dbApi.toInClause(packageIds)}) `
+
+ let whereClauseClusterExtension = `
+ AND DATA_TYPE_CLUSTER.CLUSTER_REF = ? `
+
+ let queryWithoutClusterId = selectQueryString + whereClause
+ let queryWithClusterId =
+ selectQueryString +
+ clusterQueryExtension +
+ whereClause +
+ whereClauseClusterExtension
+ return clusterId ? queryWithClusterId : queryWithoutClusterId
+}
+
+exports.sqlQueryForDataTypeByNameAndClusterId =
+ sqlQueryForDataTypeByNameAndClusterId
diff --git a/src-electron/db/query-zcl.js b/src-electron/db/query-zcl.js
index 577f4986b5..2328ebffca 100644
--- a/src-electron/db/query-zcl.js
+++ b/src-electron/db/query-zcl.js
@@ -1132,18 +1132,27 @@ exports.selectAllEnumItemsById = queryEnum.selectAllEnumItemsById
exports.selectAllEnumItems = queryEnum.selectAllEnumItems
exports.selectEnumById = queryEnum.selectEnumById
exports.selectEnumByName = queryEnum.selectEnumByName
+exports.selectEnumByNameAndClusterId = queryEnum.selectEnumByNameAndClusterId
exports.selectStructById = queryStruct.selectStructById
exports.selectStructByName = queryStruct.selectStructByName
+exports.selectStructByNameAndClusterId =
+ queryStruct.selectStructByNameAndClusterId
exports.selectBitmapById = queryBitmap.selectBitmapById
exports.selectAllBitmaps = queryBitmap.selectAllBitmaps
exports.selectBitmapByName = queryBitmap.selectBitmapByName
+exports.selectBitmapByNameAndClusterId =
+ queryBitmap.selectBitmapByNameAndClusterId
exports.selectDataTypeById = queryDataType.selectDataTypeById
exports.selectDataTypeByName = queryDataType.selectDataTypeByName
+exports.selectDataTypeByNameAndClusterId =
+ queryDataType.selectDataTypeByNameAndClusterId
exports.selectNumberByName = queryNumber.selectNumberByName
+exports.selectNumberByNameAndClusterId =
+ queryNumber.selectNumberByNameAndClusterId
exports.selectAllDiscriminators = queryDiscriminator.selectAllDiscriminators
exports.selectAllDataTypes = queryDataType.selectAllDataTypes
diff --git a/src-electron/generator/helper-session.js b/src-electron/generator/helper-session.js
index 9cc3a49bd4..67efb6b1f1 100644
--- a/src-electron/generator/helper-session.js
+++ b/src-electron/generator/helper-session.js
@@ -294,7 +294,8 @@ async function all_user_cluster_attribute_util(
await queryAttribute.selectAllAttributeDetailsFromEnabledClusters(
currentContext.global.db,
endpointsAndClusters,
- packageIds
+ packageIds,
+ side
)
} else if (isManufacturingSpecific) {
endpointAttributes =
@@ -311,6 +312,10 @@ async function all_user_cluster_attribute_util(
packageIds
)
}
+ if ('removeKeys' in options.hash) {
+ let keys = options.hash.removeKeys.split(',')
+ keys.forEach((k) => endpointAttributes.map((attr) => delete attr[k.trim()]))
+ }
let availableAttributes = []
for (let i = 0; i < endpointAttributes.length; i++) {
@@ -612,18 +617,22 @@ function all_user_cluster_commands_irrespective_of_manufaturing_specification(
/**
* Creates endpoint type cluster attribute iterator. This fetches all
- * manufacturing and non-manufaturing specific attributes which have been enabled
- * on added endpoints
+ * manufacturer-specific and standard attributes which have been enabled on
+ * added endpoints based on the name and side of the cluster. When side
+ * is not mentioned then client and server attributes are returned.
+ * Available Options:
+ * - removeKeys: Removes one or more keys from the map(for eg keys in db-mapping.js)
+ * for eg:(#enabled_attributes_for_cluster_and_side
+ * [cluster-name], [cluster-side], removeKeys='isOptional, isNullable')
+ * will remove 'isOptional' and 'isNullable' from the results
*
+ * @param name
+ * @param side
* @param options
* @returns Promise of the resolved blocks iterating over manufacturing specific
- * and non-manufacturing specific cluster attributes.
+ * and standard cluster attributes.
*/
-function all_user_cluster_attributes_irrespective_of_manufatucuring_specification(
- name,
- side,
- options
-) {
+function enabled_attributes_for_cluster_and_side(name, side, options) {
return all_user_cluster_attribute_util(name, side, options, this, false, true)
}
@@ -1526,7 +1535,15 @@ exports.all_user_cluster_manufacturer_specific_attributes =
exports.all_user_cluster_non_manufacturer_specific_attributes =
all_user_cluster_non_manufacturer_specific_attributes
exports.all_user_cluster_attributes_irrespective_of_manufatucuring_specification =
- all_user_cluster_attributes_irrespective_of_manufatucuring_specification
+ enabled_attributes_for_cluster_and_side
+exports.all_user_cluster_attributes_irrespective_of_manufatucuring_specification =
+ dep(enabled_attributes_for_cluster_and_side, {
+ from: 'all_user_cluster_attributes_irrespective_of_manufatucuring_specification',
+ to: 'enabled_attributes_for_cluster_and_side',
+ })
+exports.enabled_attributes_for_cluster_and_side =
+ enabled_attributes_for_cluster_and_side
+
exports.all_user_cluster_attributes_for_generated_defaults =
all_user_cluster_attributes_for_generated_defaults
exports.all_user_cluster_generated_attributes =
diff --git a/src-electron/generator/helper-zcl.js b/src-electron/generator/helper-zcl.js
index 471a68b4cd..364cf14234 100644
--- a/src-electron/generator/helper-zcl.js
+++ b/src-electron/generator/helper-zcl.js
@@ -730,33 +730,39 @@ function zcl_attributes_client(options) {
* Iterator over the server attributes. If it is used at toplevel, if iterates over all the server attributes
* in the database. If used within zcl_cluster context, it iterates over all the server attributes
* that belong to that cluster.
- *
+ * Available Options:
+ * - removeKeys: Removes one or more keys from the map(for eg keys in db-mapping.js)
+ * for eg: (#zcl_attributes_server removeKeys='isOptional, isNullable') will remove 'isOptional'
+ * from the results
* @param {*} options
* @returns Promise of attribute iteration.
*/
-function zcl_attributes_server(options) {
+async function zcl_attributes_server(options) {
// If used at the toplevel, 'this' is the toplevel context object.
// when used at the cluster level, 'this' is a cluster
- let promise = templateUtil
- .ensureZclPackageIds(this)
- .then((packageIds) => {
- if ('id' in this) {
- // We're functioning inside a nested context with an id, so we will only query for this cluster.
- return queryZcl.selectAttributesByClusterIdAndSideIncludingGlobal(
- this.global.db,
- this.id,
- packageIds,
- dbEnum.side.server
- )
- } else {
- return queryZcl.selectAllAttributesBySide(
- this.global.db,
- dbEnum.side.server,
- packageIds
- )
- }
- })
- .then((atts) => templateUtil.collectBlocks(atts, options, this))
+ let packageIds = await templateUtil.ensureZclPackageIds(this)
+ let serverAttributes = ''
+ if ('id' in this) {
+ // We're functioning inside a nested context with an id, so we will only query for this cluster.
+ serverAttributes =
+ await queryZcl.selectAttributesByClusterIdAndSideIncludingGlobal(
+ this.global.db,
+ this.id,
+ packageIds,
+ dbEnum.side.server
+ )
+ } else {
+ serverAttributes = await queryZcl.selectAllAttributesBySide(
+ this.global.db,
+ dbEnum.side.server,
+ packageIds
+ )
+ }
+ if ('removeKeys' in options.hash) {
+ let keys = options.hash.removeKeys.split(',')
+ keys.forEach((k) => serverAttributes.map((attr) => delete attr[k.trim()]))
+ }
+ let promise = templateUtil.collectBlocks(serverAttributes, options, this)
return templateUtil.templatePromise(this.global, promise)
}
@@ -2693,6 +2699,88 @@ function if_compare(leftValue, rightValue, options) {
}
}
+/**
+ * Check if the given type is signed or not based on the type name and cluster
+ * id.
+ * Note: This helper needs to be used under a block helper which has a
+ * reference to clusterId.
+ * @param {*} type
+ * @param {*} clusterId
+ * @param {*} options
+ * @returns Promise of content
+ */
+async function if_is_data_type_signed(type, clusterId, options) {
+ // Get ZCL Data Type from the db
+ const packageIds = await templateUtil.ensureZclPackageIds(this)
+ let dataType = await queryZcl.selectDataTypeByNameAndClusterId(
+ this.global.db,
+ type,
+ clusterId,
+ packageIds
+ )
+
+ let sizeAndSign = await zclUtil.zcl_data_type_size_and_sign(
+ type,
+ dataType,
+ clusterId,
+ packageIds,
+ this
+ )
+ if (sizeAndSign.isSigned) {
+ return options.fn(this)
+ } else {
+ return options.inverse(this)
+ }
+}
+
+/**
+ * Fetches the size of the data type based on type name and cluster id given
+ * Note:
+ * - Size is zero for structs
+ * - This helper needs to be used under a block helper which has a
+ * reference to clusterId.
+ * Available Options:
+ * - roundUpToPowerOfTwo: Rounds the size up to the nearest power of 2
+ * - sizeIn: By default size is returned in bytes but it can be returned in bits
+ * by mentioning sizeIn="bits"
+ * @param {*} type
+ * @param {*} clusterId
+ * @param {*} options
+ * @returns size of the data type
+ */
+async function as_zcl_data_type_size(type, clusterId, options) {
+ let hash = options.hash
+ let sizeMultiple = 1
+ let result = 0
+ if (hash && hash.sizeIn == 'bits') {
+ sizeMultiple = 8
+ }
+
+ // Get ZCL Data Type from the db
+ const packageIds = await templateUtil.ensureZclPackageIds(this)
+ let dataType = await queryZcl.selectDataTypeByNameAndClusterId(
+ this.global.db,
+ type,
+ clusterId,
+ packageIds
+ )
+
+ let sizeAndSign = await zclUtil.zcl_data_type_size_and_sign(
+ type,
+ dataType,
+ clusterId,
+ packageIds,
+ this
+ )
+ result = sizeAndSign.size
+ result =
+ hash && hash.roundUpToPowerOfTwo
+ ? Math.pow(2, Math.ceil(Math.log2(result)))
+ : result
+
+ return result * sizeMultiple
+}
+
const dep = templateUtil.deprecatedHelper
// WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
@@ -2864,3 +2952,5 @@ exports.as_type_max_value = as_type_max_value
exports.as_type_min_value = as_type_min_value
exports.as_zcl_type_size = as_zcl_type_size
exports.if_compare = if_compare
+exports.if_is_data_type_signed = if_is_data_type_signed
+exports.as_zcl_data_type_size = as_zcl_data_type_size
diff --git a/src-electron/generator/matter/app/zap-templates/templates/chip/helper.js b/src-electron/generator/matter/app/zap-templates/templates/chip/helper.js
index 493d726b58..19f3db722c 100644
--- a/src-electron/generator/matter/app/zap-templates/templates/chip/helper.js
+++ b/src-electron/generator/matter/app/zap-templates/templates/chip/helper.js
@@ -745,6 +745,8 @@ async function chip_access_elements(options) {
return templateUtil.templatePromise(this.global, p);
}
+const dep = templateUtil.deprecatedHelper;
+
//
// Module exports
//
@@ -762,7 +764,12 @@ exports.chip_server_global_responses = chip_server_global_responses;
exports.chip_cluster_responses = chip_cluster_responses;
exports.chip_cluster_response_arguments = chip_cluster_response_arguments;
exports.chip_attribute_list_entryTypes = chip_attribute_list_entryTypes;
-exports.chip_server_cluster_attributes = chip_server_cluster_attributes;
+exports.chip_server_cluster_attributes = dep(
+ chip_server_cluster_attributes,
+ 'chip_server_cluster_attributes has been deprecated. Use \
+ enabled_attributes_for_cluster_and_side and \
+ zcl_attributes_server to get enabled and all server attributes respectively'
+);
exports.chip_server_cluster_events = chip_server_cluster_events;
exports.chip_server_has_list_attributes = chip_server_has_list_attributes;
exports.chip_server_has_reportable_attributes =
@@ -772,7 +779,9 @@ exports.chip_endpoints = chip_endpoints;
exports.chip_endpoint_clusters = chip_endpoint_clusters;
exports.if_chip_enum = if_chip_enum;
exports.if_chip_complex = if_chip_complex;
-exports.if_basic_global_response = if_basic_global_response;
+exports.if_basic_global_response = dep(if_basic_global_response, {
+ to: 'if_basic_attribute',
+});
exports.chip_cluster_specific_structs = chip_cluster_specific_structs;
exports.chip_shared_structs = chip_shared_structs;
exports.chip_access_elements = chip_access_elements;
diff --git a/src-electron/generator/matter/controller/java/templates/helper.js b/src-electron/generator/matter/controller/java/templates/helper.js
index f2db53d41f..66c2fed741 100644
--- a/src-electron/generator/matter/controller/java/templates/helper.js
+++ b/src-electron/generator/matter/controller/java/templates/helper.js
@@ -23,6 +23,11 @@ const ChipTypesHelper = require('../../../app/zap-templates/common/ChipTypesHelp
const StringHelper = require('../../../app/zap-templates/common/StringHelper.js');
const appHelper = require('../../../app/zap-templates/templates/app/helper.js');
const dbEnum = require('../../../../../../src-shared/db-enum');
+const queryZcl = require(zapPath + 'db/query-zcl');
+const zclUtil = require(zapPath + 'util/zcl-util.js');
+
+const characterStringTypes = ['CHAR_STRING', 'LONG_CHAR_STRING'];
+const octetStringTypes = ['OCTET_STRING', 'LONG_OCTET_STRING'];
function convertBasicCTypeToJavaType(cType) {
switch (cType) {
@@ -187,6 +192,82 @@ function convertAttributeCallbackTypeToJavaName(cType) {
}
}
+/**
+ * Note: This helper needs to be used under a block helper which has a
+ * reference to clusterId.
+ * Available options:
+ * - isBoxedJavaType: 0/1 to return string types in different ways
+ * - All other options passed to this helper are considered as overrides for
+ * zcl types
+ * for eg: (as_underlying_java_zcl_type type clusterId boolean='Boolean')
+ * will return "Boolean" for "boolean" type
+ * @param {*} type
+ * @param {*} clusterId
+ * @param {*} options
+ * @returns The corresponding java data type for a zcl data type.
+ */
+async function as_underlying_java_zcl_type(type, clusterId, options) {
+ let hash = options.hash;
+ // Overwrite any type with the one coming from the template options
+ // Eg: {{as_underlying_java_zcl_type type [clusterId] boolean='Boolean'}}
+ // Here all types named 'boolean' will be returned as 'Boolean'
+ if (type in hash) {
+ return hash[type];
+ }
+
+ // Get ZCL Data Type from the db
+ const packageIds = await templateUtil.ensureZclPackageIds(this);
+ let dataType = await queryZcl.selectDataTypeByNameAndClusterId(
+ this.global.db,
+ type,
+ clusterId,
+ packageIds
+ );
+
+ if (!dataType) {
+ env.logWarning(type + ' not found in the data_type table');
+ return 0;
+ }
+ let isBoxedJavaType =
+ hash && hash.isBoxedJavaType ? hash.isBoxedJavaType : false;
+ if (
+ dataType.discriminatorName.toLowerCase() == dbEnum.zclType.bitmap ||
+ dataType.discriminatorName.toLowerCase() == dbEnum.zclType.enum ||
+ dataType.discriminatorName.toLowerCase() == dbEnum.zclType.number
+ ) {
+ if (dataType.name.includes('float')) {
+ return 'Float';
+ } else if (dataType.name.includes('double')) {
+ return 'Double';
+ } else if (dataType.name.includes('single')) {
+ return 'Float';
+ } else {
+ let sizeAndSign = await zclUtil.zcl_data_type_size_and_sign(
+ type,
+ dataType,
+ clusterId,
+ packageIds,
+ this
+ );
+ if (sizeAndSign.size >= 3) {
+ return 'Long';
+ }
+ }
+ return 'Integer';
+ } else if (octetStringTypes.includes(type.toUpperCase())) {
+ return isBoxedJavaType ? 'byte[]' : 'OctetString';
+ } else if (characterStringTypes.includes(type.toUpperCase())) {
+ return isBoxedJavaType ? 'String' : 'CharString';
+ } else {
+ let error = 'Unhandled type ' + type;
+ if (isBoxedJavaType) {
+ return 'Object';
+ } else {
+ throw error;
+ }
+ }
+}
+
async function asUnderlyingBasicType(type) {
const options = { hash: {} };
let zclType = await zclHelper.asUnderlyingZclType.call(this, type, options);
@@ -342,12 +423,92 @@ function incrementDepth(depth) {
return depth + 1;
}
+/**
+ * If helper that checks if an attribute is basic or not based for java code
+ * generation
+ * For eg: In java, an attribute is not basic if it is either nullable, optional,
+ * array type or struct.
+ * Note: This helper should be used within an attribute block helper and also
+ * needs to be used under a block helper which has a reference to clusterId.
+ * example:
+ * {{#if_basic_attribute type}}
+ * type is basic
+ * {{else}}
+ * type is not basic
+ * {{/if_basic_attribute}}
+ * @param {*} type
+ * @param {*} clusterId
+ * @param {*} options
+ * @returns Promise of content
+ */
+async function if_basic_attribute(type, clusterId, options) {
+ let struct = null;
+ if (this.isNullable || this.isOptional || this.isArray) {
+ return options.inverse(this);
+ } else {
+ let packageIds = await templateUtil.ensureZclPackageIds(this);
+ struct = await queryZcl.selectStructByNameAndClusterId(
+ this.global.db,
+ type,
+ clusterId,
+ packageIds
+ );
+ if (struct) {
+ return options.inverse(this);
+ } else {
+ return options.fn(this);
+ }
+ }
+}
+
+/**
+ * If helper that checks if an attribute is not supported for java code
+ * generation
+ * Note: This helper needs to be used under a block helper which has a
+ * reference to clusterId.
+ * For eg: In java, an attribute callback is not supported when it is a struct.
+ * However it is supported if it is an array of structs.
+ * @param {*} type
+ * @param {*} isArray
+ * @param {*} clusterId
+ * @param {*} options
+ * @returns Promise of content
+ */
+async function if_unsupported_attribute_callback(
+ type,
+ isArray,
+ clusterId,
+ options
+) {
+ let struct = null;
+ if (isArray) {
+ return options.inverse(this);
+ } else {
+ let packageIds = await templateUtil.ensureZclPackageIds(this);
+ struct = await queryZcl.selectStructByNameAndClusterId(
+ this.global.db,
+ type,
+ clusterId,
+ packageIds
+ );
+ if (struct) {
+ return options.fn(this);
+ } else {
+ return options.inverse(this);
+ }
+ }
+}
+
+const dep = templateUtil.deprecatedHelper;
+
//
// Module exports
//
exports.asUnderlyingBasicType = asUnderlyingBasicType;
exports.asJavaType = asJavaType;
-exports.asJavaBoxedType = asJavaBoxedType;
+exports.asJavaBoxedType = dep(asJavaBoxedType, {
+ to: 'as_underlying_java_zcl_type',
+});
exports.asJniType = asJniType;
exports.asJniSignature = asJniSignature;
exports.asJniClassName = asJniClassName;
@@ -356,11 +517,16 @@ exports.asJniSignatureBasic = asJniSignatureBasic;
exports.convertBasicCTypeToJniType = convertBasicCTypeToJniType;
exports.convertCTypeToJniSignature = convertCTypeToJniSignature;
exports.convertBasicCTypeToJavaBoxedType = convertBasicCTypeToJavaBoxedType;
-exports.convertAttributeCallbackTypeToJavaName =
- convertAttributeCallbackTypeToJavaName;
+exports.convertAttributeCallbackTypeToJavaName = dep(
+ convertAttributeCallbackTypeToJavaName,
+ { to: 'as_underlying_java_zcl_type' }
+);
exports.incrementDepth = incrementDepth;
exports.meta = {
category: dbEnum.helperCategory.matter,
alias: ['controller/java/templates/helper.js', 'matter-java-helper'],
};
+exports.as_underlying_java_zcl_type = as_underlying_java_zcl_type;
+exports.if_basic_attribute = if_basic_attribute;
+exports.if_unsupported_attribute_callback = if_unsupported_attribute_callback;
diff --git a/src-electron/generator/matter/controller/python/templates/helper.js b/src-electron/generator/matter/controller/python/templates/helper.js
index 5d0ddead17..1b06f53d8c 100644
--- a/src-electron/generator/matter/controller/python/templates/helper.js
+++ b/src-electron/generator/matter/controller/python/templates/helper.js
@@ -16,8 +16,14 @@
*/
// Import helpers from zap core
+const zapPath = '../../../../../';
const dbEnum = require('../../../../../../src-shared/db-enum');
const ChipTypesHelper = require('../../../app/zap-templates/common/ChipTypesHelper');
+const templateUtil = require(zapPath + 'generator/template-util.js');
+const queryZcl = require(zapPath + 'db/query-zcl');
+
+const characterStringTypes = ['CHAR_STRING', 'LONG_CHAR_STRING'];
+const octetStringTypes = ['OCTET_STRING', 'LONG_OCTET_STRING'];
function asPythonType(zclType) {
const type = ChipTypesHelper.asBasicType(zclType);
@@ -43,6 +49,63 @@ function asPythonType(zclType) {
}
}
+/**
+ * Note: This helper needs to be used under a block helper which has a
+ * reference to clusterId.
+ * Available options:
+ * - All options passed to this helper are considered as overrides for
+ * zcl types
+ * for eg: (as_underlying_python_zcl_type type clusterId SomeType='Stype')
+ * will return "Stype" for "SomeType" type
+ * @param {*} type
+ * @param {*} clusterId
+ * @param {*} options
+ * @returns The corresponding python data type for a zcl data type.
+ */
+async function as_underlying_python_zcl_type(type, clusterId, options) {
+ let hash = options.hash;
+ // Overwrite any type with the one coming from the template options
+ // Eg: {{as_underlying_python_zcl_type type [clusterId] SomeType='Stype'}}
+ // Here all types named 'SomeType' will be returned as 'Stype'
+ if (type in hash) {
+ return hash[type];
+ }
+
+ // Get ZCL Data Type from the db
+ const packageIds = await templateUtil.ensureZclPackageIds(this);
+ let dataType = await queryZcl.selectDataTypeByNameAndClusterId(
+ this.global.db,
+ type,
+ clusterId,
+ packageIds
+ );
+ if (type == 'boolean') {
+ return 'bool';
+ } else if (
+ dataType.discriminatorName.toLowerCase() == dbEnum.zclType.bitmap ||
+ dataType.discriminatorName.toLowerCase() == dbEnum.zclType.enum ||
+ dataType.discriminatorName.toLowerCase() == dbEnum.zclType.number
+ ) {
+ // Do not know on why this is the case but returning nothing for floats
+ // and this is done for compatibility with asPythonType.
+ // Issue: https://github.com/project-chip/connectedhomeip/issues/25718
+ if (
+ dataType.name.includes('float') ||
+ dataType.name.includes('double') ||
+ dataType.name.includes('single')
+ ) {
+ return '';
+ }
+ return 'int';
+ } else if (octetStringTypes.includes(type.toUpperCase())) {
+ return 'bytes';
+ } else if (characterStringTypes.includes(type.toUpperCase())) {
+ return 'str';
+ } else {
+ return '';
+ }
+}
+
function asPythonCType(zclType) {
const type = ChipTypesHelper.asBasicType(zclType);
switch (type) {
@@ -62,13 +125,18 @@ function asPythonCType(zclType) {
}
}
+const dep = templateUtil.deprecatedHelper;
+
//
// Module exports
//
-exports.asPythonType = asPythonType;
+exports.asPythonType = dep(asPythonType, {
+ to: 'as_underlying_python_zcl_type',
+});
exports.asPythonCType = asPythonCType;
exports.meta = {
category: dbEnum.helperCategory.matter,
alias: ['controller/python/templates/helper.js', 'matter-python-helper'],
};
+exports.as_underlying_python_zcl_type = as_underlying_python_zcl_type;
diff --git a/src-electron/util/zcl-util.js b/src-electron/util/zcl-util.js
index 64b38c70f7..6330643f6a 100644
--- a/src-electron/util/zcl-util.js
+++ b/src-electron/util/zcl-util.js
@@ -797,6 +797,57 @@ async function createCommandSignature(db, packageId, cmd) {
}
}
+/**
+ *
+ * @param {*} type
+ * @param {*} dataType
+ * @param {*} clusterId
+ * @param {*} packageIds
+ * @param {*} context
+ * @returns The size and sign of a zcl data type
+ */
+async function zcl_data_type_size_and_sign(
+ type,
+ dataType,
+ clusterId,
+ packageIds,
+ context
+) {
+ let result = 0
+ let isSigned = false
+ if (dataType.discriminatorName.toLowerCase() == dbEnum.zclType.bitmap) {
+ let bitmap = await queryZcl.selectBitmapByNameAndClusterId(
+ context.global.db,
+ dataType.name,
+ clusterId,
+ packageIds
+ )
+ result = bitmap.size
+ } else if (dataType.discriminatorName.toLowerCase() == dbEnum.zclType.enum) {
+ let en = await queryZcl.selectEnumByNameAndClusterId(
+ context.global.db,
+ dataType.name,
+ clusterId,
+ packageIds
+ )
+ result = en.size
+ } else if (
+ dataType.discriminatorName.toLowerCase() == dbEnum.zclType.number
+ ) {
+ let number = await queryZcl.selectNumberByNameAndClusterId(
+ context.global.db,
+ dataType.name,
+ clusterId,
+ packageIds
+ )
+ isSigned = number.isSigned
+ result = number.size
+ } else {
+ env.logWarning(type + ' is a complex type and size could not be determined')
+ }
+ return { size: result, isSigned: isSigned }
+}
+
exports.clusterComparator = clusterComparator
exports.attributeComparator = attributeComparator
exports.commandComparator = commandComparator
@@ -811,3 +862,4 @@ exports.determineType = determineType
exports.dataTypeCharacterFormatter = dataTypeCharacterFormatter
exports.calculateBytes = calculateBytes
exports.createCommandSignature = createCommandSignature
+exports.zcl_data_type_size_and_sign = zcl_data_type_size_and_sign
diff --git a/test/gen-matter-4.test.js b/test/gen-matter-4.test.js
index 093c46177d..b906c580a5 100644
--- a/test/gen-matter-4.test.js
+++ b/test/gen-matter-4.test.js
@@ -168,3 +168,95 @@ test(
},
testUtil.timeout.long()
)
+
+test(
+ `Zap testing miscellaneouos type specific helpers: ${path.relative(
+ __dirname,
+ testFile
+ )}`,
+ async () => {
+ let sessionId = await querySession.createBlankSession(db)
+
+ await importJs.importDataFromFile(db, testFile, {
+ sessionId: sessionId,
+ })
+
+ let genResult = await genEngine.generate(
+ db,
+ sessionId,
+ templateContext.packageId,
+ {},
+ { disableDeprecationWarnings: true }
+ )
+ expect(genResult.hasErrors).toEqual(false)
+
+ // Note: A lot of these tests here are for sake of backwards
+ // compatibility. Latest ZAP must be able to generate content for
+ // the old SDKs, so if you changed something that generates
+ // endpoint_config differently, please be very very careful and
+ // make sure you can answer positively the following question:
+ // will after my changes, zap still be able to generate content
+ // that will work with an older SDK.
+ //
+ let ept = genResult.content['miscellaneous_helper_tests.out']
+
+ // Testing if_unsupported_attribute_callback helper
+ expect(ept).toContain(
+ 'attribute callback for OnOff of boolean type is supported in java'
+ )
+ expect(ept).toContain(
+ 'attribute callback for GlobalSceneControl of boolean type is supported in java'
+ )
+ expect(ept).toContain(
+ 'attribute callback for GeneratedCommandList of command_id type is supported in java'
+ )
+
+ // Testing if_basic_attribute helper
+ expect(ept).toContain(
+ 'attribute OnTime of int16u type is basic type in java'
+ )
+ expect(ept).toContain(
+ 'attribute EventList of event_id type is not basic type in java'
+ )
+ expect(ept).toContain(
+ 'attribute StartUpOnOff of OnOffStartUpOnOff type is not basic type in java'
+ )
+
+ // Testing as_underlying_java_zcl_type helper
+ expect(ept).toContain(
+ 'Underlying Java type for attribute OnOff of boolean type: Boolean'
+ )
+ expect(ept).toContain(
+ 'Underlying Java type for attribute OnTime of int16u type: Integer'
+ )
+ expect(ept).toContain(
+ 'Underlying Java type for attribute GeneratedCommandList of command_id type: Long'
+ )
+
+ // Testing as_underlying_python_zcl_type helper
+ expect(ept).toContain(
+ 'Underlying Python type for attribute OnOff of boolean type: bool'
+ )
+ expect(ept).toContain(
+ 'Underlying Python type for attribute OnTime of int16u type: int'
+ )
+ expect(ept).toContain(
+ 'Underlying Python type for attribute GeneratedCommandList of command_id type: int'
+ )
+
+ // Testing if_is_data_type_signed and as_zcl_data_type_size
+ expect(ept).toContain(
+ 'attribute OnOff of type boolean is unsigned. The size of this attribute is: 8 bits'
+ )
+ expect(ept).toContain(
+ 'attribute OnTime of type int16u is unsigned. The size of this attribute is: 16 bits'
+ )
+ expect(ept).toContain(
+ 'attribute StartUpOnOff of type OnOffStartUpOnOff is unsigned. The size of this attribute is: 8 bits'
+ )
+ expect(ept).toContain(
+ 'attribute GeneratedCommandList of type command_id is unsigned. The size of this attribute is: 32 bits'
+ )
+ },
+ testUtil.timeout.long()
+)
diff --git a/test/gen-template/matter3/miscellaneous_helper_tests.zapt b/test/gen-template/matter3/miscellaneous_helper_tests.zapt
new file mode 100644
index 0000000000..452a050384
--- /dev/null
+++ b/test/gen-template/matter3/miscellaneous_helper_tests.zapt
@@ -0,0 +1,22 @@
+{{#chip_client_clusters }}
+ {{#zcl_attributes_server removeKeys='isOptional'}}
+ {{#if_unsupported_attribute_callback type isArray ../id language='java'}}
+attribute callback for {{name}} of {{type}} type is not supported in java
+ {{else}}
+attribute callback for {{name}} of {{type}} type is supported in java
+ {{#if_basic_attribute type ../id language='java'}}
+ attribute {{name}} of {{type}} type is basic type in java
+ {{else}}
+ attribute {{name}} of {{type}} type is not basic type in java
+ {{/if_basic_attribute}}
+ {{/if_unsupported_attribute_callback}}
+Underlying Java type for attribute {{name}} of {{type}} type: {{as_underlying_java_zcl_type type ../id boolean="Boolean"}}
+Underlying Python type for attribute {{name}} of {{type}} type: {{as_underlying_python_zcl_type type ../id boolean="bool" BOOLEAN="bool"}}
+ {{#if_is_data_type_signed type ../id}}
+attribute {{name}} of type {{type}} is signed. The size of this attribute is: {{as_zcl_data_type_size type ../id sizeIn='bits' roundUpToPowerOfTwo=1}} bits
+ {{else}}
+attribute {{name}} of type {{type}} is unsigned. The size of this attribute is: {{as_zcl_data_type_size type ../id sizeIn='bits' roundUpToPowerOfTwo=1}} bits
+ {{/if_is_data_type_signed}}
+
+ {{/zcl_attributes_server}}
+{{/chip_client_clusters}}
\ No newline at end of file
diff --git a/test/gen-template/matter3/t.json b/test/gen-template/matter3/t.json
index 46d0858bd5..2ceb05887b 100644
--- a/test/gen-template/matter3/t.json
+++ b/test/gen-template/matter3/t.json
@@ -129,6 +129,11 @@
"path": "endpoint_config.zapt",
"name": "Endpoint Config",
"output": "endpoint_config.h"
+ },
+ {
+ "path": "miscellaneous_helper_tests.zapt",
+ "name": "miscellaneous helper",
+ "output": "miscellaneous_helper_tests.out"
}
]
}
diff --git a/test/test-util.js b/test/test-util.js
index 749e353c77..1f8aa54b6f 100644
--- a/test/test-util.js
+++ b/test/test-util.js
@@ -86,7 +86,7 @@ exports.testTemplate = {
matter2: './test/gen-template/matter2/templates.json',
matter2Count: 1,
matter3: './test/gen-template/matter3/t.json',
- matter3Count: 17,
+ matter3Count: 18,
dotdot: './test/gen-template/dotdot/dotdot-templates.json',
dotdotCount: 5,
unittest: './test/gen-template/test/gen-test.json',