Skip to content

Commit

Permalink
fix defaultRsp handling
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Sep 25, 2023
1 parent 66b642d commit 13766ab
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/Af.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ class Af extends EventEmitter {

nextZclSeqNum() {
this._seq ++; // seqNumber is a private var on the top of this module
if (this._seq >= 253 || this._seq < 0)
this._seq = 0;
if (this._seq >= 253 || this._seq < 0) this._seq = 0;
return this._seq;
}

Expand Down Expand Up @@ -111,13 +110,17 @@ class Af extends EventEmitter {
zclDebug(`0x${msg.srcaddr.toString(16)}:${msg.srcendpoint}->0x00:${msg.dstendpoint} (${msg.zclMsg.seqNum}) ${msg.clusterid} ${frameType === 0 ? 'foundation' : 'functional'}(${msg.zclMsg.cmdId}) ${JSON.stringify(msg.zclMsg.payload)}`);

if(msg.zclMsg.frameCntl.direction === 1) {
let prefix = 'ZCL:'+((frameType === 0 && msg.zclMsg.cmdId !== 'defaultRsp') ? 'foundation' : 'functional')+':'

// for broadcast responses only
const prefix = 'ZCL:'+(frameType ? 'functional' : 'foundation')+':'
this.emit(prefix + msg.dstendpoint + ':' + msg.zclMsg.seqNum, msg);

prefix += msg.srcaddr.toString(16) + ':' + msg.srcendpoint + ':'

// { groupid, clusterid, srcaddr, srcendpoint, dstendpoint, wasbroadcast, linkquality, securityuse, timestamp, transseqnumber, zclMsg }
this.emit(prefix + msg.srcaddr.toString(16) + ':' + msg.srcendpoint + ':' + msg.dstendpoint + ':' + msg.zclMsg.seqNum, msg);
this.emit(prefix + msg.srcaddr.toString(16) + ':' + msg.srcendpoint + ':' + msg.zclMsg.seqNum, msg);
this.emit(prefix + msg.dstendpoint + ':' + msg.zclMsg.seqNum, msg);

this.emit(prefix + msg.zclMsg.seqNum, msg);
}

// Necessary, some IAS devices don't respect endpoints
Expand Down

0 comments on commit 13766ab

Please sign in to comment.