Skip to content

Commit

Permalink
Adding support for Quality tag in Commands
Browse files Browse the repository at this point in the history
* Added support for qualities in commands
* Added isLargeMessage quality
* Modified relevant queries and template helpers
* Also fixed issues with loading of attribute qualities
* Added tests for both command and attribute qualities
  • Loading branch information
dhchandw committed Oct 22, 2024
1 parent 3ef94ba commit d2e28b6
Show file tree
Hide file tree
Showing 13 changed files with 2,913 additions and 2,314 deletions.
10 changes: 6 additions & 4 deletions src-electron/db/db-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ exports.map = {
isArray: x.ARRAY_TYPE ? 1 : 0,
mustUseTimedWrite: dbApi.fromDbBool(x.MUST_USE_TIMED_WRITE),
apiMaturity: x.API_MATURITY,
isChangeComitted: dbApi.fromDbBool(x.IS_CHANGE_COMITTED),
isChangeOmitted: dbApi.fromDbBool(x.IS_CHANGE_OMITTED),
persistence: x.PERSISTENCE
}
},
Expand Down Expand Up @@ -215,7 +215,8 @@ exports.map = {
hasSpecificResponse: dbApi.toDbBool(x.RESPONSE_REF),
isIncoming: x.INCOMING,
isOutgoing: x.OUTGOING,
isDefaultResponseEnabled: x.IS_DEFAULT_RESPONSE_ENABLED
isDefaultResponseEnabled: x.IS_DEFAULT_RESPONSE_ENABLED,
isLargeMessage: dbApi.fromDbBool(x.IS_LARGE_MESSAGE)
}
},

Expand Down Expand Up @@ -686,7 +687,7 @@ exports.map = {
tokenId: x.TOKEN_ID, // Endpoint type attribute's token id
type: x.TYPE != 'array' ? x.TYPE : x.ARRAY_TYPE, // Attribute type
apiMaturity: x.API_MATURITY,
isChangeComitted: x.IS_CHANGE_COMITTED,
isChangeOmitted: dbApi.fromDbBool(x.IS_CHANGE_OMITTED),
persistence: x.PERSISTENCE
}
},
Expand All @@ -700,7 +701,8 @@ exports.map = {
incoming: dbApi.fromDbBool(x.INCOMING),
outgoing: dbApi.fromDbBool(x.OUTGOING),
isIncoming: dbApi.fromDbBool(x.IS_INCOMING),
isEnabled: dbApi.fromDbBool(x.IS_ENABLED)
isEnabled: dbApi.fromDbBool(x.IS_ENABLED),
isLargeMessage: dbApi.fromDbBool(x.IS_LARGE_MESSAGE)
}
},

Expand Down
8 changes: 4 additions & 4 deletions src-electron/db/query-attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ async function selectAllAttributeDetailsFromEnabledClusters(
ENDPOINT_TYPE_ATTRIBUTE.MAX_INTERVAL,
ENDPOINT_TYPE_ATTRIBUTE.REPORTABLE_CHANGE,
ATTRIBUTE.API_MATURITY,
ATTRIBUTE.IS_CHANGE_COMITTED,
ATTRIBUTE.IS_CHANGE_OMITTED,
ATTRIBUTE.PERSISTENCE
FROM ATTRIBUTE
INNER JOIN ENDPOINT_TYPE_ATTRIBUTE
Expand Down Expand Up @@ -259,7 +259,7 @@ async function selectAttributeDetailsFromAllEndpointTypesAndClustersUtil(
CLUSTER.NAME AS CLUSTER_NAME,
ENDPOINT_TYPE_CLUSTER.ENABLED,
ATTRIBUTE.API_MATURITY,
ATTRIBUTE.IS_CHANGE_COMITTED,
ATTRIBUTE.IS_CHANGE_OMITTED,
ATTRIBUTE.PERSISTENCE
FROM
ATTRIBUTE
Expand Down Expand Up @@ -882,7 +882,7 @@ SELECT
A.ARRAY_TYPE,
A.MUST_USE_TIMED_WRITE,
A.API_MATURITY,
A.IS_CHANGE_COMITTED,
A.IS_CHANGE_OMITTED,
A.PERSISTENCE
FROM ATTRIBUTE AS A
INNER JOIN CLUSTER AS C
Expand Down Expand Up @@ -949,7 +949,7 @@ SELECT
A.ARRAY_TYPE,
A.MUST_USE_TIMED_WRITE,
A.API_MATURITY,
A.IS_CHANGE_COMITTED,
A.IS_CHANGE_OMITTED,
A.PERSISTENCE
FROM ATTRIBUTE AS A
WHERE A.PACKAGE_REF IN (${dbApi.toInClause(packageIds)})
Expand Down
15 changes: 12 additions & 3 deletions src-electron/db/query-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,8 @@ async function selectNonGlobalCommandByCode(
C.MUST_USE_TIMED_INVOKE,
C.IS_FABRIC_SCOPED,
C.RESPONSE_REF,
C.RESPONSE_NAME
C.RESPONSE_NAME,
C.IS_LARGE_MESSAGE
FROM COMMAND AS C
INNER JOIN CLUSTER AS CL
ON CL.CLUSTER_ID = C.CLUSTER_REF
Expand Down Expand Up @@ -935,7 +936,8 @@ async function selectGlobalCommandByCode(
C.MUST_USE_TIMED_INVOKE,
C.IS_FABRIC_SCOPED,
C.RESPONSE_REF,
C.RESPONSE_NAME
C.RESPONSE_NAME,
C.IS_LARGE_MESSAGE
FROM
COMMAND AS C
WHERE
Expand Down Expand Up @@ -1012,6 +1014,7 @@ SELECT
COMMAND.RESPONSE_REF,
COMMAND.RESPONSE_NAME,
COMMAND.IS_DEFAULT_RESPONSE_ENABLED,
COMMAND.IS_LARGE_MESSAGE,
COUNT(COMMAND_ARG.COMMAND_REF) AS COMMAND_ARGUMENT_COUNT,
COUNT(COMMAND_ARG.COMMAND_REF) FILTER (WHERE COMMAND_ARG.IS_OPTIONAL = 0) AS REQUIRED_COMMAND_ARGUMENT_COUNT
FROM COMMAND
Expand Down Expand Up @@ -1083,6 +1086,7 @@ SELECT
CO.IS_FABRIC_SCOPED,
CO.RESPONSE_REF,
CO.RESPONSE_NAME,
CO.IS_LARGE_MESSAGE,
CL.NAME AS CLUSTER_NAME,
CL.CODE AS CLUSTER_CODE,
CL.MANUFACTURER_CODE AS CLUSTER_MANUFACTURER_CODE,
Expand Down Expand Up @@ -1249,6 +1253,7 @@ SELECT
COMMAND.RESPONSE_REF,
COMMAND.RESPONSE_NAME,
COMMAND.IS_DEFAULT_RESPONSE_ENABLED,
COMMAND.IS_LARGE_MESSAGE,
COUNT(COMMAND_ARG.COMMAND_REF) AS COMMAND_ARGUMENT_COUNT
FROM
COMMAND
Expand Down Expand Up @@ -1368,6 +1373,7 @@ SELECT
COMMAND.RESPONSE_REF,
COMMAND.RESPONSE_NAME,
COMMAND.IS_DEFAULT_RESPONSE_ENABLED,
COMMAND.IS_LARGE_MESSAGE,
COUNT(COMMAND_ARG.COMMAND_REF) AS COMMAND_ARGUMENT_COUNT
FROM
COMMAND
Expand Down Expand Up @@ -1542,6 +1548,7 @@ SELECT
CMD.IS_FABRIC_SCOPED,
CMD.RESPONSE_REF,
CMD.RESPONSE_NAME,
CMD.IS_LARGE_MESSAGE,
CL.CODE AS CLUSTER_CODE,
CL.NAME AS CLUSTER_NAME,
CL.NAME AS CLUSTER_NAME,
Expand Down Expand Up @@ -1636,7 +1643,8 @@ function commandMapFunction(x) {
isClusterEnabled: x.ENABLED,
commandArgCount: x.COMMAND_ARGUMENT_COUNT,
responseRef: x.RESPONSE_REF,
responseName: x.RESPONSE_NAME
responseName: x.RESPONSE_NAME,
isLargeMessage: dbApi.fromDbBool(x.IS_LARGE_MESSAGE)
}
}

Expand Down Expand Up @@ -1783,6 +1791,7 @@ async function selectCommandDetailsFromAllEndpointTypesAndClusters(
C.RESPONSE_NAME,
C.MUST_USE_TIMED_INVOKE,
C.IS_FABRIC_SCOPED,
C.IS_LARGE_MESSAGE,
CASE
WHEN
(COUNT(CASE WHEN ETC.IS_INCOMING=1 AND ETC.IS_ENABLED THEN 1 ELSE NULL END) OVER (PARTITION BY C.COMMAND_ID)) >= 1
Expand Down
16 changes: 10 additions & 6 deletions src-electron/db/query-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ INSERT INTO COMMAND (
MANUFACTURER_CODE,
INTRODUCED_IN_REF,
REMOVED_IN_REF,
IS_DEFAULT_RESPONSE_ENABLED
IS_DEFAULT_RESPONSE_ENABLED,
IS_LARGE_MESSAGE
) VALUES (
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
(SELECT SPEC_ID FROM SPEC WHERE CODE = ? AND PACKAGE_REF = ?),
(SELECT SPEC_ID FROM SPEC WHERE CODE = ? AND PACKAGE_REF = ?),
?
?, ?
)`

const INSERT_COMMAND_ARG_QUERY = `
Expand Down Expand Up @@ -166,7 +167,7 @@ INSERT OR REPLACE INTO ATTRIBUTE (
INTRODUCED_IN_REF,
REMOVED_IN_REF,
API_MATURITY,
IS_CHANGE_COMITTED,
IS_CHANGE_OMITTED,
PERSISTENCE
) VALUES (
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
Expand Down Expand Up @@ -243,7 +244,9 @@ function attributeMap(clusterId, packageId, attributes) {
packageId,
attribute.removedIn,
packageId,
attribute.apiMaturity
attribute.apiMaturity,
dbApi.toDbBool(attribute.isChangeOmitted),
attribute.persistence
])
}

Expand Down Expand Up @@ -299,7 +302,8 @@ function commandMap(clusterId, packageId, commands) {
packageId,
command.removedIn,
packageId,
dbApi.toDbBool(command.isDefaultResponseEnabled)
dbApi.toDbBool(command.isDefaultResponseEnabled),
dbApi.toDbBool(command.isLargeMessage)
])
}

Expand Down Expand Up @@ -776,7 +780,7 @@ async function insertClusters(db, packageId, data) {
let i
for (i = 0; i < lastIdsArray.length; i++) {
let lastId = lastIdsArray[i]
// NOTE: This code must stay in sync with insertClusterExtensionsx
// NOTE: This code must stay in sync with insertClusterExtensions
if ('commands' in data[i]) {
let cmds = data[i].commands
commands.data.push(...commandMap(lastId, packageId, cmds))
Expand Down
5 changes: 3 additions & 2 deletions src-electron/db/query-session-zcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ SELECT
ATTRIBUTE.IS_SCENE_REQUIRED,
ATTRIBUTE.ARRAY_TYPE,
ATTRIBUTE.MUST_USE_TIMED_WRITE,
ATTRIBUTE.IS_CHANGE_COMITTED,
ATTRIBUTE.IS_CHANGE_OMITTED,
ATTRIBUTE.PERSISTENCE
FROM
ATTRIBUTE, CLUSTER, SESSION_PACKAGE
Expand Down Expand Up @@ -216,7 +216,8 @@ SELECT
CMD.IS_OPTIONAL,
CMD.MUST_USE_TIMED_INVOKE,
CMD.IS_FABRIC_SCOPED,
CMD.RESPONSE_REF
CMD.RESPONSE_REF,
CMD.IS_LARGE_MESSAGE
FROM
COMMAND AS CMD
INNER JOIN
Expand Down
14 changes: 7 additions & 7 deletions src-electron/db/query-zcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ SELECT
MUST_USE_TIMED_WRITE,
API_MATURITY,
PACKAGE_REF,
IS_CHANGE_COMITTED,
IS_CHANGE_OMITTED,
PERSISTENCE
FROM ATTRIBUTE
WHERE (CLUSTER_REF = ? OR CLUSTER_REF IS NULL)
Expand Down Expand Up @@ -770,7 +770,7 @@ SELECT
ARRAY_TYPE,
MUST_USE_TIMED_WRITE,
API_MATURITY,
IS_CHANGE_COMITTED,
IS_CHANGE_OMITTED,
PERSISTENCE
FROM ATTRIBUTE
WHERE
Expand Down Expand Up @@ -837,7 +837,7 @@ SELECT
A.ARRAY_TYPE,
A.MUST_USE_TIMED_WRITE,
A.API_MATURITY,
A.IS_CHANGE_COMITTED,
A.IS_CHANGE_OMITTED,
A.PERSISTENCE
FROM
ATTRIBUTE AS A,
Expand Down Expand Up @@ -891,7 +891,7 @@ SELECT
ARRAY_TYPE,
MUST_USE_TIMED_WRITE,
API_MATURITY,
IS_CHANGE_COMITTED,
IS_CHANGE_OMITTED,
PERSISTENCE
FROM ATTRIBUTE
WHERE ATTRIBUTE_ID = ?`,
Expand Down Expand Up @@ -958,7 +958,7 @@ SELECT
A.ARRAY_TYPE,
A.MUST_USE_TIMED_WRITE,
A.API_MATURITY,
A.IS_CHANGE_COMITTED,
A.IS_CHANGE_OMITTED,
A.PERSISTENCE
FROM ATTRIBUTE AS A
WHERE ATTRIBUTE_ID = ?`,
Expand Down Expand Up @@ -1007,7 +1007,7 @@ SELECT
A.MUST_USE_TIMED_WRITE,
A.API_MATURITY,
C.CODE AS CLUSTER_CODE,
A.IS_CHANGE_COMITTED,
A.IS_CHANGE_OMITTED,
A.PERSISTENCE
FROM
ATTRIBUTE AS A
Expand Down Expand Up @@ -1063,7 +1063,7 @@ SELECT
ARRAY_TYPE,
MUST_USE_TIMED_WRITE,
API_MATURITY,
IS_CHANGE_COMITTED,
IS_CHANGE_OMITTED,
PERSISTENCE
FROM ATTRIBUTE
WHERE SIDE = ?
Expand Down
3 changes: 2 additions & 1 deletion src-electron/db/zap-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ CREATE TABLE IF NOT EXISTS "COMMAND" (
"RESPONSE_NAME" integer,
"RESPONSE_REF" integer,
"IS_DEFAULT_RESPONSE_ENABLED" integer,
"IS_LARGE_MESSAGE" integer,
foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE,
foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE,
foreign key (CLUSTER_REF) references CLUSTER(CLUSTER_ID) ON DELETE CASCADE ON UPDATE CASCADE,
Expand Down Expand Up @@ -291,7 +292,7 @@ CREATE TABLE IF NOT EXISTS "ATTRIBUTE" (
"INTRODUCED_IN_REF" integer,
"REMOVED_IN_REF" integer,
"API_MATURITY" text,
"IS_CHANGE_COMITTED" integer,
"IS_CHANGE_OMITTED" integer,
"PERSISTENCE" text,
foreign key (INTRODUCED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE,
foreign key (REMOVED_IN_REF) references SPEC(SPEC_ID) ON DELETE CASCADE ON UPDATE CASCADE,
Expand Down
9 changes: 7 additions & 2 deletions src-electron/zcl/zcl-loader-silabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ function prepareCluster(cluster, context, isExtension = false) {
if ('command' in cluster) {
ret.commands = []
cluster.command.forEach((command) => {
let quality = null
if ('quality' in command) {
quality = command.quality[0].$
}
let cmd = {
code: parseInt(command.$.code),
manufacturerCode: command.$.manufacturerCode,
Expand All @@ -470,7 +474,8 @@ function prepareCluster(cluster, context, isExtension = false) {
responseName: command.$.response == null ? null : command.$.response,
isDefaultResponseEnabled:
command.$.disableDefaultResponse == 'true' ? false : true,
isFabricScoped: command.$.isFabricScoped == 'true'
isFabricScoped: command.$.isFabricScoped == 'true',
isLargeMessage: quality ? quality.largeMessage == 'true' : false
}
cmd.access = extractAccessIntoArray(command)
if (cmd.manufacturerCode == null) {
Expand Down Expand Up @@ -639,7 +644,7 @@ function prepareCluster(cluster, context, isExtension = false) {
entryType: attribute.$.entryType,
mustUseTimedWrite: attribute.$.mustUseTimedWrite == 'true',
apiMaturity: attribute.$.apiMaturity,
changeOmitted: quality ? quality.changeOmitted == 'true' : false,
isChangeOmitted: quality ? quality.changeOmitted == 'true' : false,
persistence: quality ? quality.persistence : null
}
att.access = extractAccessIntoArray(attribute)
Expand Down
11 changes: 9 additions & 2 deletions test/gen-matter-1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,17 @@ test(
'0,UINT0_MAX// actual type: ThermostatScheduleTransition'
)

// Testing attribute's scene loading
// Testing attribute qualities loading
expect(
sdkExt.includes(
"// attribute: 0x0300 / 0x4001 => EnhancedColorMode, extensions: '', '', scene: true"
"// attribute: 0x0300 / 0x4001 => EnhancedColorMode, extensions: '', '', scene: true, isChangeOmitted: true, persistence: nonVolatile"
)
)

// Testing isLargeMessage quality for commands
expect(
sdkExt.includes(
"// command: 0x0300 / 0x00 => MoveToHue, test extension: '', isLargeMessage: true"
)
)
},
Expand Down
4 changes: 2 additions & 2 deletions test/gen-template/matter/sdk-ext.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
------------------- Commands -------------------
{{#zcl_command_tree}}
// command: {{asHex clusterCode 4 'null'}} / {{asHex code 2}} => {{label}}, test extension: '{{command_extension
property="testCommandExtension"}}'
property="testCommandExtension"}}', isLargeMessage: {{isLargeMessage}}
{{/zcl_command_tree}}

------------------- Attributes -------------------
{{#zcl_attributes}}
// attribute: {{asHex clusterCode 4}} / {{asHex code 4}} => {{label}}, extensions: '{{attribute_extension
property="testAttributeExtension1"}}', '{{attribute_extension property="testAttributeExtension2"}}', scene: {{isSceneRequired}}
property="testAttributeExtension1"}}', '{{attribute_extension property="testAttributeExtension2"}}', scene: {{isSceneRequired}}, isChangeOmitted: {{isChangeOmitted}}, persistence: {{persistence}}
{{/zcl_attributes}}

-------------------- Events -----------------------
Expand Down
Loading

0 comments on commit d2e28b6

Please sign in to comment.