Closed Koenkk closed 3 weeks ago
A few more suggestions...
Moving this function to ZclHeader
as write()
(or something like that) for consistency. Also, frameControl
doesn't need a variable in there, it can just be passed directly to buffalo.writeUInt8
.
Have something like this in ZclHeader
:
/** Returns the amount of bytes used by this header */
get length(): number {
return 3 + (this.manufacturerCode === null ? 0 : 2);
}
get isGlobal(): boolean {
return this.frameControl.frameType === FrameType.GLOBAL;
}
get isSpecific(): boolean {
return this.frameControl.frameType === FrameType.SPECIFIC;
}
ZclFrame
, this.Header.commandIdentifier
is a duplicate of this.Command.ID
. Also, frame.getCommand()
seems to be called often enough just to get the ID (frame.getCommand().ID
). Probably some optimizations needed around this.All done! Let me know if this is OK now.
Move the
ZclFrame.fromBuffer()
out of adapter code to prepare for custom cluster definitions as discussed in https://github.com/Koenkk/zigbee-herdsman/pull/971