UNPKG

knxultimate

Version:

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

60 lines 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const KnxLog_1 = require("../KnxLog"); const logger = (0, KnxLog_1.module)('DPT16'); const config = { id: 'DPT16', formatAPDU(value) { if (typeof value !== 'string') { logger.error('Must supply a string value. Autoconversion to string'); try { value = value.toString(); } catch (error) { value = 'DPT Err'; } } const buf = Buffer.alloc(14); if (this.subtypeid === '001') buf.write(value, 'latin1'); if (this.subtypeid === '000') buf.write(value, 'ascii'); return buf; }, fromBuffer(buf) { if (buf.length !== 14) { logger.error('Buffer should be 14 byte long, got', buf.length); return null; } if (this.subtypeid === '001') return buf.toString('latin1'); if (this.subtypeid === '000') return buf.toString('ascii'); return null; }, basetype: { bitlength: 14 * 8, valuetype: 'basic', desc: '14-character string', help: `// Send a text to a display msg.payload = "Hello!" return msg;`, helplink: '', }, subtypes: { '000': { use: 'G', desc: 'DPT_String_ASCII', name: 'ASCII string', force_encoding: 'US-ASCII', }, '001': { use: 'G', desc: 'DPT_String_8859_1', name: 'ISO-8859-1 string', force_encoding: 'ISO-8859-1', }, }, }; exports.default = config; //# sourceMappingURL=dpt16.js.map