knxultimate
Version:
KNX IP protocol implementation for Node. This is the ENGINE of Node-Red KNX-Ultimate node.
50 lines • 1.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const KnxLog_1 = require("../KnxLog");
const utils_1 = require("../utils");
const logger = (0, KnxLog_1.module)('DPT999');
const config = {
id: 'DPT999',
formatAPDU(value) {
if (typeof value !== 'string' || value.length < 10) {
logger.warn("Must supply an HEX string value of 10 bytes. Please don't add '$' nor '0x' Example 12340000000000000000");
return null;
}
value = value
.toUpperCase()
.replace(/\$/g, '')
.replace(/0X/g, '')
.replace(/ /g, '');
const apdu_data = Buffer.alloc(10);
let i = 0;
const iSlice = 2;
for (let index = 0; index < value.length; index += iSlice) {
const sHex = value.substring(index, iSlice + index);
const int = (0, utils_1.hexToDec)(sHex);
apdu_data[i] = int;
i++;
}
return apdu_data;
},
fromBuffer(buf) {
return buf.toString('hex');
},
basetype: {
bitlength: 80,
valuetype: 'basic',
desc: '10-bytes',
help: `// Send a code to an alarm keypad
msg.payload = '123400000000000000'; // Or msg.payload = '$12 $34 $00 $00 $00 $00 $00 $00 $00';
return msg;`,
helplink: '',
},
subtypes: {
'001': {
use: 'G',
desc: '10Bytes HEX',
name: '10 Bytes',
},
},
};
exports.default = config;
//# sourceMappingURL=dpt999.js.map