PLCHome / velux-klf200-api

Provide node to Veluxl® KLF-200 io-homecontrol® Gateway API
42 stars 7 forks source link

Issue with GW_ACTIVATE_SCENE_REQ #2

Closed grimbouk closed 5 years ago

grimbouk commented 5 years ago

Hi,

thanks for this implementation, I'm just trying to find my way and think i might have found a bug. GW_ACTIVATE_SCENE_REQ (line 2333 of klf.js sets the Buffer size to 1 - I think this should be 6?

If I leave as is, I get an error...

RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to write outside buffer bounds at boundsError (internal/buffer.js:51:11) at checkBounds (internal/buffer.js:30:5) at checkInt (internal/buffer.js:37:3) at writeU_Int16BE (internal/buffer.js:653:3) at Buffer.writeUInt16BE (internal/buffer.js:661:10) at GW_ACTIVATE_SCENE_REQ (..\node_modules\velux-klf200-api\lib\klf.js:2334:9)

PLCHome commented 5 years ago

You are right, in lib/klf.js:

  GW_ACTIVATE_SCENE_REQ:  function (data) {
    var buf = new Buffer(1)
    buf.writeUInt16BE(Tools.getSessionID(data.sessionID),0)
    buf.writeUInt8(data.commandOriginator,2)
    buf.writeUInt8(data.priorityLevel,3)
    buf.writeUInt8(data.sceneID,4)
    buf.writeUInt8(data.velocity,5)
    return buf
},

there is the wrong buffer size it must be: var buf = new Buffer(6) Im not at home, I'll fix it sa soon as possible.