Skip to content

Commit 203522d

Browse files
authored
Revert "Revert a reverted multi-protocol commit 61d328c" (#1299)
This reverts commit 61d328c. Fixing Custom XML issues: - Cleaning up the custom xml UI update as well as the custom xml package uploading such that there are no duplicates - Fixing the custom xml UI for attributes, commands and events when cluster extensions are added through custom xml. Needed the custom xml package ids to be included - Fixing the duplicate attributes and commands which show up in the attribute and command UI when a custom cluster with custom attributes and commands is added. This is solved by using a set in : reduceAndConcatenateZclEntity(db, id, [...new Set([...standAlonePackageIds, clusterInfo.packageRef])], - Adding unique constraint to Attribute table and adding insert or replace to attribute insert query such that custom cluster extensions are not reloaded into the db. - Making sure the global attributes are part of the custom clusters in static-zcl.js while calling reduceAndConcatenateZclEntity - Making sure that session partition numbering is correct for the partitionNumber column - For loading custom cluster extensions such as attributes and commands. Making sure they are loaded into the database based on the top level zcl package loaded. This is needed for sdk upgrades or custom xml in multi-protocol. See changes to zcl-loader-silabs and zcl-loader - When adding custom xml, there are instances where multiple zcl packages are loaded for the same xml file. This was an issue with the mutation observer. Getting the load new package call out of the observer to fix this. Reproducer: Open zap, add custom xml from extensions, close extensions pane, add another xml from extensions and you will see two instances of the xml added. If you add another xml then you see 3 instances. This is fixed in ZclCustomZclView.vue - Making sure that the delete button appears across custom xml for removal and doing some minor UI cleanup - Add more unit tests for custom xml - Cleaning up zap toolbar UI for logos - JIRA: ZAPP-1351
1 parent 0af7250 commit 203522d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+9391
-2652
lines changed

apack.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Graphical configuration tool for application and libraries based on Zigbee Cluster Library.",
55
"path": [".", "node_modules/.bin/", "ZAP.app/Contents/MacOS"],
66
"requiredFeatureLevel": "apack.core:9",
7-
"featureLevel": 100,
7+
"featureLevel": 101,
88
"uc.triggerExtension": "zap",
99
"executable": {
1010
"zap:win32.x86_64": {

docs/zap-schema.svg

+1,969-2,193
Loading

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"package-metadata": "node src-script/zap-package-metadata.js",
5959
"zap": "node src-script/zap-start.js --logToStdout --gen ./test/gen-template/zigbee/gen-templates.json",
6060
"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",
61+
"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",
6162
"zapzigbee": "node src-script/zap-start.js --logToStdout --zcl ./zcl-builtin/silabs/zcl.json --gen ./test/gen-template/zigbee/gen-templates.json",
6263
"zapmatter": "node src-script/zap-start.js --logToStdoutc --zcl ./zcl-builtin/matter/zcl.json --gen ./test/gen-template/matter/gen-test.json",
6364
"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",
@@ -66,6 +67,7 @@
6667
"zigbeezap-devserver": "node src-script/zap-start.js server --stateDirectory ~/.zap/zigbee-server/ --allowCors --logToStdout --gen ./test/gen-template/zigbee/gen-templates.json --reuseZapInstance",
6768
"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",
6869
"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",
70+
"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",
6971
"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 ",
7072
"stop": "node src-script/zap-start.js stop --reuseZapInstance",
7173
"status": "node src-script/zap-start.js status --reuseZapInstance",

src-electron/db/db-mapping.js

+48
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,23 @@ exports.map = {
384384
name: x.NAME,
385385
caption: x.DESCRIPTION,
386386
class: x.CLASS,
387+
packageRef: x.PACKAGE_REF,
388+
}
389+
},
390+
391+
deviceTypeExtended: (x) => {
392+
if (x == null) return undefined
393+
return {
394+
id: x.DEVICE_TYPE_ID,
395+
code: x.CODE,
396+
profileId: x.PROFILE_ID,
397+
domain: x.DOMAIN,
398+
label: x.NAME,
399+
name: x.NAME,
400+
caption: x.DESCRIPTION,
401+
class: x.CLASS,
402+
packageRef: x.PACKAGE_REF,
403+
category: x.CATEGORY,
387404
}
388405
},
389406

@@ -452,6 +469,25 @@ exports.map = {
452469
parentEndpointIdentifier: x.PARENT_ENDPOINT_IDENTIFIER,
453470
}
454471
},
472+
endpointExtended: (x) => {
473+
if (x == null) return undefined
474+
return {
475+
id: x.ENDPOINT_ID,
476+
endpointRef: x.ENDPOINT_ID,
477+
sessionRef: x.SESSION_REF,
478+
endpointIdentifier: x.ENDPOINT_IDENTIFIER,
479+
endpointId: x.ENDPOINT_IDENTIFIER,
480+
endpointTypeRef: x.ENDPOINT_TYPE_REF,
481+
profileId: x.PROFILE,
482+
networkId: x.NETWORK_IDENTIFIER,
483+
endpointVersion: x.DEVICE_VERSION, // Left for backwards compatibility
484+
deviceVersion: x.DEVICE_VERSION,
485+
deviceIdentifier: x.DEVICE_IDENTIFIER,
486+
parentRef: x.PARENT_ENDPOINT_REF,
487+
parentEndpointIdentifier: x.PARENT_ENDPOINT_IDENTIFIER,
488+
category: x.CATEGORY, // Category of the device type coming from the zcl package it belongs to.
489+
}
490+
},
455491
endpointType: (x) => {
456492
if (x == null) return undefined
457493
return {
@@ -643,6 +679,8 @@ exports.map = {
643679
sessionRef: x.SESSION_REF,
644680
required: x.REQUIRED,
645681
type: x.TYPE,
682+
sessionPartitionId: x.SESSION_PARTITION_ID,
683+
category: x.CATEGORY,
646684
}
647685
},
648686
sessionLog: (x) => {
@@ -664,6 +702,16 @@ exports.map = {
664702
newNotification: x.NEW_NOTIFICATION == 1,
665703
}
666704
},
705+
706+
sessionPartition: (x) => {
707+
if (x == null) return undefined
708+
return {
709+
sessionPartitionId: x.SESSION_PARTITION_ID,
710+
sessionRef: x.SESSION_REF,
711+
sessionPartitionNumber: x.SESSION_PARTITION_NUMBER,
712+
}
713+
},
714+
667715
user: (x) => {
668716
if (x == null) return undefined
669717
return {

src-electron/db/query-attribute.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1102,8 +1102,12 @@ INNER JOIN
11021102
CLUSTER
11031103
ON
11041104
ENDPOINT_TYPE_CLUSTER.CLUSTER_REF = CLUSTER.CLUSTER_ID
1105+
INNER JOIN
1106+
SESSION_PARTITION
1107+
ON
1108+
ENDPOINT_TYPE.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
11051109
WHERE
1106-
ENDPOINT_TYPE.SESSION_REF = ${sessionId}
1110+
SESSION_PARTITION.SESSION_REF = ${sessionId}
11071111
AND
11081112
ENDPOINT_TYPE_CLUSTER.ENABLED=1
11091113
AND

src-electron/db/query-cluster.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,12 @@ async function selectAllUserClustersWithTokenAttributes(
218218
CLUSTER
219219
ON
220220
ENDPOINT_TYPE_CLUSTER.CLUSTER_REF = CLUSTER.CLUSTER_ID
221+
INNER JOIN
222+
SESSION_PARTITION
223+
ON
224+
ENDPOINT_TYPE.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
221225
WHERE
222-
ENDPOINT_TYPE.SESSION_REF = ?
226+
SESSION_PARTITION.SESSION_REF = ?
223227
AND
224228
ENDPOINT_TYPE_CLUSTER.ENABLED=1
225229
AND

src-electron/db/query-config.js

+62-14
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const dbEnum = require('../../src-shared/db-enum.js')
2727
const queryZcl = require('./query-zcl.js')
2828
const queryUpgrade = require('../sdk/matter.js')
2929
const queryDeviceType = require('./query-device-type')
30+
const querySession = require('./query-session')
3031
const queryCommand = require('./query-command.js')
3132
const restApi = require('../../src-shared/rest-api.js')
3233
const _ = require('lodash')
@@ -576,16 +577,18 @@ async function selectCountOfEndpointsWithGivenEndpointIdentifier(
576577
/**
577578
* Promises to add an endpoint type.
578579
*
579-
* @export
580580
* @param {*} db
581-
* @param {*} sessionId
581+
* @param {*} sessionPartitionInfo
582582
* @param {*} name
583583
* @param {*} deviceTypeRef
584+
* @param {*} deviceTypeIdentifier
585+
* @param {*} deviceTypeVersion
586+
* @param {*} doTransaction
584587
* @returns Promise to update endpoints.
585588
*/
586589
async function insertEndpointType(
587590
db,
588-
sessionId,
591+
sessionPartitionInfo,
589592
name,
590593
deviceTypeRef,
591594
deviceTypeIdentifier,
@@ -604,8 +607,8 @@ async function insertEndpointType(
604607
// Insert endpoint type
605608
let newEndpointTypeId = await dbApi.dbInsert(
606609
db,
607-
'INSERT OR REPLACE INTO ENDPOINT_TYPE ( SESSION_REF, NAME ) VALUES ( ?, ?)',
608-
[sessionId, name]
610+
'INSERT OR REPLACE INTO ENDPOINT_TYPE ( SESSION_PARTITION_REF, NAME ) VALUES ( ?, ?)',
611+
[sessionPartitionInfo.sessionPartitionId, name]
609612
)
610613

611614
// Creating endpoint type and device type ref combinations along with order of insertion
@@ -635,7 +638,7 @@ async function insertEndpointType(
635638
db,
636639
'ERROR',
637640
isErrorStringPresent ? err.split('Error:')[1] : err,
638-
sessionId,
641+
sessionPartitionInfo.sessionRef,
639642
1,
640643
1
641644
)
@@ -656,7 +659,7 @@ async function insertEndpointType(
656659
for (const dtRef of deviceTypeRefs) {
657660
await setEndpointDefaults(
658661
db,
659-
sessionId,
662+
sessionPartitionInfo.sessionRef,
660663
newEndpointTypeId,
661664
dtRef,
662665
doTransaction
@@ -679,7 +682,8 @@ async function duplicateEndpointType(db, endpointTypeId) {
679682
db,
680683
`
681684
SELECT
682-
ENDPOINT_TYPE.SESSION_REF,
685+
SESSION_PARTITION.SESSION_REF,
686+
SESSION_PARTITION.SESSION_PARTITION_ID,
683687
ENDPOINT_TYPE.NAME,
684688
ENDPOINT_TYPE_DEVICE.DEVICE_TYPE_REF,
685689
ENDPOINT_TYPE_DEVICE.DEVICE_IDENTIFIER,
@@ -690,6 +694,10 @@ async function duplicateEndpointType(db, endpointTypeId) {
690694
ENDPOINT_TYPE_DEVICE
691695
ON
692696
ENDPOINT_TYPE.ENDPOINT_TYPE_ID = ENDPOINT_TYPE_DEVICE.ENDPOINT_TYPE_REF
697+
INNER JOIN
698+
SESSION_PARTITION
699+
ON
700+
ENDPOINT_TYPE.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
693701
WHERE
694702
ENDPOINT_TYPE_DEVICE.ENDPOINT_TYPE_REF = ?`,
695703
[endpointTypeId]
@@ -699,9 +707,12 @@ async function duplicateEndpointType(db, endpointTypeId) {
699707
// Enter into the endpoint_type table
700708
newEndpointTypeId = await dbApi.dbInsert(
701709
db,
702-
`INSERT INTO ENDPOINT_TYPE (SESSION_REF, NAME)
710+
`INSERT INTO ENDPOINT_TYPE (SESSION_PARTITION_REF, NAME)
703711
VALUES (?, ?)`,
704-
[endpointTypeDeviceInfo[0].SESSION_REF, endpointTypeDeviceInfo[0].NAME]
712+
[
713+
endpointTypeDeviceInfo[0].SESSION_PARTITION_ID,
714+
endpointTypeDeviceInfo[0].NAME,
715+
]
705716
)
706717

707718
// Enter into the endpoint_type_device table to establish the endpoint_type
@@ -758,8 +769,12 @@ async function updateEndpointType(db, sessionId, endpointTypeId, changesArray) {
758769
INNER JOIN
759770
ENDPOINT_TYPE_DEVICE
760771
ON ENDPOINT_TYPE.ENDPOINT_TYPE_ID = ENDPOINT_TYPE_DEVICE.ENDPOINT_TYPE_REF
772+
INNER JOIN
773+
SESSION_PARTITION
774+
ON
775+
ENDPOINT_TYPE.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
761776
WHERE
762-
ENDPOINT_TYPE_ID = ? AND SESSION_REF = ?
777+
ENDPOINT_TYPE.ENDPOINT_TYPE_ID = ? AND SESSION_PARTITION.SESSION_REF = ?
763778
ORDER BY
764779
ENDPOINT_TYPE_DEVICE.DEVICE_TYPE_ORDER`,
765780
[endpointTypeId, sessionId]
@@ -873,7 +888,10 @@ async function updateEndpointType(db, sessionId, endpointTypeId, changesArray) {
873888
/**
874889
* Promise to set the default attributes and clusters for a endpoint type.
875890
* @param {*} db
891+
* @param {*} sessionId
876892
* @param {*} endpointTypeId
893+
* @param {*} deviceTypeRef
894+
* @param {*} doTransaction
877895
*/
878896
async function setEndpointDefaults(
879897
db,
@@ -893,7 +911,20 @@ async function setEndpointDefaults(
893911
if (pkgs == null || pkgs.length < 1)
894912
throw new Error('Could not locate package id for a given session.')
895913

914+
let deviceTypeInfo =
915+
await querySession.selectDeviceTypePackageInfoFromDeviceTypeId(
916+
db,
917+
deviceTypeRef
918+
)
919+
let endpointTypeCategory =
920+
deviceTypeInfo.length > 0 ? deviceTypeInfo[0].category : null
896921
let packageId = pkgs[0].id
922+
for (let i = 0; i < pkgs.length; i++) {
923+
if (pkgs[i].category == endpointTypeCategory) {
924+
packageId = pkgs[i].id
925+
break
926+
}
927+
}
897928
let clusters = await queryDeviceType.selectDeviceTypeClustersByDeviceTypeRef(
898929
db,
899930
deviceTypeRef
@@ -1216,7 +1247,16 @@ async function resolveNonOptionalAndReportableAttributes(
12161247
async function selectEndpointTypeCount(db, sessionId) {
12171248
let x = await dbApi.dbGet(
12181249
db,
1219-
'SELECT COUNT(ENDPOINT_TYPE_ID) AS CNT FROM ENDPOINT_TYPE WHERE SESSION_REF = ?',
1250+
`SELECT
1251+
COUNT(ENDPOINT_TYPE_ID) AS CNT
1252+
FROM
1253+
ENDPOINT_TYPE
1254+
INNER JOIN
1255+
SESSION_PARTITION
1256+
ON
1257+
SESSION_PARTITION.SESSION_PARTITION_ID = ENDPOINT_TYPE.SESSION_PARTITION_REF
1258+
WHERE
1259+
SESSION_PARTITION.SESSION_REF = ?`,
12201260
[sessionId]
12211261
)
12221262
return x['CNT']
@@ -1243,7 +1283,11 @@ SELECT
12431283
COUNT(ENDPOINT_TYPE_ID)
12441284
FROM
12451285
ENDPOINT_TYPE
1246-
WHERE SESSION_REF = ?
1286+
INNER JOIN
1287+
SESSION_PARTITION
1288+
ON
1289+
SESSION_PARTITION.SESSION_PARTITION_ID = ENDPOINT_TYPE.SESSION_PARTITION_REF
1290+
WHERE SESSION_PARTITION.SESSION_REF = ?
12471291
AND ENDPOINT_TYPE_ID IN
12481292
(SELECT ENDPOINT_TYPE_REF
12491293
FROM ENDPOINT_TYPE_CLUSTER
@@ -1404,8 +1448,12 @@ JOIN
14041448
ATTRIBUTE AS A ON ETA.ATTRIBUTE_REF = A.ATTRIBUTE_ID
14051449
JOIN
14061450
ENDPOINT_TYPE AS ET ON ETA.ENDPOINT_TYPE_REF = ET.ENDPOINT_TYPE_ID
1451+
INNER JOIN
1452+
SESSION_PARTITION
1453+
ON
1454+
ET.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
14071455
WHERE
1408-
ET.SESSION_REF = ? AND ETA.INCLUDED = 1
1456+
SESSION_PARTITION.SESSION_REF = ? AND ETA.INCLUDED = 1
14091457
ORDER BY
14101458
CLUSTER_CODE, ATTRIBUTE_CODE
14111459
`,

src-electron/db/query-device-type.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ const dbMapping = require('./db-mapping')
2626
/**
2727
* Retrieves all the device types in the database.
2828
*
29-
* @export
3029
* @param {*} db
30+
* @param {*} packageId
3131
* @returns Promise that resolves with the rows of device types.
3232
*/
3333
async function selectAllDeviceTypes(db, packageId) {
3434
return dbApi
3535
.dbAll(
3636
db,
37-
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION, CLASS FROM DEVICE_TYPE WHERE PACKAGE_REF = ? ORDER BY DOMAIN, CODE',
37+
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION, CLASS, PACKAGE_REF FROM DEVICE_TYPE WHERE PACKAGE_REF = ? ORDER BY DOMAIN, CODE',
3838
[packageId]
3939
)
4040
.then((rows) => rows.map(dbMapping.map.deviceType))
@@ -51,7 +51,7 @@ async function selectDeviceTypeById(db, id) {
5151
return dbApi
5252
.dbGet(
5353
db,
54-
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION, CLASS FROM DEVICE_TYPE WHERE DEVICE_TYPE_ID = ?',
54+
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION, CLASS, PACKAGE_REF FROM DEVICE_TYPE WHERE DEVICE_TYPE_ID = ?',
5555
[id]
5656
)
5757
.then(dbMapping.map.deviceType)

0 commit comments

Comments
 (0)