UNPKG

@iotize/tap

Version:

IoTize Device client for Javascript

238 lines (226 loc) 5.83 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'; /** * Generated file. Do not edit */ TapStreamReader.prototype.readLoraConfig = function () { const model = {}; model.classA = this.readBoolean(1); model.classB = this.readBoolean(1); model.classC = this.readBoolean(1); model.dataLoggingEnabled = this.readBoolean(1); model.singlePacketEnabled = this.readBoolean(1); return model; }; // TapStreamWriter.prototype.write(model: LoraConfig) : TapStreamWriter{ // return this.writeLoraConfig(model) // } TapStreamWriter.prototype.writeLoraConfig = function (model) { this.writeBoolean(model.classA, 1); this.writeBoolean(model.classB, 1); this.writeBoolean(model.classC, 1); this.writeBoolean(model.dataLoggingEnabled, 1); this.writeBoolean(model.singlePacketEnabled, 1); return this; }; /** * Generated file. Do not edit */ class LoraConfigConverter { encode(model, stream = new TapStreamWriter()) { stream.writeLoraConfig(model); return stream.toBytes; } decode(data) { const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data); return stream.readLoraConfig(); } } /** * Generated file. Do not edit */ const loraConfig = new LoraConfigConverter(); var serviceConverters = /*#__PURE__*/Object.freeze({ __proto__: null, loraConfig: loraConfig }); /** * Generated file. Do not edit */ const allConverters = Object.assign(Object.assign({}, converters), serviceConverters); const SERVICE_CALLS = { getIds: { method: TapRequestFrame.MethodType.GET, pathAlias: '/lora/ids', path: '/1024//90', }, putIds: { method: TapRequestFrame.MethodType.PUT, pathAlias: '/lora/ids', path: '/1024//90', }, getConfig: { method: TapRequestFrame.MethodType.GET, pathAlias: '/lora/config', path: '/1024//91', responseBodyDecoder: allConverters.loraConfig, }, putConfig: { method: TapRequestFrame.MethodType.PUT, pathAlias: '/lora/config', path: '/1024//91', bodyEncoder: allConverters.loraConfig, }, }; class LoraService extends AbstractService { constructor() { super(...arguments); this.resources = SERVICE_CALLS; } /** * Get LoRa IDs * * LWM2M path: /1024//90 * * @tapVersion(">=1.0") * @return */ getIds() { return this.serviceCallRunner.execute(this.getIdsCall()); } /** * * * LWM2M path: /1024//90 * * @tapVersion(">=1.0") * @return call options */ getIdsCall() { const callOptions = Object.assign({}, this.resources.getIds); return callOptions; } /** * Write LoRa IDs * * LWM2M path: /1024//90 * * @tapVersion(">=1.0") * @param value input * @return */ putIds( /* * */ value) { return this.serviceCallRunner.execute(this.putIdsCall(value)); } /** * * * LWM2M path: /1024//90 * * @tapVersion(">=1.0") * @param value input * @return call options */ putIdsCall( /* * */ value) { const callOptions = Object.assign({}, this.resources.putIds); callOptions.body = value; return callOptions; } /** * Get LoRa configuration * * LWM2M path: /1024//91 * * @tapVersion(">=1.0") * @return */ getConfig() { return this.serviceCallRunner.execute(this.getConfigCall()); } /** * * * LWM2M path: /1024//91 * * @tapVersion(">=1.0") * @return call options */ getConfigCall() { const callOptions = Object.assign({}, this.resources.getConfig); return callOptions; } /** * Write LoRa configuration * * LWM2M path: /1024//91 * * @tapVersion(">=1.0") * @param value input * @return */ putConfig( /* * */ value) { return this.serviceCallRunner.execute(this.putConfigCall(value)); } /** * * * LWM2M path: /1024//91 * * @tapVersion(">=1.0") * @param value input * @return call options */ putConfigCall( /* * */ value) { const callOptions = Object.assign({}, this.resources.putConfig); callOptions.body = value; return callOptions; } } const _TAP_SERVICE_EXTENSION_LORA_ = extendServiceContainer('lora', LoraService); /** * Generated file. Do not edit */ const ResourceMetaData = { '/lora/ids': { put: { minApiVersion: 1.0, configModeRequired: false, schema: { $ref: './definitions.yaml#/Bytes', }, }, }, '/lora/config': { put: { minApiVersion: 1.0, configModeRequired: false, schema: { $ref: './definitions.yaml#/LoraConfig', }, }, }, }; // import './lib/custom/extension'; /** * Generated bundle index. Do not edit. */ export { SERVICE_CALLS as LORA_SERVICE_CALLS, LoraConfigConverter, ResourceMetaData as LoraResourceMetaData, LoraService, _TAP_SERVICE_EXTENSION_LORA_, serviceConverters as loraConverters }; //# sourceMappingURL=iotize-tap-service-impl-lora.js.map