3.4.0 • Published 7 months ago
@cutos/device-thermometer v3.4.0
Introduction
@cutos/device-thermometer is a JavaScript library that can receive data from cutos thermometer driver Developers can use this interface to handle body heat data when detected
DeviceThermometer SDK
Installation
npm install @cutos/core
npm install @cutos/device-thermometer
Import dependencies
import {CoreAPI} from '@cutos/core';
import {DeviceThermometer} from '@cutos/device-thermometer';DeviceThermometer
Constructor, create DeviceThermometer instance
let devThermometer = new DeviceThermometer(name);- name: thermometer device name
Example:
devThermometer = new DeviceThermometer('device-thermometer');DeviceTSPLPrinter.init
thermometer device initialization
devThermometer.init(callback);- callback: callback function
Example:
devThermometer.init((result, error) => {
if (!error) {
console.log('onDeviceCreate', result)
} else {
console.log(error)
}
});DeviceThermometer.connect
Connect thermometer
devThermometer.connect(path, callback);- path: device port
- callback: callback function
Example:
devThermometer.connect('/ttyS1', (response) => {
console.log(response)
})- Return result example:
{
"status": true,
"msg": {
"path": "/ttyS1",
"baudRate": 115200,
"stopBit": 1
}
}DeviceThermometer.onData
listen data from the driver
devThermometer.onData(listener);- listener: data process function
- data example:
{
"data": 36.5
}3.4.0
7 months ago