0.2.0 • Published 5 years ago

@corelink/cls-aoa v0.2.0

Weekly downloads
7
License
ISC
Repository
-
Last release
5 years ago

Installation

via NPM

npm i -g @corelink/cls-aoa

via downloaded zip archive 1. unzip archive to wherever you want. eg. /opt/cls-aoa 2. add path to system environment variable.

export PATH=$PATH:/opt/cls-aoa

Windows OS is deferent. Google it yourself.

Usage

Start service

cls-aoa path/to/cpaFile [flags]

Eg.

cls-aoa ~/Document/demo.cpa

HTTP APIs

List all beacons

GET http://localhost:44444/beacons

Parameters

NameInOptionalDescription
macsqueryYESBeacon macs

HTTP Status

CodeDescriptionBody
200OKJSON Result

Result Structure

{
x: number; // Position x-axis
y: number; // Position y-axis
z: number; // Position z-axis
mapId: string; // Map ID
zoneId: string; // Zone ID
updatedAt: number; // Timestamp for last package
userData: {
  161: {
    channel: number; //
    frequency: number; //
    power: { // 
      type: 'TI' | 'Nordic'; // 
      value: number; //
    };
    sos: boolean; // Button pressed
    battery: number; // Battery percentage
  };
};

} }

> Example. GET http://localhost:44444/beacons?macs=806fb00c45d9,806fb00c45c9
```json
{
  "806fb00c45d9": {
    "x":9.573189735412598,
    "y":5.213486194610596,
    "z":0.800000011920929,
    "mapId":"lwlx6fFgu",
    "zoneId":"z1",
    "updatedAt":1571109529308,
    "userData":{
      "161":{
        "channel":2481,
        "frequency":50,
        "power":{
          "type":"TI",
          "value":5
        },
        "sos":false,
        "battery":83
      }
    }
  },
  "806fb00c45c9":{
    "x":6.329273700714111,
    "y":7.880806922912598,
    "z":0.800000011920929,
    "mapId":"lwlx6fFgu",
    "zoneId":"z1",
    "updatedAt":1571109529215,
    "userData":{
      "161":{
        "channel":2481,
        "frequency":110,
        "power":{
          "type":"TI",
          "value":0
        },
        "sos":false,
        "battery":95
      }
    }
  }
}

List all locators

GET http://localhost:44444/locators

Parameters

NameInOptionalDescription
macsqueryYESLocator macs

HTTP Status

CodeDescriptionBody
200OKJSON Result

Result Structure

{
mac: string; // Locator mac
angles: number[6]; // Locator angles
updatedAt: number; // Timestamp for last package

} }

> Example. GET http://localhost:44444/locators?macs=18:04:ed:7a:c5:01,18:04:ed:7a:c4:78
```json
{
  "192.168.123.137": {
    "mac": "18:04:ed:7a:c5:01",
    "angles": [26, -137, 2150, 60, 550, 491],
    "updatedAt": 1571109502971
  },
  "192.168.123.28": {
    "mac": "18:04:ed:7a:c4:78",
    "angles": [118, 191, 2091, -113, 248, 646],
    "updatedAt": 1571109502988
  }
}

Retrieve a beacon

GET http://localhost:44444/beacons/:mac

Parameters

NameInOptionalDescription
macpathNOBeacon mac

HTTP Status

CodeDescriptionBody
200OKJSON Result
404Not FountError Message

Result Structure

{
  mac: string; // Beacon mac
  x: number; // Position x-axis
  y: number; // Position y-axis
  z: number; // Position z-axis
  mapId: string; // Map ID
  zoneId: string; // Zone ID
  updatedAt: number; // Timestamp for last package
  userData: {
    161: {
      channel: number; //
      frequency: number; //
      power: { // 
        type: 'TI' | 'Nordic'; // 
        value: number; //
      };
      sos: boolean; // Button pressed
      battery: number; // Battery percentage
    };
  };
}

Example. GET http://localhost:44444/beacons/806fb00c45c9

{
  "mac": "806fb00c45c9",
  "x": 6.963463306427002,
  "y": 6.864238739013672,
  "z": 0.800000011920929,
  "mapId": "lwlx6fFgu",
  "zoneId": "z1",
  "updatedAt": 1571120302882,
  "userData": {
    "161": {
      "channel": 2481,
      "frequency": 110,
      "power":{
        "type": "TI",
        "value": 0
      },
      "sos": false,
      "battery": 95
    }
  }
}

Example. GET http://localhost:44444/beacons/mac_not_existed

Beacon not found

Retrieve a locator

GET http://localhost:44444/locators/:mac

Parameters

NameInOptionalDescription
macpathNOLocator mac

HTTP Status

CodeDescriptionBody
200OKJSON Result
404Not FountError Message

Result Structure

{
  ip: string; // Locator ip address v4
  mac: string; // Locator mac
  angles: number[6]; // Locator angles
  updatedAt: number; // Timestamp for last package
}

Example. GET http://localhost:44444/locators/18:04:ed:7a:c4:78

{
  "ip": "192.168.123.28",
  "mac": "18:04:ed:7a:c4:78",
  "angles": [119, 190, 2093, -122, 232, 641],
  "updatedAt": 1571118991384
}

Example. GET http://localhost:44444/locators/mac_not_existed

Locator not found