UNPKG

knxultimate

Version:

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

52 lines 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const KnxLog_1 = require("../KnxLog"); const logger = (0, KnxLog_1.module)('DPT19'); const config = { id: 'DPT19', formatAPDU: (value) => { if (typeof value !== 'object' || value.constructor.name !== 'Date') { logger.error('Must supply a Date object'); return null; } const day = value.getDay() === 0 ? 7 : value.getDay(); const apdu_data = Buffer.alloc(8); apdu_data[0] = value.getFullYear() - 1900; apdu_data[1] = value.getMonth() + 1; apdu_data[2] = value.getDate(); apdu_data[3] = (day << 5) + value.getHours(); apdu_data[4] = value.getMinutes(); apdu_data[5] = value.getSeconds(); apdu_data[6] = 0; apdu_data[7] = 0; return apdu_data; return null; }, fromBuffer: (buf) => { if (buf.length !== 8) { logger.warn('Buffer should be 8 bytes long, got', buf.length); return null; } const d = new Date(buf[0] + 1900, buf[1] - 1, buf[2], buf[3] & 0b00011111, buf[4], buf[5]); return d; return null; }, basetype: { bitlength: 64, valuetype: 'composite', desc: '8-byte Date+Time', help: `// Setting date/time using DPT 19.001 // This sends both date and time to the KNX BUS msg.payload = new Date(); return msg;`, helplink: 'https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki/-Sample---DateTime-to-BUS', }, subtypes: { '001': { name: 'Date time', desc: 'datetime', }, }, }; exports.default = config; //# sourceMappingURL=dpt19.js.map