UNPKG

@iotize/tap

Version:

IoTize Device client for Javascript

415 lines (403 loc) 10.3 kB
import { AbstractService, extendServiceContainer } from '@iotize/tap'; import { TapRequestFrame } from '@iotize/tap/client/api'; import { TapStreamReader, TapStreamWriter } from '@iotize/tap/client/impl'; import { converters } from '@iotize/tap/service/core'; import { singlePacketConverters } from '@iotize/tap/service/impl/single-packet'; /** * Generated file. Do not edit */ TapStreamReader.prototype.readDataLogOption = function () { const model = {}; this.forwardBits(6); model.security = this.readBoolean(1); model.qos = this.readBoolean(1); this.forwardBits(5); model.logOnChange = this.readBoolean(1); model.rollingMode = this.readBoolean(1); model.autorun = this.readBoolean(1); return model; }; // TapStreamWriter.prototype.write(model: DataLogOption) : TapStreamWriter{ // return this.writeDataLogOption(model) // } TapStreamWriter.prototype.writeDataLogOption = function (model) { this.forwardBits(6); this.writeBoolean(model.security, 1); this.writeBoolean(model.qos, 1); this.forwardBits(5); this.writeBoolean(model.logOnChange, 1); this.writeBoolean(model.rollingMode, 1); this.writeBoolean(model.autorun, 1); return this; }; /** * Generated file. Do not edit */ class DataLogOptionConverter { encode(model, stream = new TapStreamWriter()) { stream.writeDataLogOption(model); return stream.toBytes; } decode(data) { const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data); return stream.readDataLogOption(); } } /** * Generated file. Do not edit */ const dataLogOption = new DataLogOptionConverter(); var serviceConverters = /*#__PURE__*/Object.freeze({ __proto__: null, dataLogOption: dataLogOption }); /** * Generated file. Do not edit */ const allConverters = Object.assign(Object.assign(Object.assign({}, converters), serviceConverters), singlePacketConverters); const SERVICE_CALLS = { getMaxPacketCount: { method: TapRequestFrame.MethodType.GET, pathAlias: '/data-log/max-packet-count', path: '/1024//23', responseBodyDecoder: allConverters.uint16, }, isRunning: { method: TapRequestFrame.MethodType.GET, pathAlias: '/data-log/run', path: '/1031//0', responseBodyDecoder: allConverters.boolean, }, run: { method: TapRequestFrame.MethodType.POST, pathAlias: '/data-log/run', path: '/1031//0', }, stop: { method: TapRequestFrame.MethodType.POST, pathAlias: '/data-log/stop', path: '/1031//1', }, getOptions: { method: TapRequestFrame.MethodType.GET, pathAlias: '/data-log/options', path: '/1031//2', responseBodyDecoder: allConverters.dataLogOption, }, putOptions: { method: TapRequestFrame.MethodType.PUT, pathAlias: '/data-log/options', path: '/1031//2', bodyEncoder: allConverters.dataLogOption, }, putCryptoKey: { method: TapRequestFrame.MethodType.PUT, pathAlias: '/data-log/crypto-key', path: '/1031//3', }, flush: { method: TapRequestFrame.MethodType.POST, pathAlias: '/data-log/flush', path: '/1031//4', }, getPacketCount: { method: TapRequestFrame.MethodType.GET, pathAlias: '/data-log/packet-count', path: '/1031//10', responseBodyDecoder: allConverters.uint16, }, dequeueOnePacket: { method: TapRequestFrame.MethodType.GET, pathAlias: '/data-log/dequeue-packet', path: '/1031//11', responseBodyDecoder: allConverters.singlePacket, }, }; class DataLogService extends AbstractService { constructor() { super(...arguments); this.resources = SERVICE_CALLS; } /** * Get the maximum number of packet * * LWM2M path: /1024//23 * * @tapVersion(">=1.0") * @return */ getMaxPacketCount() { return this.serviceCallRunner.execute(this.getMaxPacketCountCall()); } /** * * * LWM2M path: /1024//23 * * @tapVersion(">=1.0") * @return call options */ getMaxPacketCountCall() { const callOptions = Object.assign({}, this.resources.getMaxPacketCount); return callOptions; } /** * Get datalog running status * * LWM2M path: /1031//0 * * @tapVersion(">=1.0") * @return */ isRunning() { return this.serviceCallRunner.execute(this.isRunningCall()); } /** * * * LWM2M path: /1031//0 * * @tapVersion(">=1.0") * @return call options */ isRunningCall() { const callOptions = Object.assign({}, this.resources.isRunning); return callOptions; } /** * Run data-log acquisition * * LWM2M path: /1031//0 * * @tapVersion(">=1.0") * @return */ run() { return this.serviceCallRunner.execute(this.runCall()); } /** * * * LWM2M path: /1031//0 * * @tapVersion(">=1.0") * @return call options */ runCall() { const callOptions = Object.assign({}, this.resources.run); return callOptions; } /** * Stop data-log acquisition * * LWM2M path: /1031//1 * * @tapVersion(">=1.0") * @return */ stop() { return this.serviceCallRunner.execute(this.stopCall()); } /** * * * LWM2M path: /1031//1 * * @tapVersion(">=1.0") * @return call options */ stopCall() { const callOptions = Object.assign({}, this.resources.stop); return callOptions; } /** * Get data log options * * LWM2M path: /1031//2 * * @tapVersion(">=1.0") * @return */ getOptions() { return this.serviceCallRunner.execute(this.getOptionsCall()); } /** * * * LWM2M path: /1031//2 * * @tapVersion(">=1.0") * @return call options */ getOptionsCall() { const callOptions = Object.assign({}, this.resources.getOptions); return callOptions; } /** * Write data log option * * LWM2M path: /1031//2 * * @tapVersion(">=1.0") * @param value input * @return */ putOptions( /* * */ value) { return this.serviceCallRunner.execute(this.putOptionsCall(value)); } /** * * * LWM2M path: /1031//2 * * @tapVersion(">=1.0") * @param value input * @return call options */ putOptionsCall( /* * */ value) { const callOptions = Object.assign({}, this.resources.putOptions); callOptions.body = value; return callOptions; } /** * Write data log crypto key * * LWM2M path: /1031//3 * * @tapVersion(">=1.0") * @param value input * @return */ putCryptoKey( /* * */ value) { return this.serviceCallRunner.execute(this.putCryptoKeyCall(value)); } /** * * * LWM2M path: /1031//3 * * @tapVersion(">=1.0") * @param value input * @return call options */ putCryptoKeyCall( /* * */ value) { const callOptions = Object.assign({}, this.resources.putCryptoKey); callOptions.body = value; return callOptions; } /** * Flush data log packets * * LWM2M path: /1031//4 * * @tapVersion(">=1.0") * @return */ flush() { return this.serviceCallRunner.execute(this.flushCall()); } /** * * * LWM2M path: /1031//4 * * @tapVersion(">=1.0") * @return call options */ flushCall() { const callOptions = Object.assign({}, this.resources.flush); return callOptions; } /** * Get number of pending data-log packet * * LWM2M path: /1031//10 * * @tapVersion(">=1.0") * @return */ getPacketCount() { return this.serviceCallRunner.execute(this.getPacketCountCall()); } /** * * * LWM2M path: /1031//10 * * @tapVersion(">=1.0") * @return call options */ getPacketCountCall() { const callOptions = Object.assign({}, this.resources.getPacketCount); return callOptions; } /** * Dequeue one packet * * LWM2M path: /1031//11 * * @tapVersion(">=1.0") * @return */ dequeueOnePacket() { return this.serviceCallRunner.execute(this.dequeueOnePacketCall()); } /** * * * LWM2M path: /1031//11 * * @tapVersion(">=1.0") * @return call options */ dequeueOnePacketCall() { const callOptions = Object.assign({}, this.resources.dequeueOnePacket); return callOptions; } } const _TAP_SERVICE_EXTENSION_DATALOG_ = extendServiceContainer('dataLog', DataLogService); /** * Generated file. Do not edit */ const ResourceMetaData = { '/data-log/options': { put: { minApiVersion: 1.0, configModeRequired: true, schema: { $ref: './definitions.yaml#/DataLogOption', }, }, }, '/data-log/crypto-key': { put: { minApiVersion: 1.0, configModeRequired: true, schema: { $ref: './definitions.yaml#/Bytes', }, }, }, }; // import './lib/custom/extension'; /** * Generated bundle index. Do not edit. */ export { SERVICE_CALLS as DATALOG_SERVICE_CALLS, DataLogOptionConverter, ResourceMetaData as DataLogResourceMetaData, DataLogService, _TAP_SERVICE_EXTENSION_DATALOG_, serviceConverters as dataLogConverters }; //# sourceMappingURL=iotize-tap-service-impl-data-log.js.map