Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/fix custom xml issues/zapp 1351 #1299

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apack.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Graphical configuration tool for application and libraries based on Zigbee Cluster Library.",
"path": [".", "node_modules/.bin/", "ZAP.app/Contents/MacOS"],
"requiredFeatureLevel": "apack.core:9",
"featureLevel": 100,
"featureLevel": 101,
"uc.triggerExtension": "zap",
"executable": {
"zap:win32.x86_64": {
Expand Down
4,162 changes: 1,969 additions & 2,193 deletions docs/zap-schema.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"package-metadata": "node src-script/zap-package-metadata.js",
"zap": "node src-script/zap-start.js --logToStdout --gen ./test/gen-template/zigbee/gen-templates.json",
"zapall": "node src-script/zap-start.js --logToStdout --zcl ./test/resource/meta/zcl.json --zcl ./zcl-builtin/silabs/zcl.json --zcl ./zcl-builtin/matter/zcl.json --gen ./test/gen-template/zigbee/gen-templates.json --gen ./test/gen-template/matter/gen-test.json --gen ./test/resource/meta/gen-test.json",
"zapmultiprotocol": "node src-script/zap-start.js --logToStdout --zcl ./zcl-builtin/silabs/zcl.json --zcl ./zcl-builtin/matter/zcl-with-test-extensions.json --gen ./test/gen-template/zigbee/gen-templates.json --gen ./test/gen-template/matter/gen-test.json",
"zapzigbee": "node src-script/zap-start.js --logToStdout --zcl ./zcl-builtin/silabs/zcl.json --gen ./test/gen-template/zigbee/gen-templates.json",
"zapmatter": "node src-script/zap-start.js --logToStdoutc --zcl ./zcl-builtin/matter/zcl.json --gen ./test/gen-template/matter/gen-test.json",
"zapmeta": "node src-script/zap-start.js --logToStdout --zcl ./test/resource/meta/zcl.json --gen ./test/resource/meta/gen-test.json --in ./test/resource/test-meta.zap",
Expand All @@ -66,6 +67,7 @@
"zigbeezap-devserver": "node src-script/zap-start.js server --stateDirectory ~/.zap/zigbee-server/ --allowCors --logToStdout --gen ./test/gen-template/zigbee/gen-templates.json --reuseZapInstance",
"matterzap-devserver": "node src-script/zap-start.js server --stateDirectory ~/.zap/matter-server/ --allowCors --logToStdout --zcl ./zcl-builtin/matter/zcl.json --gen ./test/resource/meta/gen-test.json --reuseZapInstance",
"matterzap-devserver2": "node src-script/zap-start.js server --stateDirectory --zcl ./zcl-builtin/matter/zcl.json --allowCors --logToStdout --gen ./test/gen-template/matter3/t.json --reuseZapInstance",
"zapall-devserver": "node src-script/zap-start.js server --stateDirectory --zcl ./zcl-builtin/silabs/zcl.json --zcl ./zcl-builtin/matter/zcl.json --allowCors --logToStdout --gen ./test/gen-template/zigbee/gen-templates.json --gen ./test/gen-template/matter/gen-test.json --gen --reuseZapInstance",
"server": "node src-script/zap-start.js server --stateDirectory ~/.zap/server/ --allowCors --logToStdout --zcl ./zcl-builtin/silabs/zcl.json --zcl ./zcl-builtin/matter/zcl.json --gen ./test/gen-template/zigbee/gen-templates.json --gen ./test/gen-template/matter/gen-test.json ",
"stop": "node src-script/zap-start.js stop --reuseZapInstance",
"status": "node src-script/zap-start.js status --reuseZapInstance",
Expand Down
48 changes: 48 additions & 0 deletions src-electron/db/db-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,23 @@ exports.map = {
name: x.NAME,
caption: x.DESCRIPTION,
class: x.CLASS,
packageRef: x.PACKAGE_REF,
}
},

deviceTypeExtended: (x) => {
if (x == null) return undefined
return {
id: x.DEVICE_TYPE_ID,
code: x.CODE,
profileId: x.PROFILE_ID,
domain: x.DOMAIN,
label: x.NAME,
name: x.NAME,
caption: x.DESCRIPTION,
class: x.CLASS,
packageRef: x.PACKAGE_REF,
category: x.CATEGORY,
}
},

Expand Down Expand Up @@ -452,6 +469,25 @@ exports.map = {
parentEndpointIdentifier: x.PARENT_ENDPOINT_IDENTIFIER,
}
},
endpointExtended: (x) => {
if (x == null) return undefined
return {
id: x.ENDPOINT_ID,
endpointRef: x.ENDPOINT_ID,
sessionRef: x.SESSION_REF,
endpointIdentifier: x.ENDPOINT_IDENTIFIER,
endpointId: x.ENDPOINT_IDENTIFIER,
endpointTypeRef: x.ENDPOINT_TYPE_REF,
profileId: x.PROFILE,
networkId: x.NETWORK_IDENTIFIER,
endpointVersion: x.DEVICE_VERSION, // Left for backwards compatibility
deviceVersion: x.DEVICE_VERSION,
deviceIdentifier: x.DEVICE_IDENTIFIER,
parentRef: x.PARENT_ENDPOINT_REF,
parentEndpointIdentifier: x.PARENT_ENDPOINT_IDENTIFIER,
category: x.CATEGORY, // Category of the device type coming from the zcl package it belongs to.
}
},
endpointType: (x) => {
if (x == null) return undefined
return {
Expand Down Expand Up @@ -643,6 +679,8 @@ exports.map = {
sessionRef: x.SESSION_REF,
required: x.REQUIRED,
type: x.TYPE,
sessionPartitionId: x.SESSION_PARTITION_ID,
category: x.CATEGORY,
}
},
sessionLog: (x) => {
Expand All @@ -664,6 +702,16 @@ exports.map = {
newNotification: x.NEW_NOTIFICATION == 1,
}
},

sessionPartition: (x) => {
if (x == null) return undefined
return {
sessionPartitionId: x.SESSION_PARTITION_ID,
sessionRef: x.SESSION_REF,
sessionPartitionNumber: x.SESSION_PARTITION_NUMBER,
}
},

user: (x) => {
if (x == null) return undefined
return {
Expand Down
6 changes: 5 additions & 1 deletion src-electron/db/query-attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,12 @@ INNER JOIN
CLUSTER
ON
ENDPOINT_TYPE_CLUSTER.CLUSTER_REF = CLUSTER.CLUSTER_ID
INNER JOIN
SESSION_PARTITION
ON
ENDPOINT_TYPE.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
WHERE
ENDPOINT_TYPE.SESSION_REF = ${sessionId}
SESSION_PARTITION.SESSION_REF = ${sessionId}
AND
ENDPOINT_TYPE_CLUSTER.ENABLED=1
AND
Expand Down
6 changes: 5 additions & 1 deletion src-electron/db/query-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,12 @@ async function selectAllUserClustersWithTokenAttributes(
CLUSTER
ON
ENDPOINT_TYPE_CLUSTER.CLUSTER_REF = CLUSTER.CLUSTER_ID
INNER JOIN
SESSION_PARTITION
ON
ENDPOINT_TYPE.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
WHERE
ENDPOINT_TYPE.SESSION_REF = ?
SESSION_PARTITION.SESSION_REF = ?
AND
ENDPOINT_TYPE_CLUSTER.ENABLED=1
AND
Expand Down
76 changes: 62 additions & 14 deletions src-electron/db/query-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const dbEnum = require('../../src-shared/db-enum.js')
const queryZcl = require('./query-zcl.js')
const queryUpgrade = require('../sdk/matter.js')
const queryDeviceType = require('./query-device-type')
const querySession = require('./query-session')
const queryCommand = require('./query-command.js')
const restApi = require('../../src-shared/rest-api.js')
const _ = require('lodash')
Expand Down Expand Up @@ -576,16 +577,18 @@ async function selectCountOfEndpointsWithGivenEndpointIdentifier(
/**
* Promises to add an endpoint type.
*
* @export
* @param {*} db
* @param {*} sessionId
* @param {*} sessionPartitionInfo
* @param {*} name
* @param {*} deviceTypeRef
* @param {*} deviceTypeIdentifier
* @param {*} deviceTypeVersion
* @param {*} doTransaction
* @returns Promise to update endpoints.
*/
async function insertEndpointType(
db,
sessionId,
sessionPartitionInfo,
name,
deviceTypeRef,
deviceTypeIdentifier,
Expand All @@ -604,8 +607,8 @@ async function insertEndpointType(
// Insert endpoint type
let newEndpointTypeId = await dbApi.dbInsert(
db,
'INSERT OR REPLACE INTO ENDPOINT_TYPE ( SESSION_REF, NAME ) VALUES ( ?, ?)',
[sessionId, name]
'INSERT OR REPLACE INTO ENDPOINT_TYPE ( SESSION_PARTITION_REF, NAME ) VALUES ( ?, ?)',
[sessionPartitionInfo.sessionPartitionId, name]
)

// Creating endpoint type and device type ref combinations along with order of insertion
Expand Down Expand Up @@ -635,7 +638,7 @@ async function insertEndpointType(
db,
'ERROR',
isErrorStringPresent ? err.split('Error:')[1] : err,
sessionId,
sessionPartitionInfo.sessionRef,
1,
1
)
Expand All @@ -656,7 +659,7 @@ async function insertEndpointType(
for (const dtRef of deviceTypeRefs) {
await setEndpointDefaults(
db,
sessionId,
sessionPartitionInfo.sessionRef,
newEndpointTypeId,
dtRef,
doTransaction
Expand All @@ -679,7 +682,8 @@ async function duplicateEndpointType(db, endpointTypeId) {
db,
`
SELECT
ENDPOINT_TYPE.SESSION_REF,
SESSION_PARTITION.SESSION_REF,
SESSION_PARTITION.SESSION_PARTITION_ID,
ENDPOINT_TYPE.NAME,
ENDPOINT_TYPE_DEVICE.DEVICE_TYPE_REF,
ENDPOINT_TYPE_DEVICE.DEVICE_IDENTIFIER,
Expand All @@ -690,6 +694,10 @@ async function duplicateEndpointType(db, endpointTypeId) {
ENDPOINT_TYPE_DEVICE
ON
ENDPOINT_TYPE.ENDPOINT_TYPE_ID = ENDPOINT_TYPE_DEVICE.ENDPOINT_TYPE_REF
INNER JOIN
SESSION_PARTITION
ON
ENDPOINT_TYPE.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
WHERE
ENDPOINT_TYPE_DEVICE.ENDPOINT_TYPE_REF = ?`,
[endpointTypeId]
Expand All @@ -699,9 +707,12 @@ async function duplicateEndpointType(db, endpointTypeId) {
// Enter into the endpoint_type table
newEndpointTypeId = await dbApi.dbInsert(
db,
`INSERT INTO ENDPOINT_TYPE (SESSION_REF, NAME)
`INSERT INTO ENDPOINT_TYPE (SESSION_PARTITION_REF, NAME)
VALUES (?, ?)`,
[endpointTypeDeviceInfo[0].SESSION_REF, endpointTypeDeviceInfo[0].NAME]
[
endpointTypeDeviceInfo[0].SESSION_PARTITION_ID,
endpointTypeDeviceInfo[0].NAME,
]
)

// Enter into the endpoint_type_device table to establish the endpoint_type
Expand Down Expand Up @@ -758,8 +769,12 @@ async function updateEndpointType(db, sessionId, endpointTypeId, changesArray) {
INNER JOIN
ENDPOINT_TYPE_DEVICE
ON ENDPOINT_TYPE.ENDPOINT_TYPE_ID = ENDPOINT_TYPE_DEVICE.ENDPOINT_TYPE_REF
INNER JOIN
SESSION_PARTITION
ON
ENDPOINT_TYPE.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
WHERE
ENDPOINT_TYPE_ID = ? AND SESSION_REF = ?
ENDPOINT_TYPE.ENDPOINT_TYPE_ID = ? AND SESSION_PARTITION.SESSION_REF = ?
ORDER BY
ENDPOINT_TYPE_DEVICE.DEVICE_TYPE_ORDER`,
[endpointTypeId, sessionId]
Expand Down Expand Up @@ -873,7 +888,10 @@ async function updateEndpointType(db, sessionId, endpointTypeId, changesArray) {
/**
* Promise to set the default attributes and clusters for a endpoint type.
* @param {*} db
* @param {*} sessionId
* @param {*} endpointTypeId
* @param {*} deviceTypeRef
* @param {*} doTransaction
*/
async function setEndpointDefaults(
db,
Expand All @@ -893,7 +911,20 @@ async function setEndpointDefaults(
if (pkgs == null || pkgs.length < 1)
throw new Error('Could not locate package id for a given session.')

let deviceTypeInfo =
await querySession.selectDeviceTypePackageInfoFromDeviceTypeId(
db,
deviceTypeRef
)
let endpointTypeCategory =
deviceTypeInfo.length > 0 ? deviceTypeInfo[0].category : null
let packageId = pkgs[0].id
for (let i = 0; i < pkgs.length; i++) {
if (pkgs[i].category == endpointTypeCategory) {
packageId = pkgs[i].id
break
}
}
let clusters = await queryDeviceType.selectDeviceTypeClustersByDeviceTypeRef(
db,
deviceTypeRef
Expand Down Expand Up @@ -1216,7 +1247,16 @@ async function resolveNonOptionalAndReportableAttributes(
async function selectEndpointTypeCount(db, sessionId) {
let x = await dbApi.dbGet(
db,
'SELECT COUNT(ENDPOINT_TYPE_ID) AS CNT FROM ENDPOINT_TYPE WHERE SESSION_REF = ?',
`SELECT
COUNT(ENDPOINT_TYPE_ID) AS CNT
FROM
ENDPOINT_TYPE
INNER JOIN
SESSION_PARTITION
ON
SESSION_PARTITION.SESSION_PARTITION_ID = ENDPOINT_TYPE.SESSION_PARTITION_REF
WHERE
SESSION_PARTITION.SESSION_REF = ?`,
[sessionId]
)
return x['CNT']
Expand All @@ -1243,7 +1283,11 @@ SELECT
COUNT(ENDPOINT_TYPE_ID)
FROM
ENDPOINT_TYPE
WHERE SESSION_REF = ?
INNER JOIN
SESSION_PARTITION
ON
SESSION_PARTITION.SESSION_PARTITION_ID = ENDPOINT_TYPE.SESSION_PARTITION_REF
WHERE SESSION_PARTITION.SESSION_REF = ?
AND ENDPOINT_TYPE_ID IN
(SELECT ENDPOINT_TYPE_REF
FROM ENDPOINT_TYPE_CLUSTER
Expand Down Expand Up @@ -1404,8 +1448,12 @@ JOIN
ATTRIBUTE AS A ON ETA.ATTRIBUTE_REF = A.ATTRIBUTE_ID
JOIN
ENDPOINT_TYPE AS ET ON ETA.ENDPOINT_TYPE_REF = ET.ENDPOINT_TYPE_ID
INNER JOIN
SESSION_PARTITION
ON
ET.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
WHERE
ET.SESSION_REF = ? AND ETA.INCLUDED = 1
SESSION_PARTITION.SESSION_REF = ? AND ETA.INCLUDED = 1
ORDER BY
CLUSTER_CODE, ATTRIBUTE_CODE
`,
Expand Down
6 changes: 3 additions & 3 deletions src-electron/db/query-device-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ const dbMapping = require('./db-mapping')
/**
* Retrieves all the device types in the database.
*
* @export
* @param {*} db
* @param {*} packageId
* @returns Promise that resolves with the rows of device types.
*/
async function selectAllDeviceTypes(db, packageId) {
return dbApi
.dbAll(
db,
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION, CLASS FROM DEVICE_TYPE WHERE PACKAGE_REF = ? ORDER BY DOMAIN, CODE',
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION, CLASS, PACKAGE_REF FROM DEVICE_TYPE WHERE PACKAGE_REF = ? ORDER BY DOMAIN, CODE',
[packageId]
)
.then((rows) => rows.map(dbMapping.map.deviceType))
Expand All @@ -51,7 +51,7 @@ async function selectDeviceTypeById(db, id) {
return dbApi
.dbGet(
db,
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION, CLASS FROM DEVICE_TYPE WHERE DEVICE_TYPE_ID = ?',
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION, CLASS, PACKAGE_REF FROM DEVICE_TYPE WHERE DEVICE_TYPE_ID = ?',
[id]
)
.then(dbMapping.map.deviceType)
Expand Down
Loading
Loading