Skip to content

Commit

Permalink
Updated chip_endpoint_generated_event_*() methods to use existing db …
Browse files Browse the repository at this point in the history
…query methods
  • Loading branch information
emargolis committed Jan 30, 2023
1 parent 120433e commit fc248c3
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = queryEvent.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 = queryEvent.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++
})
})
Expand Down Expand Up @@ -287,12 +294,10 @@ function chip_endpoint_cluster_list() {
} )`;
}

let packageIds = templateUtil.ensureZclPackageIds(this)
let events = queryEvent.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} )`;
Expand Down

0 comments on commit fc248c3

Please sign in to comment.