From 3427fe58dd0a412071ad546e1c38d329f2978567 Mon Sep 17 00:00:00 2001 From: Mathew Date: Thu, 28 Sep 2023 15:31:47 +1000 Subject: [PATCH] always generate events even for gatewayApp --- lib/Af.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/Af.js b/lib/Af.js index d15a05a..e646dd1 100644 --- a/lib/Af.js +++ b/lib/Af.js @@ -126,6 +126,23 @@ class Af extends EventEmitter { if(zclDebug.enabled){ zclDebug(`0x${msg.srcaddr.toString(16)}:${msg.srcendpoint}->0x00:${msg.dstendpoint} (${zclData.seqNum}) ${msg.clusterid} ${frameType === 0 ? 'foundation' : 'functional'}(${zclData.cmdId}) ${JSON.stringify(zclData.payload)}`); } + + const evt = {zclData, msg} + this.emit('ZCL:incomingMsg', evt); + + if(zclData.frameCntl.direction === 1) { + let prefix = 'ZCL:'+((frameType === 0 && zclData.cmdId !== 'defaultRsp') ? 'foundation' : 'functional')+':' + + // for broadcast responses only + this.emit(prefix + msg.dstendpoint + ':' + zclData.seqNum, evt); + + prefix += msg.srcaddr.toString(16) + ':' + msg.srcendpoint + ':' + + // { groupid, clusterid, srcaddr, srcendpoint, dstendpoint, wasbroadcast, linkquality, securityuse, timestamp, transseqnumber, zclMsg } + this.emit(prefix + msg.dstendpoint + ':' + zclData.seqNum, evt); + + this.emit(prefix + zclData.seqNum, evt); + } if (frameType === 0 && zclData.cmdId === 'report') this.emit('ind:reported', { ep: remoteEp, cId: msg.clusterid, attrs: zclData.payload }); @@ -142,23 +159,6 @@ class Af extends EventEmitter { if (zclData.cmdId === 'statusChangeNotification' && frameType === 1 && zclData.payload) { this.emit('ind:statusChange', { ep: remoteEp, cId: msg.clusterid, zclData: zclData, msg }); } - - const evt = {zclData, msg} - this.emit('ZCL:incomingMsg', evt); - - if(zclData.frameCntl.direction === 1) { - let prefix = 'ZCL:'+((frameType === 0 && zclData.cmdId !== 'defaultRsp') ? 'foundation' : 'functional')+':' - - // for broadcast responses only - this.emit(prefix + msg.dstendpoint + ':' + zclData.seqNum, evt); - - prefix += msg.srcaddr.toString(16) + ':' + msg.srcendpoint + ':' - - // { groupid, clusterid, srcaddr, srcendpoint, dstendpoint, wasbroadcast, linkquality, securityuse, timestamp, transseqnumber, zclMsg } - this.emit(prefix + msg.dstendpoint + ':' + zclData.seqNum, evt); - - this.emit(prefix + zclData.seqNum, evt); - } } } makeAfParamsExt(srcEp, addrMode, dstAddrOrGrpId, cId, rawPayload, opt) {