This package is used for integration with the Go-IoT DINGO-Stack. Introduction
The DINGO-Stack provides a UNIX-Socket for inter process communication. UNIX-Socket
This package provides these functions for the UNIX-Socket communication:
sendToUnixSocket()
This function takes a JSON object as parameter and writes it to the UNIX-Socket.
setDebugMode()
This package will log messages to the console by default. If this behavior is not desired, then call this function with a Boolean false as parameter.
Example
Install this package into your project by calling npm install @goiot/goiot
Then in-code, use like this:
const goiot = require('@goiot/goiot');
// Send object to UNIX-Socket
goiot.sendToUnixSocket(jsonObject);// Turn off console messages
goiot.setDebugMode(false);
This is the JSON format, that the objects, that are sent to the UNIX-Socket, must adhere to - notice that some of the properties are optional: JSON-format
{ | |
"protocol": "CoAP", | // Optional "wMBus", "Conectrics", "CoAP", "OCF", etc. |
"type": "tempHumidityLight", | // Unique name of sensor-type within "protocol" |
// Example from wMBus is "LAS_SMOKE_DETECTOR" | |
// where "LAS stands for vendor "Lansen". | |
// Set this name wisely and vendor-unique | |
"timestamp": 1561096180, | // Optional (Epoch time) |
"sensorId": "3b8e", | // 64 bit hexadecimal unsigned integer |
"nativeId": "", | // optional. Example for wMBus is "LAS.00019160.2A.03" |
"sequenceNumber": 142, | |
"maxHops": 0, | // Optional maximum number of allowed network hops (0 = unlimited) |
"numHops": 1, | // Optional number of network hops that the message took |
"rssi": -64, | // Optional signal strength (wMBus, enOcean, etc.). |
"payload": { | // Sensor specific value-pairs |
"battery": 2.8, | |
"temperature": 25.71, | |
"temperatureUnit": "C", | |
"humidity": 50.25, | |
"bucketedLux": 0 | |
} } |