knxultimate
Version:
KNX IP protocol implementation for Node. This is the ENGINE of Node-Red KNX-Ultimate node.
39 lines • 1.55 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const KNXPacket_1 = __importDefault(require("./KNXPacket"));
const KNXConstants_1 = require("./KNXConstants");
const HPAI_1 = __importDefault(require("./HPAI"));
class KNXConnectionStateRequest extends KNXPacket_1.default {
constructor(channelID, hpaiControl = HPAI_1.default.NULLHPAI) {
super(KNXConstants_1.KNX_CONSTANTS.CONNECTIONSTATE_REQUEST, hpaiControl.length + 2);
this.channelID = channelID;
this.hpaiControl =
typeof hpaiControl === 'string'
? new HPAI_1.default(hpaiControl)
: hpaiControl;
}
static createFromBuffer(buffer, offset = 0) {
if (offset >= buffer.length) {
throw new Error('Buffer too short');
}
const channelID = buffer.readUInt8(offset++);
offset++;
const hpaiControl = HPAI_1.default.createFromBuffer(buffer, offset);
return new KNXConnectionStateRequest(channelID, hpaiControl);
}
toBuffer() {
const buffer = Buffer.alloc(2);
buffer.writeUInt8(this.channelID, 0);
buffer.writeUInt8(0, 1);
return Buffer.concat([
this.header.toBuffer(),
buffer,
this.hpaiControl.toBuffer(),
]);
}
}
exports.default = KNXConnectionStateRequest;
//# sourceMappingURL=KNXConnectionStateRequest.js.map