Skip to content

Commit 06d1428

Browse files
authored
ZAP: Multi-protocol Configurator Integration (#1276)
> - Schema changes such that sessions now have session partitions to allow multiple zcl and template config files. > - Session packages and endpoint types are now linked to a session partition such that generation and UI can be made exclusive to the device type selected on an endpoint > - All relevant queries have been updated with session partition > - imp-exp of .zap files is taken into account here as well > - ZAP Generation can now generate the corresponding templates based on the category of the device type and the category of the generation templates eg: matter or zigbee. The same goes for UI > - All existing tests pass with these changes - Fixing the cluster view when multiple zcl device types are selected - ZAP: Opening existing .zap files does not allow multi-device type selection - Fixing sessionAttempt in initialize.js and cleaning up the packages from the session in jsonDataLoader function in import-json fixed this - Other minor cleanup - Fixing CMP generation for command line in startup.js#generateSingleFile such that it generates for all generation template json files and not just one of them - bumping the feature level of zap - Adding the reference to parentEndpointRef in endpoint extended in db-mapping due to rebase and also fixing the selectAllEndpointsBasedOnTemplateCategory for the same - Cleaning up session package and session partitions to avoid having the wrong session packages and partitions in deleteAllSessionPackages - Cleaning up query-session#ensureBlankSession - Fixing the zap schema for command trigger warnings when adding endpoints - Fixing the parent-endpoint.test.js just like the rest with session partition info - Fixing the default attribute enablement based on catgeory such as matter/zigbee for global attributes other minor cleanup - Not showing the extensions tab in case of multi-protocol since it is currently not supported, see ZCLToolbar.vue - Showing all logos based on the categories from the zcl files selected, see ZCLToolbar.vue - Added multi-protocol tests, see multi-protocol.test.js, multi-protocol.zap, test-utils.js - Removed lo-devices.xml from the zcl-with-extensions.json matter file to test multi-protocol more efficiently since for generation as is the case in reality as well. - Fixing calls to insertEndpointType with device type params in query.test.js - Fix cypress tests for vue tour which was happening due to category(zigbee/matter) not being picked from zcl properties files. Also handling the default use case when category is not found - Calling this..dispatch('zap/updateClusters') in vue tour after update to endpoint type due to multi-protocol changes - Fixing the default use case for showing and not showing UI elements in ui-options.js - Fixing server-bare.test.js when inserting a package along with some other minor cleanup which is needed - Fix the server-bare.test.js - Improving the session creation and package selection process in the UI via ZapConfig.vue changes - Pre-selecting the package files which exist in ZapConfig.vue. Also now showing package selection view if the packages which exist in the db are the same as the ones in the .zap file. - Showing a warning in the custom xml page when a multi-proptocol config is open since custom xml is not currently supported for custom xml. See ZclCustomZclView.vue - JIRA: ZAPP-1216
1 parent a7b6141 commit 06d1428

Some content is hidden

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

61 files changed

+9283
-2641
lines changed

apack.json

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1969 additions & 2193 deletions
Loading

package.json

Lines changed: 2 additions & 0 deletions
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

Lines changed: 48 additions & 0 deletions
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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,8 +1103,12 @@ INNER JOIN
11031103
CLUSTER
11041104
ON
11051105
ENDPOINT_TYPE_CLUSTER.CLUSTER_REF = CLUSTER.CLUSTER_ID
1106+
INNER JOIN
1107+
SESSION_PARTITION
1108+
ON
1109+
ENDPOINT_TYPE.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
11061110
WHERE
1107-
ENDPOINT_TYPE.SESSION_REF = ${sessionId}
1111+
SESSION_PARTITION.SESSION_REF = ${sessionId}
11081112
AND
11091113
ENDPOINT_TYPE_CLUSTER.ENABLED=1
11101114
AND

src-electron/db/query-cluster.js

Lines changed: 5 additions & 1 deletion
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

Lines changed: 62 additions & 14 deletions
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('../matter/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')
@@ -575,16 +576,18 @@ async function selectCountOfEndpointsWithGivenEndpointIdentifier(
575576
/**
576577
* Promises to add an endpoint type.
577578
*
578-
* @export
579579
* @param {*} db
580-
* @param {*} sessionId
580+
* @param {*} sessionPartitionInfo
581581
* @param {*} name
582582
* @param {*} deviceTypeRef
583+
* @param {*} deviceTypeIdentifier
584+
* @param {*} deviceTypeVersion
585+
* @param {*} doTransaction
583586
* @returns Promise to update endpoints.
584587
*/
585588
async function insertEndpointType(
586589
db,
587-
sessionId,
590+
sessionPartitionInfo,
588591
name,
589592
deviceTypeRef,
590593
deviceTypeIdentifier,
@@ -603,8 +606,8 @@ async function insertEndpointType(
603606
// Insert endpoint type
604607
let newEndpointTypeId = await dbApi.dbInsert(
605608
db,
606-
'INSERT OR REPLACE INTO ENDPOINT_TYPE ( SESSION_REF, NAME ) VALUES ( ?, ?)',
607-
[sessionId, name]
609+
'INSERT OR REPLACE INTO ENDPOINT_TYPE ( SESSION_PARTITION_REF, NAME ) VALUES ( ?, ?)',
610+
[sessionPartitionInfo.sessionPartitionId, name]
608611
)
609612

610613
// Creating endpoint type and device type ref combinations along with order of insertion
@@ -634,7 +637,7 @@ async function insertEndpointType(
634637
db,
635638
'ERROR',
636639
isErrorStringPresent ? err.split('Error:')[1] : err,
637-
sessionId,
640+
sessionPartitionInfo.sessionRef,
638641
1,
639642
1
640643
)
@@ -655,7 +658,7 @@ async function insertEndpointType(
655658
for (const dtRef of deviceTypeRefs) {
656659
await setEndpointDefaults(
657660
db,
658-
sessionId,
661+
sessionPartitionInfo.sessionRef,
659662
newEndpointTypeId,
660663
dtRef,
661664
doTransaction
@@ -678,7 +681,8 @@ async function duplicateEndpointType(db, endpointTypeId) {
678681
db,
679682
`
680683
SELECT
681-
ENDPOINT_TYPE.SESSION_REF,
684+
SESSION_PARTITION.SESSION_REF,
685+
SESSION_PARTITION.SESSION_PARTITION_ID,
682686
ENDPOINT_TYPE.NAME,
683687
ENDPOINT_TYPE_DEVICE.DEVICE_TYPE_REF,
684688
ENDPOINT_TYPE_DEVICE.DEVICE_IDENTIFIER,
@@ -689,6 +693,10 @@ async function duplicateEndpointType(db, endpointTypeId) {
689693
ENDPOINT_TYPE_DEVICE
690694
ON
691695
ENDPOINT_TYPE.ENDPOINT_TYPE_ID = ENDPOINT_TYPE_DEVICE.ENDPOINT_TYPE_REF
696+
INNER JOIN
697+
SESSION_PARTITION
698+
ON
699+
ENDPOINT_TYPE.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
692700
WHERE
693701
ENDPOINT_TYPE_DEVICE.ENDPOINT_TYPE_REF = ?`,
694702
[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_REF,
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

Lines changed: 3 additions & 3 deletions
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)