From ccca3e74d421756178c941eed7a64c15facf0be2 Mon Sep 17 00:00:00 2001 From: Evgeni Margolis Date: Sun, 29 Jan 2023 22:07:05 -0800 Subject: [PATCH] Updated chip_endpoint_generated_event_*() methods to use existing db query methods --- .../app/zap-templates/templates/app/helper.js | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src-electron/generator/matter/app/zap-templates/templates/app/helper.js b/src-electron/generator/matter/app/zap-templates/templates/app/helper.js index 7f8459b851..8545d5ee03 100644 --- a/src-electron/generator/matter/app/zap-templates/templates/app/helper.js +++ b/src-electron/generator/matter/app/zap-templates/templates/app/helper.js @@ -189,25 +189,32 @@ function chip_endpoint_generated_commands_list(options) { } function chip_endpoint_generated_event_count(options) { + let packageIds = templateUtil.ensureZclPackageIds(this) let count = 0 this.clusterList.forEach((c) => { - count += c.events.length + let events = queryEvents.selectEventsByClusterId(this.global.db, c.clusterId, packageIds) + count += events.length }) return count } function chip_endpoint_generated_event_list(options) { + let packageIds = templateUtil.ensureZclPackageIds(this) let comment = null let index = 0 let ret = '{ \\\n' this.clusterList.forEach((c) => { - c.events.forEach((ev) => { + let events = queryEvents.selectEventsByClusterId(this.global.db, c.clusterId, packageIds) + + events.forEach((ev) => { if (c.comment != comment) { ret += ` /* ${c.comment} */ \\\n` ret += ` /* EventList (index=${index}) */ \\\n` comment = c.comment } - ret += ` ${ev.eventId}, /* ${ev.name} */ \\\n` + + let eventId = asMEI(ev.manufacturerCode, ev.code) + ret += ` ${eventId}, /* ${ev.name} */ \\\n` index++ }) }) @@ -287,12 +294,10 @@ function chip_endpoint_cluster_list() { } )`; } + let packageIds = templateUtil.ensureZclPackageIds(this) + let events = queryEvents.selectEventsByClusterId(this.global.db, c.clusterId, packageIds) let generatedEventListVal = 'nullptr'; - let generatedEventCount = 0; - c.events.forEach((event) => { - generatedEventCount++; - }); - + let generatedEventCount = events.length; if (generatedEventCount > 0) { totalEvents += generatedEventCount; generatedEventListVal = `ZAP_GENERATED_EVENTS_INDEX( ${totalEvents} )`;