knxultimate
Version:
KNX IP protocol implementation for Node. This is the ENGINE of Node-Red KNX-Ultimate node.
36 lines • 1.13 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const TLVInfo_1 = __importDefault(require("./TLVInfo"));
class AdditionalInfo {
constructor(_tlvs = []) {
this._tlvs = _tlvs;
this._length = 0;
for (const tlv of _tlvs) {
this._length += tlv.length;
}
}
static createFromBuffer(buffer, offset = 0) {
const tlvs = [];
const _getOneTLV = () => {
if (offset >= buffer.length) {
return tlvs;
}
const tlv = TLVInfo_1.default.createFromBuffer(buffer, offset);
tlvs.push(tlv);
offset += tlv.length;
return _getOneTLV();
};
return new AdditionalInfo(_getOneTLV());
}
addTLV(tlv) {
this._tlvs.push(tlv);
}
toBuffer() {
return Buffer.concat(this._tlvs.map((tlv) => tlv.toBuffer()));
}
}
exports.default = AdditionalInfo;
//# sourceMappingURL=AdditionalInfo.js.map