UNPKG

knxultimate

Version:

KNX IP protocol implementation for Node. This is the ENGINE of Node-Red KNX-Ultimate node.

54 lines 2.41 kB
"use strict"; 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"); class KNXConnectionStateResponse extends KNXPacket_1.default { constructor(channelID, status) { super(KNXConstants_1.KNX_CONSTANTS.CONNECTIONSTATE_RESPONSE, 2); this.channelID = channelID; this.status = status; } static createFromBuffer(buffer, offset = 0) { if (offset >= buffer.length) { throw new Error('Buffer too short'); } const channelID = buffer.readUInt8(offset++); const status = buffer.readUInt8(offset); return new KNXConnectionStateResponse(channelID, status); } static statusToString(status) { switch (status) { case KNXConstants_1.KNX_CONSTANTS.E_SEQUENCE_NUMBER: return 'Invalid Sequence Number'; case KNXConstants_1.KNX_CONSTANTS.E_CONNECTION_ID: return 'Invalid Connection ID'; case KNXConstants_1.KNX_CONSTANTS.E_CONNECTION_TYPE: return 'Invalid Connection Type'; case KNXConstants_1.KNX_CONSTANTS.E_CONNECTION_OPTION: return 'Invalid Connection Option'; case KNXConstants_1.KNX_CONSTANTS.E_NO_MORE_CONNECTIONS: return 'No More Connections'; case KNXConstants_1.KNX_CONSTANTS.E_NO_MORE_UNIQUE_CONNECTIONS: return 'No More Unique Connections'; case KNXConstants_1.KNX_CONSTANTS.E_DATA_CONNECTION: return 'Invalid Data Connection'; case KNXConstants_1.KNX_CONSTANTS.E_KNX_CONNECTION: return 'Invalid KNX Connection'; case KNXConstants_1.KNX_CONSTANTS.E_TUNNELING_LAYER: return 'Invalid Tunneling Layer'; default: return `Unknown error ${status}`; } } toBuffer() { const buffer = Buffer.alloc(2); buffer.writeUInt8(this.channelID, 0); buffer.writeUInt8(this.status, 1); return Buffer.concat([this.header.toBuffer(), buffer]); } } exports.default = KNXConnectionStateResponse; //# sourceMappingURL=KNXConnectionStateResponse.js.map