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

Adding support for Quality tag in Commands #1467

Merged
merged 5 commits into from
Oct 24, 2024
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
4,772 changes: 2,366 additions & 2,406 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.
7 changes: 4 additions & 3 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),
dhchandw marked this conversation as resolved.
Show resolved Hide resolved
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)
dhchandw marked this conversation as resolved.
Show resolved Hide resolved
}
},

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 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
18 changes: 14 additions & 4 deletions src-electron/db/query-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,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 @@ -1012,7 +1013,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 @@ -1089,6 +1091,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 @@ -1141,7 +1144,8 @@ async function selectAllCommandsWithArguments(db, packageId) {
argIsNullable: dbApi.fromDbBool(x.ARG_IS_NULLABLE),
argCountArg: x.ARG_COUNT_ARG,
argIntroducedIn: x.INTRODUCED_IN_REF,
argRemovedIn: x.REMOVED_IN_REF
argRemovedIn: x.REMOVED_IN_REF,
isLargeMessage: dbApi.fromDbBool(x.IS_LARGE_MESSAGE)
}
}
let rows = await dbApi.dbAll(
Expand All @@ -1160,6 +1164,7 @@ SELECT
CO.IS_FABRIC_SCOPED,
CO.RESPONSE_REF,
CO.RESPONSE_NAME,
CO.IS_LARGE_MESSAGE,
dhchandw marked this conversation as resolved.
Show resolved Hide resolved
CL.NAME AS CLUSTER_NAME,
CL.CODE AS CLUSTER_CODE,
CL.MANUFACTURER_CODE AS CLUSTER_MANUFACTURER_CODE,
Expand Down Expand Up @@ -1326,6 +1331,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 @@ -1445,6 +1451,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 @@ -1619,6 +1626,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 @@ -1713,7 +1721,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 @@ -1860,6 +1869,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,
dhchandw marked this conversation as resolved.
Show resolved Hide resolved
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
Loading