UNPKG

@ginden/blinkstick-v2

Version:
20 lines 839 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setInfoBlock = setInfoBlock; const as_buffer_1 = require("../as-buffer"); const tsafe_1 = require("tsafe"); /** * Sets an infoblock on a device. * @param {BlinkStick} device Device on which to set the value. * @param {Number} location Address to seek the data. * @param {Buffer} data The value to push to the device. Should be <= 32 bytes */ async function setInfoBlock(device, location, data) { if (data.length !== 33) { throw new Error('Data length is not 33 bytes'); } const sentBuffer = (0, as_buffer_1.asBuffer)(data); (0, tsafe_1.assert)(sentBuffer[0] === location, 'Data location does not match the expected location'); return await device.setFeatureReport(sentBuffer); } //# sourceMappingURL=set-info-block.js.map