Skip to content

Commit

Permalink
handle foundation commands that generate multiple responses
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Feb 12, 2024
1 parent 0e9c654 commit b4b2b9a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
9 changes: 6 additions & 3 deletions lib/Af.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const EventEmitter = require('eventemitter2'),
assert = require('assert'),
CcZnp = require('cc-znp'),
Qos = require('./Qos'),
Debug = require('debug')
Debug = require('debug'),
ZclMeta = require('./packet/ZclMeta');

var zcl = require('./Packet'),
zutils = CcZnp.utils,
Expand Down Expand Up @@ -463,7 +464,9 @@ class Af extends EventEmitter {
else // from local ep to remote ep
mandatoryEvent = 'ZCL:foundation:' + nwkAddr.toString(16) + ':' + dstEp.getEpId() + ':' + srcEp.getEpId() + ':' + seqNum;

areq = this.waitFor(mandatoryEvent)
const foundationCommand = ZclMeta.foundation.get(zclId.foundation(cmd).key)

areq = this.waitFor(mandatoryEvent, {filter:arg0=>(arg0.zclData.cmdId === 'defaultRsp' || arg0.zclData.cmdId === foundationCommand.rsp)})
}

var afOptions = cfg.afOptions !== undefined ? cfg.afOptions : {}
Expand Down Expand Up @@ -532,7 +535,7 @@ class Af extends EventEmitter {
frameType: 1, // functional command frame
manufSpec: cfg.manufSpec !== undefined ? cfg.manufSpec : 0,
direction: cfg.direction !== undefined ? cfg.direction : 0, // 0: client-to-server, 1: server-to-client
disDefaultRsp: cfg.disDefaultRsp !== undefined ? cfg.disDefaultRsp : 0 // enable deafult response command
disDefaultRsp: cfg.disDefaultRsp !== undefined ? cfg.disDefaultRsp : 0 // disable default response command
};

if (frameCntl.manufSpec === 1)
Expand Down
24 changes: 16 additions & 8 deletions lib/packet/defs/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"params": [
["attrId", 1]
],
"knownBufLen": 2
"knownBufLen": 2,
"rsp": "readRsp"
},
"readRsp": {
"params": [
Expand All @@ -20,15 +21,17 @@
["dataType", 0],
["attrData", 33]
],
"knownBufLen": 3
"knownBufLen": 3,
"rsp": "writeRsp"
},
"writeUndiv": {
"params": [
["attrId", 1],
["dataType", 0],
["attrData", 33]
],
"knownBufLen": 3
"knownBufLen": 3,
"rsp": "writeRsp"
},
"writeRsp": {
"params": [
Expand All @@ -50,7 +53,8 @@
["attrId", 1],
["extra", 34]
],
"knownBufLen": 3
"knownBufLen": 3,
"rsp": "configReportRsp"
},
"configReportRsp": {
"params": [
Expand All @@ -63,7 +67,8 @@
["direction", 0],
["attrId", 1]
],
"knownBufLen": 3
"knownBufLen": 3,
"rsp": "readReportConfigRsp"
},
"readReportConfigRsp": {
"params": [
Expand Down Expand Up @@ -94,7 +99,8 @@
["startAttrId", 1],
["maxAttrIds", 0]
],
"knownBufLen": 3
"knownBufLen": 3,
"rsp": "discoverRsp"
},
"discoverRsp": {
"params": [
Expand All @@ -108,7 +114,8 @@
["attrId", 1],
["selector", 36]
],
"knownBufLen": 2
"knownBufLen": 2,
"rsp": "readRsp"
},
"writeStrcut": {
"params": [
Expand All @@ -117,7 +124,8 @@
["dataType", 0],
["attrData", 37]
],
"knownBufLen": 3
"knownBufLen": 3,
"rsp": "writeStrcutRsp"
},
"writeStrcutRsp": {
"params": [
Expand Down

0 comments on commit b4b2b9a

Please sign in to comment.