scinpower-battery-subscribe
v1.0.4
Published
Subscribe to the data content reported by the battery from Zhixiang Cloud
Downloads
8
Readme
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()