Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 1x 1x 1x 3x 3x 3x 3x 18x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x | 'use strict';
const {validate} = require('../../lifx');
const Packet = {
size: 6
};
/**
* @typedef {Object} GetTileState64
* @property {Number} tileIndex an 8bit value
* @property {Number} length an 8bit value
* @property {Number} reserved an 8bit value
* @property {Number} x an 8bit value
* @property {Number} y an 8bit value
* @property {Number} width an 8bit valu
*/
/**
* Converts the given packet specific object into a packet
* @param {GetTileState64} obj object with configuration data
* @return {Buffer} packet
*/
Packet.toBuffer = function(obj) {
const buf = Buffer.alloc(this.size);
buf.fill(0);
let offset = 0;
['tileIndex', 'length', 'reserved', 'x', 'y', 'width'].forEach((field) => {
validate.isUInt8(obj[field], `getTileState64:${field}`);
});
buf.writeUInt8(obj.tileIndex, offset);
offset += 1;
buf.writeUInt8(obj.length, offset);
offset += 1;
buf.writeUInt8(obj.reserved, offset);
offset += 1;
buf.writeUInt8(obj.x, offset);
offset += 1;
buf.writeUInt8(obj.y, offset);
offset += 1;
buf.writeUInt8(obj.width, offset);
offset += 1;
return buf;
};
/**
* Converts the given packet specific object into a packet
* @param {Buffer} buf object with configuration data
* @return {GetTileState64} packet
*/
Packet.toObject = function(buf) {
const obj = {};
let offset = 0;
obj.tileIndex = buf.readUInt8(offset);
offset += 1;
obj.length = buf.readUInt8(offset);
offset += 1;
obj.reserved = buf.readUInt8(offset);
offset += 1;
obj.x = buf.readUInt8(offset);
offset += 1;
obj.y = buf.readUInt8(offset);
offset += 1;
obj.width = buf.readUInt8(offset);
offset += 1;
return obj;
};
module.exports = Packet;
|