npm.io
1.0.4 • Published 2 years ago

scinpower-battery-subscribe

Licence
ISC
Version
1.0.4
Deps
11
Size
9 kB
Vulns
0
Weekly
0

Install

npm install scinpower-battery-subscribe

TypeScript

import * as b from "scinpower-battery-subscribe";

const key = "key"
const secret = "secret"
const topics = ["parse.report.key","parse.warn.key","rsp.status.key","parse.gps.key"]
const client = new b.BatteryClient(key, secret)

client.subscribe(topics,1, async (message: b.Message, data: any) => {
  if (data === undefined) {
    throw new Error("Unknown data type")
  }
  if (data instanceof b.StatusData) {}
  if (data instanceof b.BatteryLoginData) {}
  if (data instanceof b.GpsData) {}
  if (data instanceof b.BmsData) {}
  if (data instanceof b.SensorShockData) {}
  if (data instanceof b.ModelIOData) {}
  if (data instanceof b.BmsIdData) {}
  if (data instanceof b.BmsWarnData) {}
}).then()
NodeJs
const b = require("scinpower-battery-subscribe")

const key = "key"
const secret = "secret"
const topics = ["parse.report.key","parse.warn.key","rsp.status.key","parse.gps.key"]
const client = new b.BatteryClient(key, secret)

client.subscribe(topics,1, async (message, data) => {
  if (data === undefined) {
    throw new Error("Unknown data type")
  }
  if (data instanceof b.StatusData) {}
  if (data instanceof b.BatteryLoginData) {}
  if (data instanceof b.GpsData) {}
  if (data instanceof b.BmsData) {}
  if (data instanceof b.SensorShockData) {}
  if (data instanceof b.ModelIOData) {}
  if (data instanceof b.BmsIdData) {}
  if (data instanceof b.BmsWarnData) {}

}).then()