Skip to content

Commit

Permalink
initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dhchandw committed Oct 21, 2024
1 parent 30f9298 commit 0879e9d
Show file tree
Hide file tree
Showing 11 changed files with 2,886 additions and 2,289 deletions.
6 changes: 4 additions & 2 deletions src-electron/db/db-mapping.js
Original file line number Diff line number Diff line change
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 @@ -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: 8 additions & 0 deletions src-electron/db/query-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,7 @@ async function selectNonGlobalCommandByCode(
C.IS_FABRIC_SCOPED,
C.RESPONSE_REF,
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 @@ -936,6 +937,7 @@ async function selectGlobalCommandByCode(
C.IS_FABRIC_SCOPED,
C.RESPONSE_REF,
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 @@ -1783,6 +1790,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
10 changes: 6 additions & 4 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 @@ -299,7 +300,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 +778,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
3 changes: 2 additions & 1 deletion src-electron/db/query-session-zcl.js
Original file line number Diff line number Diff line change
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
1 change: 1 addition & 0 deletions 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
8 changes: 7 additions & 1 deletion src-electron/zcl/zcl-loader-silabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ 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].$
console.log(quality)
}
let cmd = {
code: parseInt(command.$.code),
manufacturerCode: command.$.manufacturerCode,
Expand All @@ -470,7 +475,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
7 changes: 7 additions & 0 deletions test/gen-matter-1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ test(
"// attribute: 0x0300 / 0x4001 => EnhancedColorMode, extensions: '', '', scene: true"
)
)

// Testing isLargeMessage quality for commands
expect(
sdkExt.includes(
"// command: 0x0300 / 0x00 => MoveToHue, test extension: '', isLargeMessage: true"
)
)
},
testUtil.timeout.long()
)
Expand Down
2 changes: 1 addition & 1 deletion test/gen-template/matter/sdk-ext.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
------------------- 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 -------------------
Expand Down
Loading

0 comments on commit 0879e9d

Please sign in to comment.