zigbee-herdsman-zigate
Version:
An open source ZigBee gateway solution with node.js.
52 lines • 1.67 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ZGGetDevicesListMessage = void 0;
const message_1 = require("../message");
const debug_1 = require("../../debug");
const buffer_reader_1 = __importDefault(require("../buffer-reader"));
const debug = debug_1.Debug('driver:messages');
const chunk = (arr, size) => {
const chunks = [];
while (arr.length) {
chunks.push(arr.splice(0, size));
}
return chunks;
};
class ZGGetDevicesListMessage {
constructor(payload) {
this.label = 'get-devices-list';
this.code = message_1.ZGMessageCode.GetDevicesList;
this.payload = this.parsePayload(payload);
debug.log.extend(`${this.getLabel()}`)(this.payload);
}
getCode() {
return this.code;
}
getLabel() {
return this.label;
}
getPayload() {
return this.payload;
}
parsePayload(payload) {
return chunk(Array.from(payload), 13)
.map((c) => {
return Buffer.from(c);
})
.map((c) => {
const r = new buffer_reader_1.default(c);
return {
id: r.nextUInt8(),
shortAddress: r.nextUInt16BE().toString(16),
MACIEEAddress: r.nextBigInt64BE().toString(16),
powerSource: r.nextUInt8(),
linkQuality: r.nextUInt8(),
};
});
}
}
exports.ZGGetDevicesListMessage = ZGGetDevicesListMessage;
//# sourceMappingURL=get-devices-list.js.map