Skip to content

Latest commit

 

History

History
3688 lines (2558 loc) · 140 KB

api.md

File metadata and controls

3688 lines (2558 loc) · 140 KB

Modules

DB API: DB types and enums.

This module provides mappings between database columns and JS keys.

JS API: low level database access

This module provides generic DB functions for performing SQL queries.

DB API: DB mappings between columns and JS object keys.

This module provides mappings between database columns and JS keys.

DB API: user configuration queries against the database.

This module provides queries for user configuration.

DB API: generic queries against the database.

This module provides generic queries.

DB API: package-based queries.

This module provides queries related to imports and exports of files.

DB API: package-based queries.

This module provides queries related to packages.

DB API: session related queries.

This module provides session related queries.

DB API: zcl database access

This module provides queries for ZCL static queries.

JS API: generator logic
Templating API: C formatting helpers

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

Templating API: user-data specific helpers

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

Templating API: toplevel utility helpers

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

Templating API: static zcl helpers

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

JS API: generator logic
JS API: generator logic
REST API: admin functions

This module provides the REST API to the admin functions.

REST API: generation functions

This module provides the REST API to the generation.

REST API: static zcl functions

This module provides the REST API to the static zcl queries.

REST API: generation functions

This module provides the REST API to the generation.

REST API: user data

This module provides the REST API to the user specific data.

JS API: http server

This module provides the HTTP server functionality.

JS API: random utilities

Constants

replyId

Copyright (c) 2020 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.

queryZcl

Copyright (c) 2020 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.

templateUtil

Copyright (c) 2020 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.

queryZcl

Copyright (c) 2020 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.

queryPackage

Copyright (c) 2020 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.

env

This file is used specifically and only for development. It installs electron-debug & vue-devtools. There shouldn't be any need to modify this file, but it can be used to extend your development environment.

dbApi

Copyright (c) 2020 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.

axios

This module provides the API to Studio's Jetty server.

yargs

Copyright (c) 2020 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.

path

Copyright (c) 2020 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.

queryZcl

This module provides the APIs for validating inputs to the database, and returning flags indicating if things were successful or not.

fs

Copyright (c) 2020 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.

fs

Copyright (c) 2020 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.

Functions

exportSessionKeyValues(db, sessionId)

Resolves to an array of objects that contain 'key' and 'value'

exportEndpoints(db, sessionId)

Resolves to an array of endpoints.

exportEndpointTypes(db, sessionId)

Resolves to an array of endpoint types.

exportSessionPackages(db, sessionId)

Resolves with data for packages.

exportDataIntoFile(db, sessionId, filePath)

Toplevel file that takes a given session ID and exports the data into the file

createStateFromDatabase(db, sessionId)

Given a database and a session id, this method returns a promise that resolves with a state object that needs to be saved into a file.

importSessionKeyValues(db, sessionId, keyValuePairs)

Resolves with a promise that imports session key values.

readDataFromFile(filePath)

Reads the data from the file and resolves with the state object if all is good.

writeStateToDatabase(db, state)

Given a state object, this method returns a promise that resolves with the succesfull writing into the database.

importDataFromFile(db, filePath)

Writes the data from the file into a new session.

doOpen(menuItem, browserWindow, event)

Perform a file->open operation.

doSave(menuItem, browserWindow, event)

Perform a save, defering to save as if file is not yet selected.

doSaveAs(menuItem, browserWindow, event)

Perform save as.

generateInDir(browserWindow)

This function gets the directory where user wants the output and calls generateCode function which generates the code in the user selected output.

setHandlebarTemplateDirectory(browserWindow)

This function gets the directory where user wants the output and calls generateCode function which generates the code in the user selected output.

fileSave(db, winId, filePath)

perform the save.

fileOpen(db, winId, filePaths)

Perform the do open action, possibly reading in multiple files.

readAndProcessFile(db, filePath)

Process a single file, parsing it in as JSON and then possibly opening a new window if all is good.

initMenu(port)

Initialize a menu.

createOrShowWindow(port)

Call this function to create a new or show an existing preference window.

startNormal(uiEnabled, showUrl, uiMode)

Start up application in a normal mode.

startSelfCheck()

Start up application in self-check mode.

startGeneration(output, genTemplateJsonFile, zclProperties, [zapFile])

Performs headless regeneration for given parameters.

clearDatabaseFile()

Moves the main database file into a backup location.

windowCreate(port, [filePath], [sessionId])

Create a window, possibly with a given file path and with a desire to attach to a given sessionId

Win id will be passed on in the URL, and if sessionId is present, so will it.

processCommandLineArguments(argv)

Process the command line arguments and resets the state in this file to the specified values.

int8ToHex(value)

Takes an int8 value and turns it into a hex.

int16ToHex(value)

Takes an int16 value and turns it into a hex.

int32ToHex(value)

Takes an int8 value and turns it into a hex.

stringToHex(value)

Converts a string to the hex value.

hexToCBytes(value)

Takes the raw hex string, such as abcd and converts it into a C constant array, such as 0xAB, 0xCD.

bitOffset(binary)

Getting a binary string ("0001101010010") it returns the number of zero bits at the end.

hexToBinary(hex)

Convert a hex number to a binary. Hex has to be in a format as obtained by intToHex methods above: no '0x' prefix and upper-case letters, as in "12AB".

collectData(ctx)

Promises to read the properties file, extract all the actual xml files, and resolve with the array of files.

parseZclFiles(db, ctx)

Promises to iterate over all the XML files and returns an aggregate promise that will be resolved when all the XML files are done, or rejected if at least one fails.

normalizeHexValue(value)

The Dotdot ZCL XML doesn't use the 0x prefix, but it's a nice thing to have and Silabs xml does use this so this helper function normalizes the use of hex

TODO: Is this the right thing to do?

prepareAttributes(attributes, side)

Prepare XML attributes for entry into the DB

prepareCommands(commands, side)

Prepare XML commands for entry into the DB

prepareCluster(cluster, isExtension, types)

Prepare XML cluster for insertion into the database. This method can also prepare clusterExtensions.

prepareAtomic(type)

Parses xml type into the atomic object for insertion into the DB

prepareBitmap(type, fromAttribute)

Parses xml type into the bitmap object for insertion into the DB

prepareEnum(type)

Parses xml type into the enum object for insertion into the DB

prepareStruct(type)

Parses xml type into the struct object for insertion into the DB

prepareTypes(zclTypes, types)

Parses xml types into the types object for insertion into the DB

prepareAttributeType(attribute, types, cluster)

Parses xml types into the types object for insertion into the DB

prepareDeviceType(deviceType)

Preparation step for the device types.

loadZclData(db, ctx)

Promises to iterate over all the XML files and returns an aggregate promise that will be resolved when all the XML files are done, or rejected if at least one fails.

loadDotdotZcl(db, ctx)

Toplevel function that loads the xml library file and orchestrates the promise chain.

readMetadataFile(ctx)

Reads the properties file into ctx.data and also calculates crc into ctx.crc

recordToplevelPackage(ctx)

Records the toplevel package information and puts ctx.packageId into the context.

recordVersion(db, ctx)

Records the version into the database.

loadZcl(db, metadataFile)

Toplevel function that loads the zcl file and passes it off to the correct zcl loader.

processZclPostLoading(db)

Promises to perform a post loading step.

collectDataFromJsonFile(ctx)

Promises to read the JSON file and resolve all the data.

collectDataFromPropertiesFile(ctx)

Promises to read the properties file, extract all the actual xml files, and resolve with the array of files.

readZclFile(file)

Promises to read a file and resolve with the content

parseZclFile(argument)

Promises to parse the ZCL file, expecting object of { filePath, data, packageId, msg }

prepareBitmap(bm)

Prepare bitmap for database insertion.

processBitmaps(db, filePath, packageId, data)

Processes bitmaps for DB insertion.

prepareAtomic(a)

Prepare atomic to db insertion.

processAtomics(db, filePath, packageId, data)

Processes atomic types for DB insertion.

prepareCluster(cluster)

Prepare XML cluster for insertion into the database. This method can also prepare clusterExtensions.

processClusters(db, filePath, packageId, data)

Process clusters for insertion into the database.

processClusterExtensions(db, filePath, packageId, data)

Cluster Extension contains attributes and commands in a same way as regular cluster, and it has an attribute code="0xXYZ" where code is a cluster code.

processGlobals(db, filePath, packageId, data)

Processes the globals in the XML files. The global tag contains attributes and commands in a same way as cluster or clusterExtension

prepareDomain(domain)

Convert domain from XMl to domain for DB.

processDomains(db, filePath, packageId, data)

Process domains for insertion.

prepareStruct(struct)

Prepares structs for the insertion into the database.

processStructs(db, filePath, packageId, data)

Processes structs.

prepareEnum(en)

Prepares an enum for insertion into the database.

processEnums(db, filePath, packageId, data)

Processes the enums.

prepareDeviceType(deviceType)

Preparation step for the device types.

processDeviceTypes(db, filePath, packageId, data)

Process all device types.

processParsedZclData(db, argument)

After XML parser is done with the barebones parsing, this function branches the individual toplevel tags.

resolveLaterPromises(laterPromises)

Resolve later promises. This function resolves the later promises associated with processParsedZclData.

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}

parseZclFiles(db, ctx)

Promises to iterate over all the XML files and returns an aggregate promise that will be resolved when all the XML files are done, or rejected if at least one fails.

loadSilabsZcl(db, ctx)

Toplevel function that loads the properties file and orchestrates the promise chain.

DB API: DB types and enums.

This module provides mappings between database columns and JS keys.

JS API: low level database access

This module provides generic DB functions for performing SQL queries.

  • [JS API: low level database access](#moduleJS API low level database access)
    • [~dbBeginTransaction(db)](#moduleJS API low level database access..dbBeginTransaction) ⇒
    • [~dbCommit(db)](#moduleJS API low level database access..dbCommit) ⇒
    • [~dbRemove(db, query, args)](#moduleJS API low level database access..dbRemove) ⇒
    • [~dbUpdate(db, query, args)](#moduleJS API low level database access..dbUpdate) ⇒
    • [~dbInsert(db, query, args)](#moduleJS API low level database access..dbInsert) ⇒
    • [~dbAll(db, query, args)](#moduleJS API low level database access..dbAll) ⇒
    • [~dbGet(db, query, args)](#moduleJS API low level database access..dbGet) ⇒
    • [~dbMultiSelect(db, sql, arrayOfArrays)](#moduleJS API low level database access..dbMultiSelect)
    • [~dbMultiInsert(db, sql, arrayOfArrays)](#moduleJS API low level database access..dbMultiInsert) ⇒
    • [~closeDatabase(database)](#moduleJS API low level database access..closeDatabase) ⇒
    • [~initDatabase(sqlitePath)](#moduleJS API low level database access..initDatabase) ⇒
    • [~insertOrReplaceSetting(db, version)](#moduleJS API low level database access..insertOrReplaceSetting) ⇒
    • [~loadSchema(db, schemaPath, appVersion)](#moduleJS API low level database access..loadSchema) ⇒

JS API: low level database access~dbBeginTransaction(db) ⇒

Returns a promise to begin a transaction

Kind: inner method of [JS API: low level database access](#moduleJS API low level database access)
Returns: A promise that resolves without an argument and rejects with an error from BEGIN TRANSACTION query.

Param Type
db *

JS API: low level database access~dbCommit(db) ⇒

Returns a promise to execute a commit.

Kind: inner method of [JS API: low level database access](#moduleJS API low level database access)
Returns: A promise that resolves without an argument or rejects with an error from COMMIT query.

Param Type
db *

JS API: low level database access~dbRemove(db, query, args) ⇒

Returns a promise to execute a DELETE FROM query.

Kind: inner method of [JS API: low level database access](#moduleJS API low level database access)
Returns: A promise that resolve with the number of delete rows, or rejects with an error from query.

Param Type
db *
query *
args *

JS API: low level database access~dbUpdate(db, query, args) ⇒

Returns a promise to execute an update query.

Kind: inner method of [JS API: low level database access](#moduleJS API low level database access)
Returns: A promise that resolves without an argument, or rejects with an error from the query.

Param Type
db *
query *
args *

JS API: low level database access~dbInsert(db, query, args) ⇒

Returns a promise to execute an insert query.

Kind: inner method of [JS API: low level database access](#moduleJS API low level database access)
Returns: A promise that resolves with the rowid from the inserted row, or rejects with an error from the query.

Param Type
db *
query *
args *

JS API: low level database access~dbAll(db, query, args) ⇒

Returns a promise to execute a query to perform a select that returns all rows that match a query.

Kind: inner method of [JS API: low level database access](#moduleJS API low level database access)
Returns: A promise that resolves with the rows that got retrieved from the database, or rejects with an error from the query.

Param Type
db *
query *
args *

JS API: low level database access~dbGet(db, query, args) ⇒

Returns a promise to execute a query to perform a select that returns first row that matches a query.

Kind: inner method of [JS API: low level database access](#moduleJS API low level database access)
Returns: A promise that resolves with a single row that got retrieved from the database, or rejects with an error from the query.

Param Type
db *
query *
args *

JS API: low level database access~dbMultiSelect(db, sql, arrayOfArrays)

Returns a promise to perform a prepared statement, using data from array for SQL parameters. It resolves with an array of rows, containing the data, or rejects with an error.

Kind: inner method of [JS API: low level database access](#moduleJS API low level database access)

Param Type
db *
sql *
arrayOfArrays *

JS API: low level database access~dbMultiInsert(db, sql, arrayOfArrays) ⇒

Returns a promise to perfom a prepared statement, using data from array for SQL parameters. It resolves with an array of rowids, or rejects with an error.

Kind: inner method of [JS API: low level database access](#moduleJS API low level database access)
Returns: A promise that resolves with the array of rowids for the rows that got inserted, or rejects with an error from the query.

Param Type
db *
sql *
arrayOfArrays *

JS API: low level database access~closeDatabase(database) ⇒

Returns a promise that will resolve when the database in question is closed. Rejects with an error if closing fails.

Kind: inner method of [JS API: low level database access](#moduleJS API low level database access)
Returns: A promise that resolves without an argument or rejects with error from the database closing.

Param Type
database *

JS API: low level database access~initDatabase(sqlitePath) ⇒

Returns a promise to initialize a database.

Kind: inner method of [JS API: low level database access](#moduleJS API low level database access)
Returns: A promise that resolves with the database object that got created, or rejects with an error if something went wrong.

Param Type
sqlitePath *

JS API: low level database access~insertOrReplaceSetting(db, version) ⇒

Returns a promise to insert or replace a setting into the database.

Kind: inner method of [JS API: low level database access](#moduleJS API low level database access)
Returns: A promise that resolves with a rowid of created setting row or rejects with error if something goes wrong.

Param Type
db *
version *

JS API: low level database access~loadSchema(db, schemaPath, appVersion) ⇒

Returns a promise to load schema into a blank database, and inserts a version to the settings table.j

Kind: inner method of [JS API: low level database access](#moduleJS API low level database access)
Returns: A promise that resolves with the same db that got passed in, or rejects with an error.

Param Type
db *
schemaPath *
appVersion *

DB API: DB mappings between columns and JS object keys.

This module provides mappings between database columns and JS keys.

DB API: user configuration queries against the database.

This module provides queries for user configuration.

DB API: generic queries against the database.

This module provides generic queries.

DB API: package-based queries.

This module provides queries related to imports and exports of files.

DB API: package-based queries.

This module provides queries related to packages.

DB API: session related queries.

This module provides session related queries.

DB API: zcl database access

This module provides queries for ZCL static queries.

  • [DB API: zcl database access](#moduleDB API zcl database access)
    • [~selectAllEnums(db)](#moduleDB API zcl database access..selectAllEnums) ⇒
    • [~selectAllBitmaps(db)](#moduleDB API zcl database access..selectAllBitmaps) ⇒
    • [~selectAllDomains(db)](#moduleDB API zcl database access..selectAllDomains) ⇒
    • [~selectAllStructs(db)](#moduleDB API zcl database access..selectAllStructs) ⇒
    • [~selectAllClusters(db)](#moduleDB API zcl database access..selectAllClusters) ⇒
    • [~selectAllDeviceTypes(db)](#moduleDB API zcl database access..selectAllDeviceTypes) ⇒
    • [~insertGlobals(db, packageId, data)](#moduleDB API zcl database access..insertGlobals) ⇒
    • [~insertClusterExtensions(db, packageId, data)](#moduleDB API zcl database access..insertClusterExtensions) ⇒
    • [~insertClusters(db, packageId, data)](#moduleDB API zcl database access..insertClusters) ⇒
    • [~insertDeviceTypes(db, packageId, data)](#moduleDB API zcl database access..insertDeviceTypes) ⇒
    • [~insertDeviceTypeAttributes(db, dtClusterRefDataPairs)](#moduleDB API zcl database access..insertDeviceTypeAttributes)
    • [~insertDeviceTypeCommands(db, dtClusterRefDataPairs)](#moduleDB API zcl database access..insertDeviceTypeCommands)
    • [~insertDomains(db, packageId, data)](#moduleDB API zcl database access..insertDomains) ⇒
    • [~insertStructs(db, packageId, data)](#moduleDB API zcl database access..insertStructs) ⇒
    • [~insertEnums(db, packageId, data)](#moduleDB API zcl database access..insertEnums) ⇒
    • [~insertAtomics(db, packageId, data)](#moduleDB API zcl database access..insertAtomics)
    • [~selectAtomicType(db, packageId, typeName)](#moduleDB API zcl database access..selectAtomicType)
    • [~selectAllAtomics(db, packageId)](#moduleDB API zcl database access..selectAllAtomics)
    • [~getAtomicSizeFromType(db, packageId, type)](#moduleDB API zcl database access..getAtomicSizeFromType)
    • [~insertBitmaps(db, packageId, data)](#moduleDB API zcl database access..insertBitmaps) ⇒

DB API: zcl database access~selectAllEnums(db) ⇒

Retrieves all the enums in the database.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: Promise that resolves with the rows of enums.

Param Type
db *

DB API: zcl database access~selectAllBitmaps(db) ⇒

Retrieves all the bitmaps in the database.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: Promise that resolves with the rows of bitmaps.

Param Type
db *

DB API: zcl database access~selectAllDomains(db) ⇒

Retrieves all the domains in the database.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: Promise that resolves with the rows of domains.

Param Type
db *

DB API: zcl database access~selectAllStructs(db) ⇒

Retrieves all the structs in the database.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: Promise that resolves with the rows of structs.

Param Type
db *

DB API: zcl database access~selectAllClusters(db) ⇒

Retrieves all the clusters in the database.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: Promise that resolves with the rows of clusters.

Param Type
db *

DB API: zcl database access~selectAllDeviceTypes(db) ⇒

Retrieves all the device types in the database.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: Promise that resolves with the rows of device types.

Param Type
db *

DB API: zcl database access~insertGlobals(db, packageId, data) ⇒

Inserts globals into the database.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: Promise of globals insertion.

Param Type
db *
packageId *
data *

DB API: zcl database access~insertClusterExtensions(db, packageId, data) ⇒

Inserts cluster extensions into the database.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: Promise of cluster extension insertion.

Param Type
db *
packageId *
data *

DB API: zcl database access~insertClusters(db, packageId, data) ⇒

Inserts clusters into the database.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: Promise of cluster insertion.

Param Type Description
db *
packageId *
data * an array of objects that must contain: code, name, description, define. It also contains commands: and attributes:

DB API: zcl database access~insertDeviceTypes(db, packageId, data) ⇒

Inserts device types into the database.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: Promise of an insertion of device types.

Param Type Description
db *
packageId *
data * an array of objects that must contain: code, name, description

DB API: zcl database access~insertDeviceTypeAttributes(db, dtClusterRefDataPairs)

This handles the loading of device type attribute requirements into the database. There is a need to post-process to attach the actual attribute ref after the fact

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)

Param Type
db *
dtClusterRefDataPairs *

DB API: zcl database access~insertDeviceTypeCommands(db, dtClusterRefDataPairs)

This handles the loading of device type command requirements into the database. There is a need to post-process to attach the actual command ref after the fact

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)

Param Type
db *
dtClusterRefDataPairs *

DB API: zcl database access~insertDomains(db, packageId, data) ⇒

Inserts domains into the database. data is an array of objects that must contain: name

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: A promise that resolves with an array of rowids of all inserted domains.

Param Type
db *
packageId *
data *

DB API: zcl database access~insertStructs(db, packageId, data) ⇒

Inserts structs into the database. data is an array of objects that must contain: name

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: A promise that resolves with an array of struct item rowids.

Param Type
db *
packageId *
data *

DB API: zcl database access~insertEnums(db, packageId, data) ⇒

Inserts enums into the database.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: A promise of enum insertion.

Param Type Description
db *
packageId *
data * an array of objects that must contain: name, type

DB API: zcl database access~insertAtomics(db, packageId, data)

Insert atomics into the database. Data is an array of objects that must contains: name, id, description. Object might also contain 'size', but possibly not.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)

Param Type
db *
packageId *
data *

DB API: zcl database access~selectAtomicType(db, packageId, typeName)

Locates atomic type based on a type name.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)

Param Type
db *
packageId *
typeName *

DB API: zcl database access~selectAllAtomics(db, packageId)

Retrieves all atomic types under a given package Id.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)

Param Type
db *
packageId *

DB API: zcl database access~getAtomicSizeFromType(db, packageId, type)

Retrieves the size from atomic type.

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)

Param Type
db *
packageId *
type *

DB API: zcl database access~insertBitmaps(db, packageId, data) ⇒

Inserts bitmaps into the database. Data is an array of objects that must contain: name, type

Kind: inner method of [DB API: zcl database access](#moduleDB API zcl database access)
Returns: A promise of bitmap insertions.

Param Type Description
db *
packageId *
data * Array of object containing 'name' and 'type'.

JS API: generator logic

  • [JS API: generator logic](#moduleJS API generator logic)
    • [~loadGenTemplate()](#moduleJS API generator logic..loadGenTemplate) ⇒
    • [~recordTemplatesPackage(context)](#moduleJS API generator logic..recordTemplatesPackage) ⇒
    • [~loadTemplates(db, genTemplatesJson)](#moduleJS API generator logic..loadTemplates) ⇒
    • [~generateAllTemplates(genResult, pkg, generateOnly)](#moduleJS API generator logic..generateAllTemplates) ⇒
    • [~generateSingleTemplate(genResult, pkg)](#moduleJS API generator logic..generateSingleTemplate) ⇒
    • [~generate(db, packageId)](#moduleJS API generator logic..generate) ⇒
    • [~generateGenerationContent(genResult)](#moduleJS API generator logic..generateGenerationContent)
    • [~generateAndWriteFiles(db, sessionId, packageId, outputDirectory)](#moduleJS API generator logic..generateAndWriteFiles) ⇒
    • [~contentIndexer(content)](#moduleJS API generator logic..contentIndexer)
    • [~generateSingleFileForPreview(db, sessionId, fileName)](#moduleJS API generator logic..generateSingleFileForPreview) ⇒
    • [~produceContent(db, sessionId, singlePkg)](#moduleJS API generator logic..produceContent) ⇒
    • [~collectBlocks(resultArray, options, context)](#moduleJS API generator logic..collectBlocks) ⇒
    • [~ensureZclPackageId(context)](#moduleJS API generator logic..ensureZclPackageId) ⇒
    • [~ensureTemplatePackageId(context)](#moduleJS API generator logic..ensureTemplatePackageId) ⇒

JS API: generator logic~loadGenTemplate() ⇒

Given a path, it will read generation template object into memory.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: context.templates, context.crc

Param Type
context.path *

JS API: generator logic~recordTemplatesPackage(context) ⇒

Given a loading context, it records the package into the packages table and adds the packageId field into the resolved context.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves with the same context passed in, except packageId added to it

Param Type
context *

JS API: generator logic~loadTemplates(db, genTemplatesJson) ⇒

Main API function to load templates from a gen-template.json file.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: the loading context, contains: db, path, crc, packageId and templateData

Param Type Description
db * Database
genTemplatesJson * Path to the JSON file

JS API: generator logic~generateAllTemplates(genResult, pkg, generateOnly) ⇒

Generates all the templates inside a toplevel package.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: Promise that resolves with genResult, that contains all the generated templates, keyed by their 'output'

Param Type Default Description
genResult *
pkg *
generateOnly * if NULL then generate all templates, else only generate template whose out file name matches this.

JS API: generator logic~generateSingleTemplate(genResult, pkg) ⇒

Function that generates a single package and adds it to the generation result.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves with the genResult, with newly generated content added.

Param Type
genResult *
pkg *

JS API: generator logic~generate(db, packageId) ⇒

Main API function to generate stuff.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: Promise that resolves into a generation result.

Param Type Description
db * Database
packageId * packageId Template package id

JS API: generator logic~generateGenerationContent(genResult)

Returns a promise that resolves into a content that should be written out to gen result file.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)

Param Type
genResult *

JS API: generator logic~generateAndWriteFiles(db, sessionId, packageId, outputDirectory) ⇒

Generate files and write them into the given directory.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: a promise which will resolve when all the files are written.

Param Type
db *
sessionId *
packageId *
outputDirectory *

JS API: generator logic~contentIndexer(content)

This function takes a string, and resolves a preview object out of it.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)

Param Type Description
content * String to form into preview.

JS API: generator logic~generateSingleFileForPreview(db, sessionId, fileName) ⇒

Generates a single file and feeds it back for preview.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves into a preview object.

Param Type
db *
sessionId *
fileName *

JS API: generator logic~produceContent(db, sessionId, singlePkg) ⇒

Given db connection, session and a single template package, produce the output.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: Promise that resolves with the 'utf8' string that contains the generated content.

Param Type
db *
sessionId *
singlePkg *

JS API: generator logic~collectBlocks(resultArray, options, context) ⇒

Helpful function that collects the individual blocks by using elements of an array as a context, executing promises for each, and collecting them into the outgoing string.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: Promise that resolves with a content string.

Param Type Description
resultArray *
options * Options passed from a block helper.
context * The context from within this was called.

JS API: generator logic~ensureZclPackageId(context) ⇒

Returns the promise that resolves with the ZCL properties package id.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves with the package id.

Param Type
context *

JS API: generator logic~ensureTemplatePackageId(context) ⇒

Returns the promise that resolves with the ZCL properties package id.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves with the package id.

Param Type
context *

Templating API: C formatting helpers

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

  • [Templating API: C formatting helpers](#moduleTemplating API C formatting helpers)
    • [~asMacro(label)](#moduleTemplating API C formatting helpers..asMacro) ⇒
    • [~asOffset(hex)](#moduleTemplating API C formatting helpers..asOffset)
    • [~asDelimitedMacro(label)](#moduleTemplating API C formatting helpers..asDelimitedMacro)
    • [~asHex(label)](#moduleTemplating API C formatting helpers..asHex) ⇒
    • [~defaultAtomicType(atomic)](#moduleTemplating API C formatting helpers..defaultAtomicType)
    • [~asUnderlyingType(value)](#moduleTemplating API C formatting helpers..asUnderlyingType)
    • [~asType(label)](#moduleTemplating API C formatting helpers..asType) ⇒
    • [~asSymbol(label)](#moduleTemplating API C formatting helpers..asSymbol) ⇒
    • [~asBytes(value)](#moduleTemplating API C formatting helpers..asBytes)

Templating API: C formatting helpers~asMacro(label) ⇒

Formats label as a C macro. This method performs a very simply substition of illegal characters, such as ' ', ':' and such into a '_' character.

Kind: inner method of [Templating API: C formatting helpers](#moduleTemplating API C formatting helpers)
Returns: Label formatted as C macro.

Param Type
label *

Templating API: C formatting helpers~asOffset(hex)

Given a hex number, it prints the offset, which is the index of the first non-zero bit.

Kind: inner method of [Templating API: C formatting helpers](#moduleTemplating API C formatting helpers)

Param Type
hex *

Templating API: C formatting helpers~asDelimitedMacro(label)

Takes a label, and delimits is on camelcasing. For example: VerySimpleLabel will turn into VERY_SIMPLE_LABEL

Kind: inner method of [Templating API: C formatting helpers](#moduleTemplating API C formatting helpers)

Param Type
label *

Templating API: C formatting helpers~asHex(label) ⇒

Formats label as a C hex constant. If value starts as 0x or 0X it is already treated as hex, otherwise it is assumed decimal and converted to hex.

Kind: inner method of [Templating API: C formatting helpers](#moduleTemplating API C formatting helpers)
Returns: Label formatted as C hex constant.

Param Type
label *

Templating API: C formatting helpers~defaultAtomicType(atomic)

Returns the default atomic C type for a given atomic from the database. These values are used unless there is an override in template package json file. (Not yet fully implemented, but the plan is for template pkg to be able to override these.)

Kind: inner method of [Templating API: C formatting helpers](#moduleTemplating API C formatting helpers)

Param Type
atomic *

Templating API: C formatting helpers~asUnderlyingType(value)

Converts the actual zcl type into an underlying usable C type.

Kind: inner method of [Templating API: C formatting helpers](#moduleTemplating API C formatting helpers)

Param Type
value *

Templating API: C formatting helpers~asType(label) ⇒

Formats label as a C type.

Kind: inner method of [Templating API: C formatting helpers](#moduleTemplating API C formatting helpers)
Returns: Label formatted as C type.

Param Type
label *

Templating API: C formatting helpers~asSymbol(label) ⇒

Formats label as a C symbol.

Kind: inner method of [Templating API: C formatting helpers](#moduleTemplating API C formatting helpers)
Returns: Label formatted as C symbol.

Param Type
label *

Templating API: C formatting helpers~asBytes(value)

Given a default value of attribute, this method converts it into bytes

Kind: inner method of [Templating API: C formatting helpers](#moduleTemplating API C formatting helpers)

Param Type
value *

Templating API: user-data specific helpers

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

  • [Templating API: user-data specific helpers](#moduleTemplating API user-data specific helpers)
    • [~user_endpoint_types(options)](#moduleTemplating API user-data specific helpers..user_endpoint_types)
    • [~user_clusters(options)](#moduleTemplating API user-data specific helpers..user_clusters)
    • [~user_cluster_attributes(options)](#moduleTemplating API user-data specific helpers..user_cluster_attributes) ⇒
    • [~user_cluster_commands(options)](#moduleTemplating API user-data specific helpers..user_cluster_commands) ⇒
    • [~user_all_attributes(options)](#moduleTemplating API user-data specific helpers..user_all_attributes) ⇒

Templating API: user-data specific helpers~user_endpoint_types(options)

Creates block iterator helper over the endpoint types.

Kind: inner method of [Templating API: user-data specific helpers](#moduleTemplating API user-data specific helpers)

Param Type
options *

Templating API: user-data specific helpers~user_clusters(options)

Creates cluster iterator over the endpoint types. This works ony inside user_endpoint_types.

Kind: inner method of [Templating API: user-data specific helpers](#moduleTemplating API user-data specific helpers)

Param Type
options *

Templating API: user-data specific helpers~user_cluster_attributes(options) ⇒

Creates endpoint type cluster attribute iterator. This works only inside user_clusters.

Kind: inner method of [Templating API: user-data specific helpers](#moduleTemplating API user-data specific helpers)
Returns: Promise of the resolved blocks iterating over cluster attributes.

Param Type
options *

Templating API: user-data specific helpers~user_cluster_commands(options) ⇒

Creates endpoint type cluster command iterator. This works only inside user_clusters.

Kind: inner method of [Templating API: user-data specific helpers](#moduleTemplating API user-data specific helpers)
Returns: Promise of the resolved blocks iterating over cluster commands.

Param Type
options *

Templating API: user-data specific helpers~user_all_attributes(options) ⇒

Iterates over all attributes required by the user configuration.

Kind: inner method of [Templating API: user-data specific helpers](#moduleTemplating API user-data specific helpers)
Returns: Promise of the resolved blocks iterating over cluster commands.

Param Type
options *

Templating API: toplevel utility helpers

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

  • [Templating API: toplevel utility helpers](#moduleTemplating API toplevel utility helpers)
    • [~zap_header()](#moduleTemplating API toplevel utility helpers..zap_header) ⇒
    • [~ident()](#moduleTemplating API toplevel utility helpers..ident) ⇒
    • [~template_options(category, options)](#moduleTemplating API toplevel utility helpers..template_options)
    • [~first(options)](#moduleTemplating API toplevel utility helpers..first) ⇒
    • [~last(options)](#moduleTemplating API toplevel utility helpers..last) ⇒

Templating API: toplevel utility helpers~zap_header() ⇒

Produces the top-of-the-file header for a C file.

Kind: inner method of [Templating API: toplevel utility helpers](#moduleTemplating API toplevel utility helpers)
Returns: The header content

Templating API: toplevel utility helpers~ident() ⇒

Simple helper that produces an approved size of identation.

Kind: inner method of [Templating API: toplevel utility helpers](#moduleTemplating API toplevel utility helpers)
Returns: whitespace that is the identation.

Templating API: toplevel utility helpers~template_options(category, options)

Block helper that iterates over the package options of a given category.

Kind: inner method of [Templating API: toplevel utility helpers](#moduleTemplating API toplevel utility helpers)

Param Type
category *
options *

Templating API: toplevel utility helpers~first(options) ⇒

Inside an iterator, this helper allows you to specify the content that will be output only during the first element.

Kind: inner method of [Templating API: toplevel utility helpers](#moduleTemplating API toplevel utility helpers)
Returns: content, if it's the first element inside an operator, empty otherwise.

Param Type
options *

Templating API: toplevel utility helpers~last(options) ⇒

Inside an iterator, this helper allows you to specify the content that will be output only during the last element.

Kind: inner method of [Templating API: toplevel utility helpers](#moduleTemplating API toplevel utility helpers)
Returns: content, if it's the last element inside an operator, empty otherwise.

Param Type
options *

Templating API: static zcl helpers

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

  • [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
    • [~zcl_bitmaps(options)](#moduleTemplating API static zcl helpers..zcl_bitmaps) ⇒
    • [~zcl_bitmap_items(options)](#moduleTemplating API static zcl helpers..zcl_bitmap_items)
    • [~zcl_enums(options)](#moduleTemplating API static zcl helpers..zcl_enums) ⇒
    • [~zcl_enum_items(options)](#moduleTemplating API static zcl helpers..zcl_enum_items)
    • [~zcl_structs(options)](#moduleTemplating API static zcl helpers..zcl_structs) ⇒
    • [~zcl_struct_items(options)](#moduleTemplating API static zcl helpers..zcl_struct_items) ⇒
    • [~zcl_clusters(options)](#moduleTemplating API static zcl helpers..zcl_clusters) ⇒
    • [~zcl_commands(options)](#moduleTemplating API static zcl helpers..zcl_commands) ⇒
    • [~zcl_global_commands(options)](#moduleTemplating API static zcl helpers..zcl_global_commands) ⇒
    • [~zcl_attributes(options)](#moduleTemplating API static zcl helpers..zcl_attributes) ⇒
    • [~zcl_attributes_client(options)](#moduleTemplating API static zcl helpers..zcl_attributes_client) ⇒
    • [~zcl_attributes_server(options)](#moduleTemplating API static zcl helpers..zcl_attributes_server) ⇒
    • [~zcl_atomics(options)](#moduleTemplating API static zcl helpers..zcl_atomics) ⇒
    • [~zcl_cluster_largest_label_length()](#moduleTemplating API static zcl helpers..zcl_cluster_largest_label_length) ⇒
    • [~largestLabelLength(An)](#moduleTemplating API static zcl helpers..largestLabelLength) ⇒

Templating API: static zcl helpers~zcl_bitmaps(options) ⇒

Block helper iterating over all bitmaps.

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
Returns: Promise of content.

Param Type
options *

Templating API: static zcl helpers~zcl_bitmap_items(options)

Iterates over enum items. Valid only inside zcl_enums.

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)

Param Type
options *

Templating API: static zcl helpers~zcl_enums(options) ⇒

Block helper iterating over all enums.

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
Returns: Promise of content.

Param Type
options *

Templating API: static zcl helpers~zcl_enum_items(options)

Iterates over enum items. Valid only inside zcl_enums.

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)

Param Type
options *

Templating API: static zcl helpers~zcl_structs(options) ⇒

Block helper iterating over all structs. function macroList(options)

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
Returns: Promise of content.

Param Type
options *

Templating API: static zcl helpers~zcl_struct_items(options) ⇒

Block helper iterating over all struct items. Valid only inside zcl_structs.

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
Returns: Promise of content.

Param Type
options *

Templating API: static zcl helpers~zcl_clusters(options) ⇒

Block helper iterating over all clusters.

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
Returns: Promise of content.

Param Type
options *

Templating API: static zcl helpers~zcl_commands(options) ⇒

Block helper iterating over all commands. There are two modes of this helper: when used in a global context, it iterates over ALL commands in the database. when used inside a zcl_cluster block helper, it iterates only over the commands for that cluster.

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
Returns: Promise of content.

Param Type
options *

Templating API: static zcl helpers~zcl_global_commands(options) ⇒

Helper to iterate over all global commands.

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
Returns: Promise of global command iteration.

Param Type
options *

Templating API: static zcl helpers~zcl_attributes(options) ⇒

Iterator over the attributes. If it is used at toplevel, if iterates over all the attributes in the database. If used within zcl_cluster context, it iterates over all the attributes that belong to that cluster.

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
Returns: Promise of attribute iteration.

Param Type
options *

Templating API: static zcl helpers~zcl_attributes_client(options) ⇒

Iterator over the client attributes. If it is used at toplevel, if iterates over all the client attributes in the database. If used within zcl_cluster context, it iterates over all the client attributes that belong to that cluster.

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
Returns: Promise of attribute iteration.

Param Type
options *

Templating API: static zcl helpers~zcl_attributes_server(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.

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
Returns: Promise of attribute iteration.

Param Type
options *

Templating API: static zcl helpers~zcl_atomics(options) ⇒

Block helper iterating over all atomic types.

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
Returns: Promise of content.

Param Type
options *

Templating API: static zcl helpers~zcl_cluster_largest_label_length() ⇒

Given: N/A

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
Returns: the length of largest cluster name in a list of clusters

Templating API: static zcl helpers~largestLabelLength(An) ⇒

Kind: inner method of [Templating API: static zcl helpers](#moduleTemplating API static zcl helpers)
Returns: the length of largest object name in an array. Helper for zcl_cluster_largest_label_length

Param Type Description
An * Array

JS API: generator logic

  • [JS API: generator logic](#moduleJS API generator logic)
    • [~loadGenTemplate()](#moduleJS API generator logic..loadGenTemplate) ⇒
    • [~recordTemplatesPackage(context)](#moduleJS API generator logic..recordTemplatesPackage) ⇒
    • [~loadTemplates(db, genTemplatesJson)](#moduleJS API generator logic..loadTemplates) ⇒
    • [~generateAllTemplates(genResult, pkg, generateOnly)](#moduleJS API generator logic..generateAllTemplates) ⇒
    • [~generateSingleTemplate(genResult, pkg)](#moduleJS API generator logic..generateSingleTemplate) ⇒
    • [~generate(db, packageId)](#moduleJS API generator logic..generate) ⇒
    • [~generateGenerationContent(genResult)](#moduleJS API generator logic..generateGenerationContent)
    • [~generateAndWriteFiles(db, sessionId, packageId, outputDirectory)](#moduleJS API generator logic..generateAndWriteFiles) ⇒
    • [~contentIndexer(content)](#moduleJS API generator logic..contentIndexer)
    • [~generateSingleFileForPreview(db, sessionId, fileName)](#moduleJS API generator logic..generateSingleFileForPreview) ⇒
    • [~produceContent(db, sessionId, singlePkg)](#moduleJS API generator logic..produceContent) ⇒
    • [~collectBlocks(resultArray, options, context)](#moduleJS API generator logic..collectBlocks) ⇒
    • [~ensureZclPackageId(context)](#moduleJS API generator logic..ensureZclPackageId) ⇒
    • [~ensureTemplatePackageId(context)](#moduleJS API generator logic..ensureTemplatePackageId) ⇒

JS API: generator logic~loadGenTemplate() ⇒

Given a path, it will read generation template object into memory.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: context.templates, context.crc

Param Type
context.path *

JS API: generator logic~recordTemplatesPackage(context) ⇒

Given a loading context, it records the package into the packages table and adds the packageId field into the resolved context.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves with the same context passed in, except packageId added to it

Param Type
context *

JS API: generator logic~loadTemplates(db, genTemplatesJson) ⇒

Main API function to load templates from a gen-template.json file.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: the loading context, contains: db, path, crc, packageId and templateData

Param Type Description
db * Database
genTemplatesJson * Path to the JSON file

JS API: generator logic~generateAllTemplates(genResult, pkg, generateOnly) ⇒

Generates all the templates inside a toplevel package.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: Promise that resolves with genResult, that contains all the generated templates, keyed by their 'output'

Param Type Default Description
genResult *
pkg *
generateOnly * if NULL then generate all templates, else only generate template whose out file name matches this.

JS API: generator logic~generateSingleTemplate(genResult, pkg) ⇒

Function that generates a single package and adds it to the generation result.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves with the genResult, with newly generated content added.

Param Type
genResult *
pkg *

JS API: generator logic~generate(db, packageId) ⇒

Main API function to generate stuff.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: Promise that resolves into a generation result.

Param Type Description
db * Database
packageId * packageId Template package id

JS API: generator logic~generateGenerationContent(genResult)

Returns a promise that resolves into a content that should be written out to gen result file.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)

Param Type
genResult *

JS API: generator logic~generateAndWriteFiles(db, sessionId, packageId, outputDirectory) ⇒

Generate files and write them into the given directory.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: a promise which will resolve when all the files are written.

Param Type
db *
sessionId *
packageId *
outputDirectory *

JS API: generator logic~contentIndexer(content)

This function takes a string, and resolves a preview object out of it.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)

Param Type Description
content * String to form into preview.

JS API: generator logic~generateSingleFileForPreview(db, sessionId, fileName) ⇒

Generates a single file and feeds it back for preview.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves into a preview object.

Param Type
db *
sessionId *
fileName *

JS API: generator logic~produceContent(db, sessionId, singlePkg) ⇒

Given db connection, session and a single template package, produce the output.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: Promise that resolves with the 'utf8' string that contains the generated content.

Param Type
db *
sessionId *
singlePkg *

JS API: generator logic~collectBlocks(resultArray, options, context) ⇒

Helpful function that collects the individual blocks by using elements of an array as a context, executing promises for each, and collecting them into the outgoing string.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: Promise that resolves with a content string.

Param Type Description
resultArray *
options * Options passed from a block helper.
context * The context from within this was called.

JS API: generator logic~ensureZclPackageId(context) ⇒

Returns the promise that resolves with the ZCL properties package id.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves with the package id.

Param Type
context *

JS API: generator logic~ensureTemplatePackageId(context) ⇒

Returns the promise that resolves with the ZCL properties package id.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves with the package id.

Param Type
context *

JS API: generator logic

  • [JS API: generator logic](#moduleJS API generator logic)
    • [~loadGenTemplate()](#moduleJS API generator logic..loadGenTemplate) ⇒
    • [~recordTemplatesPackage(context)](#moduleJS API generator logic..recordTemplatesPackage) ⇒
    • [~loadTemplates(db, genTemplatesJson)](#moduleJS API generator logic..loadTemplates) ⇒
    • [~generateAllTemplates(genResult, pkg, generateOnly)](#moduleJS API generator logic..generateAllTemplates) ⇒
    • [~generateSingleTemplate(genResult, pkg)](#moduleJS API generator logic..generateSingleTemplate) ⇒
    • [~generate(db, packageId)](#moduleJS API generator logic..generate) ⇒
    • [~generateGenerationContent(genResult)](#moduleJS API generator logic..generateGenerationContent)
    • [~generateAndWriteFiles(db, sessionId, packageId, outputDirectory)](#moduleJS API generator logic..generateAndWriteFiles) ⇒
    • [~contentIndexer(content)](#moduleJS API generator logic..contentIndexer)
    • [~generateSingleFileForPreview(db, sessionId, fileName)](#moduleJS API generator logic..generateSingleFileForPreview) ⇒
    • [~produceContent(db, sessionId, singlePkg)](#moduleJS API generator logic..produceContent) ⇒
    • [~collectBlocks(resultArray, options, context)](#moduleJS API generator logic..collectBlocks) ⇒
    • [~ensureZclPackageId(context)](#moduleJS API generator logic..ensureZclPackageId) ⇒
    • [~ensureTemplatePackageId(context)](#moduleJS API generator logic..ensureTemplatePackageId) ⇒

JS API: generator logic~loadGenTemplate() ⇒

Given a path, it will read generation template object into memory.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: context.templates, context.crc

Param Type
context.path *

JS API: generator logic~recordTemplatesPackage(context) ⇒

Given a loading context, it records the package into the packages table and adds the packageId field into the resolved context.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves with the same context passed in, except packageId added to it

Param Type
context *

JS API: generator logic~loadTemplates(db, genTemplatesJson) ⇒

Main API function to load templates from a gen-template.json file.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: the loading context, contains: db, path, crc, packageId and templateData

Param Type Description
db * Database
genTemplatesJson * Path to the JSON file

JS API: generator logic~generateAllTemplates(genResult, pkg, generateOnly) ⇒

Generates all the templates inside a toplevel package.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: Promise that resolves with genResult, that contains all the generated templates, keyed by their 'output'

Param Type Default Description
genResult *
pkg *
generateOnly * if NULL then generate all templates, else only generate template whose out file name matches this.

JS API: generator logic~generateSingleTemplate(genResult, pkg) ⇒

Function that generates a single package and adds it to the generation result.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves with the genResult, with newly generated content added.

Param Type
genResult *
pkg *

JS API: generator logic~generate(db, packageId) ⇒

Main API function to generate stuff.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: Promise that resolves into a generation result.

Param Type Description
db * Database
packageId * packageId Template package id

JS API: generator logic~generateGenerationContent(genResult)

Returns a promise that resolves into a content that should be written out to gen result file.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)

Param Type
genResult *

JS API: generator logic~generateAndWriteFiles(db, sessionId, packageId, outputDirectory) ⇒

Generate files and write them into the given directory.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: a promise which will resolve when all the files are written.

Param Type
db *
sessionId *
packageId *
outputDirectory *

JS API: generator logic~contentIndexer(content)

This function takes a string, and resolves a preview object out of it.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)

Param Type Description
content * String to form into preview.

JS API: generator logic~generateSingleFileForPreview(db, sessionId, fileName) ⇒

Generates a single file and feeds it back for preview.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves into a preview object.

Param Type
db *
sessionId *
fileName *

JS API: generator logic~produceContent(db, sessionId, singlePkg) ⇒

Given db connection, session and a single template package, produce the output.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: Promise that resolves with the 'utf8' string that contains the generated content.

Param Type
db *
sessionId *
singlePkg *

JS API: generator logic~collectBlocks(resultArray, options, context) ⇒

Helpful function that collects the individual blocks by using elements of an array as a context, executing promises for each, and collecting them into the outgoing string.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: Promise that resolves with a content string.

Param Type Description
resultArray *
options * Options passed from a block helper.
context * The context from within this was called.

JS API: generator logic~ensureZclPackageId(context) ⇒

Returns the promise that resolves with the ZCL properties package id.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves with the package id.

Param Type
context *

JS API: generator logic~ensureTemplatePackageId(context) ⇒

Returns the promise that resolves with the ZCL properties package id.

Kind: inner method of [JS API: generator logic](#moduleJS API generator logic)
Returns: promise that resolves with the package id.

Param Type
context *

REST API: admin functions

This module provides the REST API to the admin functions.

REST API: admin functions~registerAdminApi(db, app)

API: /post/sql Request JSON:

  {
    sql: SQL Query
  }

Response JSON:

  {
    result: Array of rows.
  }

Kind: inner method of [REST API: admin functions](#moduleREST API admin functions)

Param Type
db *
app *

REST API: generation functions

This module provides the REST API to the generation.

  • [REST API: generation functions](#moduleREST API generation functions)
    • [~registerGenerationApi(db, app)](#moduleREST API generation functions..registerGenerationApi)
    • [~registerUcComponentApi(db, app)](#moduleREST API generation functions..registerUcComponentApi)

REST API: generation functions~registerGenerationApi(db, app)

Kind: inner method of [REST API: generation functions](#moduleREST API generation functions)

Param Type
db *
app *

REST API: generation functions~registerUcComponentApi(db, app)

Register server side REST API for front-end to interact with Studio components.

Kind: inner method of [REST API: generation functions](#moduleREST API generation functions)

Param Type
db *
app *

REST API: static zcl functions

This module provides the REST API to the static zcl queries.

REST API: static zcl functions~registerStaticZclApi(app)

API: /zcl/:entity/:id

Kind: inner method of [REST API: static zcl functions](#moduleREST API static zcl functions)

Param Type Description
app * Express instance.

REST API: generation functions

This module provides the REST API to the generation.

  • [REST API: generation functions](#moduleREST API generation functions)
    • [~registerGenerationApi(db, app)](#moduleREST API generation functions..registerGenerationApi)
    • [~registerUcComponentApi(db, app)](#moduleREST API generation functions..registerUcComponentApi)

REST API: generation functions~registerGenerationApi(db, app)

Kind: inner method of [REST API: generation functions](#moduleREST API generation functions)

Param Type
db *
app *

REST API: generation functions~registerUcComponentApi(db, app)

Register server side REST API for front-end to interact with Studio components.

Kind: inner method of [REST API: generation functions](#moduleREST API generation functions)

Param Type
db *
app *

REST API: user data

This module provides the REST API to the user specific data.

JS API: http server

This module provides the HTTP server functionality.

  • [JS API: http server](#moduleJS API http server)
    • [~initHttpServer(db, port)](#moduleJS API http server..initHttpServer) ⇒
    • [~shutdownHttpServer()](#moduleJS API http server..shutdownHttpServer) ⇒
    • [~httpServerPort()](#moduleJS API http server..httpServerPort) ⇒

JS API: http server~initHttpServer(db, port) ⇒

Promises to initialize the http server on a given port using a given database.

Kind: inner method of [JS API: http server](#moduleJS API http server)
Returns: A promise that resolves with an express app.

Param Type Description
db * Database object to use.
port * Port for the HTTP server.

JS API: http server~shutdownHttpServer() ⇒

Promises to shut down the http server.

Kind: inner method of [JS API: http server](#moduleJS API http server)
Returns: Promise that resolves when server is shut down.

JS API: http server~httpServerPort() ⇒

Port http server is listening on.

Kind: inner method of [JS API: http server](#moduleJS API http server)
Returns: port

JS API: random utilities

  • [JS API: random utilities](#moduleJS API random utilities)
    • [~calculateCrc(context)](#moduleJS API random utilities..calculateCrc) ⇒
    • [~initializeSessionPackage(db, sessionId)](#moduleJS API random utilities..initializeSessionPackage) ⇒

JS API: random utilities~calculateCrc(context) ⇒

Promises to calculate the CRC of the file, and resolve with an object { filePath, data, actualCrc }

Kind: inner method of [JS API: random utilities](#moduleJS API random utilities)
Returns: Promise that resolves with the same object, just adds the 'crc' key into it.

Param Type Description
context * that contains 'filePath' and 'data' keys for the file and contents of the file.

JS API: random utilities~initializeSessionPackage(db, sessionId) ⇒

This function assigns a proper package ID to the session.

Kind: inner method of [JS API: random utilities](#moduleJS API random utilities)
Returns: Promise that resolves with the session id for chaining.

Param Type
db *
sessionId *

replyId

Copyright (c) 2020 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.

Kind: global constant

queryZcl

Copyright (c) 2020 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.

Kind: global constant

templateUtil

Copyright (c) 2020 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.

Kind: global constant

queryZcl

Copyright (c) 2020 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.

Kind: global constant

queryPackage

Copyright (c) 2020 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.

Kind: global constant

env

This file is used specifically and only for development. It installs electron-debug & vue-devtools. There shouldn't be any need to modify this file, but it can be used to extend your development environment.

Kind: global constant

dbApi

Copyright (c) 2020 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.

Kind: global constant

axios

This module provides the API to Studio's Jetty server.

Kind: global constant

yargs

Copyright (c) 2020 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.

Kind: global constant

path

Copyright (c) 2020 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.

Kind: global constant

queryZcl

This module provides the APIs for validating inputs to the database, and returning flags indicating if things were successful or not.

Kind: global constant

fs

Copyright (c) 2020 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.

Kind: global constant

fs

Copyright (c) 2020 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.

Kind: global constant

exportSessionKeyValues(db, sessionId) ⇒

Resolves to an array of objects that contain 'key' and 'value'

Kind: global function
Returns: Promise to retrieve all session key values.

Param Type
db *
sessionId *

exportEndpoints(db, sessionId) ⇒

Resolves to an array of endpoints.

Kind: global function
Returns: Promise to retrieve all endpoints.

Param Type
db *
sessionId *

exportEndpointTypes(db, sessionId) ⇒

Resolves to an array of endpoint types.

Kind: global function
Returns: Promise to retrieve all endpoint types.

Param Type
db *
sessionId *

exportSessionPackages(db, sessionId)

Resolves with data for packages.

Kind: global function

Param Type
db *
sessionId *

exportDataIntoFile(db, sessionId, filePath) ⇒

Toplevel file that takes a given session ID and exports the data into the file

Kind: global function
Returns: A promise that resolves with the path of the file written.

Param Type
db *
sessionId *
filePath *

createStateFromDatabase(db, sessionId) ⇒

Given a database and a session id, this method returns a promise that resolves with a state object that needs to be saved into a file.

Kind: global function
Returns: state object that needs to be saved into a file.

Param Type
db *
sessionId *

importSessionKeyValues(db, sessionId, keyValuePairs)

Resolves with a promise that imports session key values.

Kind: global function

Param Type
db *
sessionId *
keyValuePairs *

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 *

writeStateToDatabase(db, state) ⇒

Given a state object, this method returns a promise that resolves with the succesfull writing into the database.

Kind: global function
Returns: a promise that resolves into a sessionId that was created.

Param Type
db *
state *

importDataFromFile(db, filePath) ⇒

Writes the data from the file into a new session.

Kind: global function
Returns: a promise that resolves with the session Id of the written data.

Param Type
db *
filePath *

doOpen(menuItem, browserWindow, event)

Perform a file->open operation.

Kind: global function

Param Type
menuItem *
browserWindow *
event *

doSave(menuItem, browserWindow, event)

Perform a save, defering to save as if file is not yet selected.

Kind: global function

Param Type
menuItem *
browserWindow *
event *

doSaveAs(menuItem, browserWindow, event)

Perform save as.

Kind: global function

Param Type
menuItem *
browserWindow *
event *

generateInDir(browserWindow)

This function gets the directory where user wants the output and calls generateCode function which generates the code in the user selected output.

Kind: global function

Param Type
browserWindow *

setHandlebarTemplateDirectory(browserWindow)

This function gets the directory where user wants the output and calls generateCode function which generates the code in the user selected output.

Kind: global function

Param Type
browserWindow *

fileSave(db, winId, filePath) ⇒

perform the save.

Kind: global function
Returns: Promise of saving.

Param Type
db *
winId *
filePath *

fileOpen(db, winId, filePaths)

Perform the do open action, possibly reading in multiple files.

Kind: global function

Param Type
db *
winId *
filePaths *

readAndProcessFile(db, filePath)

Process a single file, parsing it in as JSON and then possibly opening a new window if all is good.

Kind: global function

Param Type
db *
filePath *

initMenu(port)

Initialize a menu.

Kind: global function

Param Type
port *

createOrShowWindow(port)

Call this function to create a new or show an existing preference window.

Kind: global function

Param Type
port *

startNormal(uiEnabled, showUrl, uiMode)

Start up application in a normal mode.

Kind: global function

Param Type
uiEnabled *
showUrl *
uiMode *

startSelfCheck()

Start up application in self-check mode.

Kind: global function

startGeneration(output, genTemplateJsonFile, zclProperties, [zapFile]) ⇒

Performs headless regeneration for given parameters.

Kind: global function
Returns: Nothing, triggers app.quit()

Param Type Default Description
output * Directory where to write files.
genTemplateJsonFile * gen-teplate.json file to use for template loading.
zclProperties * zcl.properties file to use for ZCL properties.
[zapFile] * .zap file that contains application stater, or null if generating from clean state.

clearDatabaseFile()

Moves the main database file into a backup location.

Kind: global function

windowCreate(port, [filePath], [sessionId]) ⇒

Create a window, possibly with a given file path and with a desire to attach to a given sessionId

Win id will be passed on in the URL, and if sessionId is present, so will it.

Kind: global function
Returns: BrowserWindow that got created

Param Type Default
port *
[filePath] *
[sessionId] *

processCommandLineArguments(argv) ⇒

Process the command line arguments and resets the state in this file to the specified values.

Kind: global function
Returns: parsed argv object

Param Type
argv *

int8ToHex(value) ⇒

Takes an int8 value and turns it into a hex.

Kind: global function
Returns: hex string, 2 characters long without '0x'

Param Type
value *

int16ToHex(value) ⇒

Takes an int16 value and turns it into a hex.

Kind: global function
Returns: hex string, 4 characters long without '0x'

Param Type
value *

int32ToHex(value) ⇒

Takes an int8 value and turns it into a hex.

Kind: global function
Returns: hex string, 8 characters long without '0x'

Param Type
value *

stringToHex(value) ⇒

Converts a string to the hex value.

Kind: global function
Returns: hex string, value.length * 2 + 2 characters long. It appends the terminating NULL, so 0x00 is at the end.

Param Type
value *

hexToCBytes(value) ⇒

Takes the raw hex string, such as abcd and converts it into a C constant array, such as 0xAB, 0xCD.

Kind: global function
Returns: C byte array

Param Type
value *

bitOffset(binary)

Getting a binary string ("0001101010010") it returns the number of zero bits at the end.

Kind: global function

Param Type
binary *

hexToBinary(hex)

Convert a hex number to a binary. Hex has to be in a format as obtained by intToHex methods above: no '0x' prefix and upper-case letters, as in "12AB".

Kind: global function

Param Type
hex *

collectData(ctx) ⇒

Promises to read the properties file, extract all the actual xml files, and resolve with the array of files.

Kind: global function
Returns: Promise of resolved files.

Param Type Description
ctx * Context which contains information about the metadataFiles and data

parseZclFiles(db, ctx) ⇒

Promises to iterate over all the XML files and returns an aggregate promise that will be resolved when all the XML files are done, or rejected if at least one fails.

Kind: global function
Returns: Promise that resolves when all the individual promises of each file pass.

Param Type
db *
ctx *

normalizeHexValue(value) ⇒

The Dotdot ZCL XML doesn't use the 0x prefix, but it's a nice thing to have and Silabs xml does use this so this helper function normalizes the use of hex

TODO: Is this the right thing to do?

Kind: global function
Returns: Either the normalized hex string (with the 0x prefix) or the original

Param Type Description
value * the string value to be normalized

prepareAttributes(attributes, side) ⇒

Prepare XML attributes for entry into the DB

Kind: global function
Returns: Array containing all data from XML ready to be inserted into the DB.

Param Type Description
attributes * an array of attributes
side * the side the attribute is on either "client" or "server"

prepareCommands(commands, side) ⇒

Prepare XML commands for entry into the DB

Kind: global function
Returns: Array containing all data from XML ready to be inserted in to the DB.

Param Type Description
commands * an array of commands
side * the side the command is on either "client" or "server"

prepareCluster(cluster, isExtension, types) ⇒

Prepare XML cluster for insertion into the database. This method can also prepare clusterExtensions.

Kind: global function
Returns: Object containing all data from XML.

Param Type Default Description
cluster *
isExtension * false if this is an extension or not (there are none in dotdot xml)
types * types object into which cluster can put types it might have

prepareAtomic(type) ⇒

Parses xml type into the atomic object for insertion into the DB

Kind: global function
Returns: object ready for insertion into the DB

Param Type Description
type * an xml object which conforms to the atomic format in the dotdot xml

prepareBitmap(type, fromAttribute) ⇒

Parses xml type into the bitmap object for insertion into the DB

Kind: global function
Returns: object ready for insertion into the DB

Param Type Default Description
type * an xml object which conforms to the bitmap format in the dotdot xml
fromAttribute * false a boolean indicating if this is coming from an attribute or not

prepareEnum(type) ⇒

Parses xml type into the enum object for insertion into the DB

Kind: global function
Returns: object ready for insertion into the DB

Param Type Description
type * an xml object which conforms to the enum format in the dotdot xml

prepareStruct(type) ⇒

Parses xml type into the struct object for insertion into the DB

Kind: global function
Returns: object ready for insertion into the DB

Param Type Description
type * an xml object which conforms to the struct format in the dotdot xml

prepareTypes(zclTypes, types)

Parses xml types into the types object for insertion into the DB

Kind: global function

Param Type Description
zclTypes * an array of xml types
types * an object which includes arrays for enums, bitmaps etc...

prepareAttributeType(attribute, types, cluster)

Parses xml types into the types object for insertion into the DB

Kind: global function

Param Type Description
attribute * an attribute with the type in it
types * an object which includes arrays for enums, bitmaps etc...
cluster * the cluster that the attribute belongs to (used presently for uniqueness of the type name)

prepareDeviceType(deviceType) ⇒

Preparation step for the device types.

Kind: global function
Returns: an object containing the prepared device types.

Param Type
deviceType *

loadZclData(db, ctx) ⇒

Promises to iterate over all the XML files and returns an aggregate promise that will be resolved when all the XML files are done, or rejected if at least one fails.

Kind: global function
Returns: Promise that resolves when all the individual promises of each file pass.

Param Type
db *
ctx *

loadDotdotZcl(db, ctx) ⇒

Toplevel function that loads the xml library file and orchestrates the promise chain.

Kind: global function
Returns: a Promise that resolves with the db.

Param Type Description
db *
ctx * Context of loading.

readMetadataFile(ctx) ⇒

Reads the properties file into ctx.data and also calculates crc into ctx.crc

Kind: global function
Returns: Promise to populate data, filePath and crc into the context.

Param Type
ctx *

recordToplevelPackage(ctx)

Records the toplevel package information and puts ctx.packageId into the context.

Kind: global function

Param Type
ctx *

recordVersion(db, ctx)

Records the version into the database.

Kind: global function

Param Type
db *
ctx *

loadZcl(db, metadataFile) ⇒

Toplevel function that loads the zcl file and passes it off to the correct zcl loader.

Kind: global function
Returns: a Promise that resolves with the db.

Param Type
db *
metadataFile *

processZclPostLoading(db) ⇒

Promises to perform a post loading step.

Kind: global function
Returns: Promise to deal with the post-loading cleanup.

Param Type
db *

collectDataFromJsonFile(ctx) ⇒

Promises to read the JSON file and resolve all the data.

Kind: global function
Returns: Promise of resolved file.

Param Type Description
ctx * Context containing information about the file

collectDataFromPropertiesFile(ctx) ⇒

Promises to read the properties file, extract all the actual xml files, and resolve with the array of files.

Kind: global function
Returns: Promise of resolved files.

Param Type Description
ctx * Context which contains information about the propertiesFiles and data

readZclFile(file) ⇒

Promises to read a file and resolve with the content

Kind: global function
Returns: promise that resolves as readFile

Param Type
file *

parseZclFile(argument) ⇒

Promises to parse the ZCL file, expecting object of { filePath, data, packageId, msg }

Kind: global function
Returns: promise that resolves with the array [filePath,result,packageId,msg]

Param Type
argument *

prepareBitmap(bm) ⇒

Prepare bitmap for database insertion.

Kind: global function
Returns: Object for insertion into the database

Param Type
bm *

processBitmaps(db, filePath, packageId, data) ⇒

Processes bitmaps for DB insertion.

Kind: global function
Returns: Promise of inserted bitmaps

Param Type
db *
filePath *
packageId *
data *

prepareAtomic(a)

Prepare atomic to db insertion.

Kind: global function

Param Type
a *

processAtomics(db, filePath, packageId, data) ⇒

Processes atomic types for DB insertion.

Kind: global function
Returns: Promise of inserted bitmaps

Param Type
db *
filePath *
packageId *
data *

prepareCluster(cluster) ⇒

Prepare XML cluster for insertion into the database. This method can also prepare clusterExtensions.

Kind: global function
Returns: Object containing all data from XML.

Param Type
cluster *

processClusters(db, filePath, packageId, data) ⇒

Process clusters for insertion into the database.

Kind: global function
Returns: Promise of cluster insertion.

Param Type
db *
filePath *
packageId *
data *

processClusterExtensions(db, filePath, packageId, data) ⇒

Cluster Extension contains attributes and commands in a same way as regular cluster, and it has an attribute code="0xXYZ" where code is a cluster code.

Kind: global function
Returns: promise to resolve the clusterExtension tags

Param Type
db *
filePath *
packageId *
data *

processGlobals(db, filePath, packageId, data) ⇒

Processes the globals in the XML files. The global tag contains attributes and commands in a same way as cluster or clusterExtension

Kind: global function
Returns: promise to resolve the globals

Param Type
db *
filePath *
packageId *
data *

prepareDomain(domain) ⇒

Convert domain from XMl to domain for DB.

Kind: global function
Returns: Domain object for DB.

Param Type
domain *

processDomains(db, filePath, packageId, data) ⇒

Process domains for insertion.

Kind: global function
Returns: Promise of database insertion of domains.

Param Type
db *
filePath *
packageId *
data *

prepareStruct(struct) ⇒

Prepares structs for the insertion into the database.

Kind: global function
Returns: Object ready to insert into the database.

Param Type
struct *

processStructs(db, filePath, packageId, data) ⇒

Processes structs.

Kind: global function
Returns: Promise of inserted structs.

Param Type
db *
filePath *
packageId *
data *

prepareEnum(en) ⇒

Prepares an enum for insertion into the database.

Kind: global function
Returns: An object ready to go to the database.

Param Type
en *

processEnums(db, filePath, packageId, data) ⇒

Processes the enums.

Kind: global function
Returns: A promise of inserted enums.

Param Type
db *
filePath *
packageId *
data *

prepareDeviceType(deviceType) ⇒

Preparation step for the device types.

Kind: global function
Returns: an object containing the prepared device types.

Param Type
deviceType *

processDeviceTypes(db, filePath, packageId, data) ⇒

Process all device types.

Kind: global function
Returns: Promise of a resolved device types.

Param Type
db *
filePath *
packageId *
data *

processParsedZclData(db, argument) ⇒

After XML parser is done with the barebones parsing, this function branches the individual toplevel tags.

Kind: global function
Returns: promise that resolves when all the subtags are parsed.

Param Type
db *
argument *

resolveLaterPromises(laterPromises)

Resolve later promises. This function resolves the later promises associated with processParsedZclData.

Kind: global function

Param Type
laterPromises *

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 *

parseZclFiles(db, ctx) ⇒

Promises to iterate over all the XML files and returns an aggregate promise that will be resolved when all the XML files are done, or rejected if at least one fails.

Kind: global function
Returns: Promise that resolves when all the individual promises of each file pass.

Param Type
db *
ctx *

loadSilabsZcl(db, ctx) ⇒

Toplevel function that loads the properties file and orchestrates the promise chain.

Kind: global function
Returns: a Promise that resolves with the db.

Param Type Description
db *
ctx * The context of loading.