Skip to content

Commit

Permalink
always generate events even for gatewayApp
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Sep 28, 2023
1 parent b907519 commit 3427fe5
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions lib/Af.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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) {
Expand Down

0 comments on commit 3427fe5

Please sign in to comment.