Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/connectors-thingsmatrix-udev-vnodeautomation #22

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions decoders/connector/thingsmatrix/tmx07/connector.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "../../../../schema/connector.json",
"name": "ThingsMatrix TMX07",
"images": {
"logo": "./assets/logo.png"
},
"versions": {
"v1.0.0": {
"src": "./v1.0.0/payload.js",
"manifest": "./v1.0.0/payload-config.jsonc"
}
}
}
1 change: 1 addition & 0 deletions decoders/connector/thingsmatrix/tmx07/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tracker (LTE Cat-M) from ThingsMatrix over Cellular
11 changes: 11 additions & 0 deletions decoders/connector/thingsmatrix/tmx07/v1.0.0/payload-config.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "../../../../../schema/connector_details.json",
"description": "../description.md",
"install_text": "##\n* Internal u-blox chipset\n* Quad band GSM/GPRS 850/900/1800/1900 MHz\n* Embedded @Track protocol\n* Internal 3-axis accelerometer for motion detection\n* Internal GSM antenna\n* Internal GPS antenna\n\n",
"install_end_text": "",
"device_annotation": "Install the dashboard template: http://admin.tago.io/template/5d8bbe847fe04b001b71ba22",
"device_parameters": [],
"networks": [
"../../../../network/thingsmatrix/v1.0.0/payload.js"
]
}
Empty file.
Binary file added decoders/connector/udev/pms100/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions decoders/connector/udev/pms100/connector.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "../../../../schema/connector.json",
"name": "udev PMS100",
"images": {
"logo": "./assets/logo.png"
},
"versions": {
"v1.0.0": {
"src": "./v1.0.0/payload.js",
"manifest": "./v1.0.0/payload-config.jsonc"
}
}
}
1 change: 1 addition & 0 deletions decoders/connector/udev/pms100/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Industrial Multi Sensor Device over Sigfox
11 changes: 11 additions & 0 deletions decoders/connector/udev/pms100/v1.0.0/payload-config.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "../../../../../schema/connector_details.json",
"description": "../description.md",
"install_text": "####PMS-100 for Sigfox\nThe PMS-100 is a multi-sensor device, designed to implentent IoT Projects using Sigfox Network.\n\nThe user or developer/integrator can use onboard sensors or connect external sensors to monitor temperature, relative humidity, pulse sensors and hidrometers. \n\nThis device is certified as Sigfox Ready and has also Anatel Certification.\n##\nMore information about this device can be found [here](https://www.udev.com.br/).\n###\n",
"install_end_text": "",
"device_annotation": "Install the dashboard template: http://admin.tago.io/template/5c80263d086c3d001db53b54",
"device_parameters": [],
"networks": [
"../../../../network/sigfox/v1.0.0/payload.js"
]
}
111 changes: 111 additions & 0 deletions decoders/connector/udev/pms100/v1.0.0/payload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* uDEV Payload Parser to PMS100
*
* This code finds the variable 'data'
* Then parse uDEV PMS100 to TagoIo format.
* You'll need to implement the other modes yourself by editing this code.
*/

// convert hex to dec
function convert_hex2dec(num) {
return parseInt((num), 16).toString(10);
}

// special convert hex to dec 2 bytes
function special_convert_hex2bin(num) {
let bin = String(parseInt(num, 16).toString(2));
if (bin.length < 8) {
const addzero = 8 - bin.length;
for (let index = 0; index < addzero; index++) {
bin = `0${bin}`;
}
}
return bin;
}
// convert hex to dec 2 bytes
function extract_number_2Bytes_inverted(message, low, high) {
const hex = `${message[high]}${message[low]}`; // first high - second low. inverted byte
return convert_hex2dec(hex);
}

// special convert hex to dec 1 byte
function special_extract_number_1Byte(message, low) {
const hex = `${message[low]}`;
return special_convert_hex2bin(hex);
}

// convert hex to dec 2 bytes
function extract_number_1Byte(message, low) {
const hex = `${message[low]}`;
return convert_hex2dec(hex);
}

// find variable data and check if it exists
const data = payload.find(x => x.variable === 'data');
if (!data) throw 'Variable data can not be found';

const serie = data.serie || Date.now();
const time = data.time || undefined;
const data_value = String(data.value);
const bytes = [];

for (let i = 0; i < data_value.length; i += 2) {
bytes.push(`${data_value[i]}${data_value[i + 1]}`);
}

const byte1 = special_extract_number_1Byte(bytes, 0);
let sequence;
let mode_operation;
let event;

if (String(byte1).length === 8) {
sequence = String(byte1).slice(0, 3);
mode_operation = String(byte1).slice(3, 5);
event = String(byte1).slice(5, 8);
}

const battery = extract_number_1Byte(bytes, 1) / 10;
const temperature = extract_number_1Byte(bytes, 2);
const humidity = extract_number_1Byte(bytes, 3);


if (bytes.length === 6) {
const pulse = extract_number_2Bytes_inverted(bytes, 4, 5);
payload.push({ variable: 'pulse_count', value: Number(pulse), serie, time, unit: 'Pulses' });
} else {
const external_status = extract_number_1Byte(bytes, 4);
payload.push({ variable: 'external_status', value: Number(external_status), serie, time });
}

// pushing parsed data
payload.push({
variable: 'mode_operation',
value: Number(mode_operation) === 0 ? 'Pulse counter mode' : 'External event mode',
metadata: { mode_operation: Number(mode_operation) },
serie,
time,
}, {
variable: 'event',
value: Number(event) === 0 ? 'Periodic timer event' : Number(event) === 1 ? 'Button pressed' : 'External occurrence',
metadata: { sequence: Number(sequence), event: Number(event) },
serie,
time,
}, {
variable: 'battery',
value: Number(battery),
unit: 'V',
serie,
time,
}, {
variable: 'temperature',
value: Number(temperature),
unit: '°C',
serie,
time,
}, {
variable: 'humidity',
value: Number(humidity),
unit: '%',
serie,
time,
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions decoders/connector/vnode-automation/vnode/connector.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "../../../../schema/connector.json",
"name": "vNode",
"images": {
"logo": "./assets/logo.png"
},
"versions": {
"v1.0.0": {
"src": "./v1.0.0/payload.js",
"manifest": "./v1.0.0/payload-config.jsonc"
}
}
}
1 change: 1 addition & 0 deletions decoders/connector/vnode-automation/vnode/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vNode integration over MQTT. Works with Compact and Extended mode.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "../../../../../schema/connector_details.json",
"description": "../description.md",
"install_text": "vNode integration over MQTT. Works with Compact and Extended mode.",
"install_end_text": "",
"device_annotation": "",
"device_parameters": [],
"networks": [
"../../../../network/mqtt/v1.0.0/payload.js"
]
}
25 changes: 25 additions & 0 deletions decoders/connector/vnode-automation/vnode/v1.0.0/payload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function parseExtended(raw_payload) {
const variables = [];
for (const item of raw_payload) {
const my_var = item.t.replace('/', '').split('/').join('_');
variables.push({ variable: my_var, value: item.v, time: item.ts })
}
return variables;
}

function parseCompact(raw_payload) {
const variables = [];
for (key in raw_payload) {
const my_var = key.replace('/', '').split('/').join('_');
for (const item of raw_payload[key]) {
variables.push({ variable: my_var, value: item.v, time: item.ts })
}
}
return variables;
}

if (Array.isArray(payload[0])) {
payload = parseExtended(payload[0]);
} else if (!payload[0].variable) {
payload = parseCompact(payload[0]);
}