@@ -513,10 +513,12 @@ async function collectAttributes(endpointTypes, options) {
513513 let commandMfgCodes = [ ] // Array of { index, mfgCode } objects
514514 let clusterMfgCodes = [ ] // Array of { index, mfgCode } objects
515515 let attributeMfgCodes = [ ] // Array of { index, mfgCode } objects
516+ let eventMfgCodes = [ ] // Array of { index, mfgCode } objects
517+ let eventList = [ ]
516518 let attributeList = [ ]
517519 let commandList = [ ]
518520 let endpointList = [ ] // Array of { clusterIndex, clusterCount, attributeSize }
519- let clusterList = [ ] // Array of { clusterId, attributeIndex, attributeCount, attributeSize, mask, functions, comment }
521+ let clusterList = [ ] // Array of { clusterId, attributeIndex, attributeCount, attributeSize, eventIndex, eventCount, mask, functions, comment }
520522 let longDefaults = [ ] // Array of strings representing bytes
521523 let longDefaultsIndex = 0
522524 let minMaxIndex = 0
@@ -531,6 +533,7 @@ async function collectAttributes(endpointTypes, options) {
531533 let reportList = [ ] // Array of { direction, endpoint, clusterId, attributeId, mask, mfgCode, minOrSource, maxOrEndpoint, reportableChangeOrTimeout }
532534 let longDefaultsList = [ ] // Array of { value, size. comment }
533535 let attributeIndex = 0
536+ let eventIndex = 0
534537 let spaceForDefaultValue =
535538 options . spaceForDefaultValue !== undefined
536539 ? options . spaceForDefaultValue
@@ -563,6 +566,8 @@ async function collectAttributes(endpointTypes, options) {
563566 attributeIndex : attributeIndex ,
564567 attributeCount : c . attributes . length ,
565568 attributeSize : 0 ,
569+ eventIndex : eventIndex ,
570+ eventCount : c . events . length ,
566571 mask : [ ] ,
567572 commands : [ ] ,
568573 functions : 'NULL' ,
@@ -573,6 +578,7 @@ async function collectAttributes(endpointTypes, options) {
573578
574579 clusterIndex ++
575580 attributeIndex += c . attributes . length
581+ eventIndex += c . events . length
576582
577583 c . attributes . sort ( zclUtil . attributeComparator )
578584
@@ -850,6 +856,27 @@ async function collectAttributes(endpointTypes, options) {
850856 commandMfgCodes . push ( mfgCmd )
851857 }
852858 } )
859+
860+ // Go over the events
861+ c . events . sort ( zclUtil . eventComparator )
862+
863+ c . events . forEach ( ( ev ) => {
864+ let event = {
865+ eventId : asMEI ( ev . manufacturerCode , ev . code ) ,
866+ name : ev . name ,
867+ comment : cluster . comment ,
868+ }
869+ eventList . push ( event )
870+
871+ if ( ev . manufacturerCode ) {
872+ let mfgEv = {
873+ index : eventList . length - 1 ,
874+ mfgCode : ev . manufacturerCode ,
875+ }
876+ eventMfgCodes . push ( mfgEv )
877+ }
878+ } )
879+
853880 endpointAttributeSize += clusterAttributeSize
854881 cluster . attributeSize = clusterAttributeSize
855882 clusterList . push ( cluster )
@@ -871,7 +898,9 @@ async function collectAttributes(endpointTypes, options) {
871898 clusterList : clusterList ,
872899 attributeList : attributeList ,
873900 commandList : commandList ,
901+ eventList : eventList ,
874902 longDefaults : longDefaults ,
903+ eventMfgCodes : eventMfgCodes ,
875904 clusterMfgCodes : clusterMfgCodes ,
876905 commandMfgCodes : commandMfgCodes ,
877906 attributeMfgCodes : attributeMfgCodes ,
@@ -1011,11 +1040,12 @@ function endpoint_config(options) {
10111040 ept . clusters = clusters // Put 'clusters' into endpoint
10121041 let ps = [ ]
10131042 clusters . forEach ( ( cl ) => {
1014- // No client-side attributes or commands (at least for
1043+ // No client-side attributes, commands, and events (at least for
10151044 // endpoint_config purposes) in Matter.
10161045 if ( cl . side == dbEnum . side . client ) {
10171046 cl . attributes = [ ]
10181047 cl . commands = [ ]
1048+ cl . events = [ ]
10191049 return
10201050 }
10211051 ps . push (
@@ -1042,6 +1072,13 @@ function endpoint_config(options) {
10421072 cl . commands = commands
10431073 } )
10441074 )
1075+ ps . push (
1076+ queryEndpoint
1077+ . selectEndpointClusterEvents ( db , cl . clusterId , ept . id )
1078+ . then ( ( events ) => {
1079+ cl . events = events
1080+ } )
1081+ )
10451082 } )
10461083 return Promise . all ( ps )
10471084 } )
0 commit comments