Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Latest commit

 

History

History
66 lines (52 loc) · 1.87 KB

README.md

File metadata and controls

66 lines (52 loc) · 1.87 KB

SLMF-HTTP-connector

Build Status Coverage Status codebeat badge Known Vulnerabilities

Basic usage

Install this package simply using npm:

npm install slmf-http-connector

Let's begin by starting the connector:

const { SlmfHttpConnector } = require("slmf-http-connector");

const connector = new SlmfHttpConnector({
        accumulationPeriod : 500,
        maxAccumulatedMessages : 3,
        maxSlmfMessages : 2,
        maxRetries: 3,
        port: 8080,
        url : "http://127.0.0.1",
});

connector.start();

Now you are ready to add location messages from your server or application:

const { BatteryStatus, TagIdFormat } = require("slmf-http-connector");

connector.addMessages({
      source: "Infrastructure",
      format: "DFT",
      tagIdFormat: TagIdFormat.IEEE_EUI_64,
      tagId: 0,
      position: {
          x: 0,
          y: 0,
          z: 0,
      },
      battery: BatteryStatus.Good,
      timestamp: new Date(),
});

The messages will be sent to the target server using POST request in XML format (ISO/IEC 24730-1:2014)
If you need to stop the connector just do:

connector.stop(); // It will not send nor receive messages until started

Documentation

You can generate the library documentation inside the project folder using:

npm run docs