UNPKG

@ljames8/hormann-hcp-client

Version:

Hormann Communication Protocol v1 garage door serial client

20 lines (19 loc) 606 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.arraysEqual = arraysEqual; exports.hex = hex; exports.computeCRC8 = computeCRC8; const crc_full_1 = require("crc-full"); function arraysEqual(a, b) { return a.length === b.length && a.every((value, index) => value === b[index]); } function hex(v) { return Buffer.from(v).toString("hex"); } const crc = new crc_full_1.CRC("CRC8", 8, 0x07, 0xf3, 0x00, false, false); function computeCRC8(bytes) { if (bytes.length == 0) { throw new Error('Bytes cannot be empty'); } return crc.compute(bytes); }