Skip to content

Commit e176290

Browse files
authored
fix fetching baseType for commands derived from custom xml in zcl_commands_with_arguments() helper (#1509)
1 parent a45a6b0 commit e176290

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src-electron/generator/helper-zcl.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const queryZcl = require('../db/query-zcl')
2525
const queryDeviceType = require('../db/query-device-type')
2626
const queryCommand = require('../db/query-command')
2727
const queryEvent = require('../db/query-event')
28+
const queryPackage = require('../db/query-package')
2829
const dbEnum = require('../../src-shared/db-enum')
2930
const templateUtil = require('./template-util')
3031
const helperC = require('./helper-c')
@@ -528,18 +529,24 @@ async function zcl_commands_with_cluster_info(options) {
528529
async function zcl_commands_with_arguments(options) {
529530
let sortBy = options.hash.sortBy
530531
let packageIds = await templateUtil.ensureZclPackageIds(this)
532+
let packages = await queryPackage.getPackagesByPackageIds(
533+
this.global.db,
534+
packageIds
535+
)
531536

532537
let cmds = await Promise.all(
533-
packageIds.map(async (packageId) => {
538+
packages.map(async (pkg) => {
534539
let cmdsPerPackageId = await queryCommand.selectAllCommandsWithArguments(
535540
this.global.db,
536-
packageId
541+
pkg.id
537542
)
538543
if ('signature' == sortBy) {
539544
for (const cmd of cmdsPerPackageId) {
540545
let sig = await zclUtil.createCommandSignature(
541546
this.global.db,
542-
packageId,
547+
pkg.type === dbEnum.packageType.zclXmlStandalone
548+
? packageIds // If it's a custom xml, we need to pass all packages to have access to atomic types
549+
: pkg.id,
543550
cmd
544551
)
545552
cmd.signature = sig.signature
@@ -2790,6 +2797,7 @@ async function as_zcl_type_size(type, options) {
27902797

27912798
/**
27922799
* An if helper for comparisons
2800+
27932801
* @param {*} leftValue
27942802
* @param {*} rightValue
27952803
* @param {*} options

test/custom-matter-xml.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@ test(
312312
expect(sdkExt).toContain(
313313
"/ command: 0x0006 / 0xFFF201 => SampleMfgSpecificToggleWithTransition2, test extension: ''"
314314
)
315+
// checking if baseType for command arguments derived from custom xml is accurate
316+
expect(sdkExt).toContain(
317+
'Sample Custom Cluster - AddArgumentsResponse\n returnValue - int8u'
318+
)
315319

316320
let endpointConfig = genResult.content['endpoint-config.c']
317321
expect(sdkExt).not.toBeNull()

test/gen-template/matter/sdk-ext.zapt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
property="testCommandExtension"}}', isLargeMessage: {{isLargeMessage}}
1919
{{/zcl_command_tree}}
2020

21+
------------------- Commands with Arguments -------------------
22+
23+
{{#zcl_commands_with_arguments sortBy="signature"}}
24+
{{clusterName}} - {{commandName}}
25+
{{#zcl_command_arguments}}
26+
{{label}} - {{baseType}}
27+
{{/zcl_command_arguments}}
28+
{{/zcl_commands_with_arguments}}
29+
2130
------------------- Attributes -------------------
2231
{{#zcl_attributes}}
2332
// attribute: {{asHex clusterCode 4}} / {{asHex code 4}} => {{label}}, extensions: '{{attribute_extension

0 commit comments

Comments
 (0)