1.0.0 • Published 2 years ago

isobarot-edge-gateway v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

isobarot-edge-gateway

  • Client library for sending data to isobarot cloud over HTTP or MQTT.

Getting Started

npm install --save isobarot-edge-gateway

HTTP Example - Local

const { EdgeGateway } = require("isobarot-edge-gateway");
const gateway = new EdgeGateway({
  type: "local",
  configurationApiUrl: "https://api.isobarot.com/path-to-config",
  configurationMqttBrokerUrl: "api.isobarot.com",
  configurationMqttTopic: "config",
  isobarCloudSenderParams: {
    url: "api.isobarot.com",
  },
});
gateway.init();

gateway.setValue("<sensor-id or custom-topic>", {
  apiToken: "<token>",
  record: {
    // ...
  },
});

// on application close
gateway.dispose();

MQTT Example - Local

const { EdgeGateway } = require("isobarot-edge-gateway");
const gateway = new EdgeGateway({
  type: "local",
  configurationApiUrl: "https://api.isobarot.com/path-to-config",
  configurationMqttBrokerUrl: "api.isobarot.com",
  configurationMqttTopic: "config",
  isobarCloudSenderParams: {
    url: "api.isobarot.com",
    type: "mqtt"
  },
});
gateway.init();

gateway.setValue("<sensor-id or custom-topic>", {
  apiToken: "<token>",
  record: {
    // ...
  },
});

// on application close
gateway.dispose();

MQTT Example - Hub - To be implemented

const { EdgeGateway } = require("isobarot-edge-gateway");
const gateway = new EdgeGateway({
  type: "hub",
  hubPort: 1883,
  configurationApiUrl: "https://api.isobarot.com/path-to-config",
  configurationMqttBrokerUrl: "api.isobarot.com",
  configurationMqttTopic: "config",
  isobarCloudSenderParams: {
    url: "api.isobarot.com",
    type: "mqtt"
  },
});
gateway.init();

/*
  Hub is listening on 0.0.0.0:1883
  Publish to <topic> { apiToken: <token>, record: { ... } }
*/

// on application close
gateway.dispose();