Skip to content

Commit

Permalink
feat/connectors-robeau-tektelic (#11)
Browse files Browse the repository at this point in the history
* chore: Update schema for connector_details.json

* feat: Add Robeau/Tektelic sensor decoders

* Added fake image for no break the schema

* chore: Update biome.jsonc to ignore specific decoder files
  • Loading branch information
mateuscardosodeveloper authored Jun 7, 2024
1 parent d990853 commit 43dbe55
Show file tree
Hide file tree
Showing 75 changed files with 5,517 additions and 0 deletions.
Binary file added decoders/connector/robeau/robeau/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/robeau/robeau/connector.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "../../../../schema/connector.json",
"name": "Robeau",
"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/robeau/robeau/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LoRaWAN device to measure water consumption and detect leaks
98 changes: 98 additions & 0 deletions decoders/connector/robeau/robeau/v1.0.0/payload-config.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"$schema": "../../../../../schema/connector_details.json",
"description": "../description.md",
"install_text": "In-building water management solution composed with\n- one sensor using turbine to calculate flow and volume of water\n- one datalogger to transmit data with Lora protocole\nWith this IoT device, you can :\n- detect leaks in real time and receive alerts (emailor text message) in case of over-consumption or leak\n- monitor your water network and analyse your water consumption everywhere in your building and do predictive maintenance\n- save water and then save money on your water bill\n- conserve water and have an environmental impact",
"install_end_text": "",
"device_annotation": "",
"device_parameters": [
{
"type": "dropdown",
"label": "Sensor 1 type",
"name": "sensor_1",
"group": "advanced",
"options": [
{
"is_default": true,
"label": "DN20",
"value": "1000"
},
{
"is_default": false,
"label": "DN25",
"value": "336.89"
}
]
},
{
"name": "sensor_2",
"label": "Sensor 2 type",
"type": "dropdown",
"group": "advanced",
"options": [
{
"is_default": true,
"label": "DN20",
"value": "1000"
},
{
"is_default": false,
"label": "DN25",
"value": "336.89"
}
]
},
{
"name": "sensor_3",
"label": "Sensor 3 type",
"type": "dropdown",
"group": "advanced",
"options": [
{
"is_default": true,
"label": "DN20",
"value": "1000"
},
{
"is_default": false,
"label": "DN25",
"value": "336.89"
}
]
},
{
"name": "sensor_4",
"label": "Sensor 4 type",
"type": "dropdown",
"group": "advanced",
"options": [
{
"is_default": true,
"label": "DN20",
"value": "1000"
},
{
"is_default": false,
"label": "DN25",
"value": "336.89"
}
]
}
],
"networks": [
"../../../../network/lorawan-actility/v1.0.0/payload.js",
"../../../../network/lorawan-citykinect/v1.0.0/payload.js",
"../../../../network/lorawan-everynet/v1.0.0/payload.js",
"../../../../network/lorawan-kerlink/v1.0.0/payload.js",
"../../../../network/lorawan-loriot-/v1.0.0/payload.js",
"../../../../network/lorawan-machineq/v1.0.0/payload.js",
"../../../../network/lorawan-orbiwise/v1.0.0/payload.js",
"../../../../network/lorawan-senra/v1.0.0/payload.js",
"../../../../network/lorawan-swisscom/v1.0.0/payload.js",
"../../../../network/lorawan-ttittn-v3/v1.0.0/payload.js",
"../../../../network/lorawan-tektelic/v1.0.0/payload.js",
"../../../../network/lorawan-senet/v1.0.0/payload.js",
"../../../../network/lorawan-chirpstack/v1.0.0/payload.js",
"../../../../network/lorawan-helium/v1.0.0/payload.js",
"../../../../network/lorawan-brdot-/v1.0.0/payload.js"
]
}
121 changes: 121 additions & 0 deletions decoders/connector/robeau/robeau/v1.0.0/payload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/* This is an generic payload parser example.
** The code find the payload variable and parse it if exists.
**
** IMPORTANT: In most case, you will only need to edit the parsePayload function.
**
** Testing:
** You can do manual tests to this parse by using the Device Emulator. Copy and Paste the following code:
** [{ "variable": "payload", "value": "0109611395" }]
**
** The ignore_vars variable in this code should be used to ignore variables
** from the device that you don't want.
*/
// Add ignorable variables in this array.
const ignore_vars = [];

/**
* This is the main function to parse the payload. Everything else doesn't require your attention.
* @param {String} payload_raw
* @returns {Object} containing key and value to TagoIO
*/
// const device = { params: [{ key: 'sensor_1', value: '1000' }, { key: 'sensor_2', value: '1000' }, { key: 'sensor_4', value: '1000' }] };

function parsePayload(payload_raw, port) {
try {
// if (port === 100)
const buffer = Buffer.from(payload_raw, 'hex');
const data = [];

const header_data = (`00000000${(parseInt(payload_raw.substr(0, 2), 16)).toString(2)}`).substr(-8);
const sensor = header_data.substr(2, 4);
console.log(sensor[3]);

const battery_voltage = buffer.readUInt8(1);

data.push({
variable: 'battery_voltage', value: battery_voltage / 100, unit: 'v',
});

if (buffer.length > 2) {
const sensor_1_param = device.params.find(param => param.key === 'sensor_1');
const sensor_1 = buffer.readUIntBE(2, 6);
if (sensor_1_param) {
data.push({
variable: 'sensor_1', value: sensor_1 / +sensor_1_param.value, unit: 'L',
});
} else {
data.push({
variable: 'sensor_1', value: sensor_1, unit: 'L', metadata: { error: 'Missing sensor_1 parameter' },
});
}
}

if (buffer.length > 8) {
const sensor_2_param = device.params.find(param => param.key === 'sensor_2');
const sensor_2 = buffer.readUIntBE(8, 6);
if (sensor_2_param) {
data.push({
variable: 'sensor_2', value: sensor_2 / +sensor_2_param.value, unit: 'L',
});
} else {
data.push({
variable: 'sensor_2', value: sensor_2, unit: 'L', metadata: { error: 'Missing sensor_2 parameter' },
});
}
}

if (buffer.length > 14) {
const sensor_3_param = device.params.find(param => param.key === 'sensor_3');
const sensor_3 = buffer.readUIntBE(14, 6);
if (sensor_3_param) {
data.push({
variable: 'sensor_3', value: sensor_3 / +sensor_3_param.value, unit: 'L',
});
} else {
data.push({
variable: 'sensor_3', value: sensor_3, unit: 'L', metadata: { error: 'Missing sensor_3 parameter' },
});
}
}

if (buffer.length > 20) {
const sensor_4_param = device.params.find(param => param.key === 'sensor_4');
const sensor_4 = buffer.readUIntBE(20, 6);
if (sensor_4_param) {
data.push({
variable: 'sensor_4', value: sensor_4 / +sensor_4_param.value, unit: 'L',
});
} else {
data.push({
variable: 'sensor_4', value: sensor_4, unit: 'L', metadata: { error: 'Missing sensor_4 parameter' },
});
}
}

return data;
} catch (e) {
console.log(e);
// Return the variable parse_error for debugging.
return [{ variable: 'parse_error', value: e.message }];
}
}

// let payload = [{ variable: 'payload', value: 'C5FE000000001777' }];
// Remove unwanted variables.
payload = payload.filter(x => !ignore_vars.includes(x.variable));

// Payload is an environment variable. Is where what is being inserted to your device comes in.
// Payload always is an array of objects. [ { variable, value...}, {variable, value...} ...]
const payload_raw = payload.find(x => x.variable === 'payload_raw' || x.variable === 'payload' || x.variable === 'data');
// const port = payload.find(x => x.variable === 'port' || x.variable === 'fport');
if (payload_raw) {
// Get a unique serie for the incoming data.
const { value, serie, time } = payload_raw;

// Parse the payload_raw to JSON format (it comes in a String format)
if (value) {
payload = payload.concat(parsePayload(value).map(x => ({ ...x, serie, time: x.time || time })));
}
}

// console.log(payload);
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/tektelic/asset-tracker/connector.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "../../../../schema/connector.json",
"name": "Tektelic Asset Tracker",
"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/tektelic/asset-tracker/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GPS-enabled real-time location with detection of motion over LoRaWAN™
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "../../../../../schema/connector_details.json",
"description": "../description.md",
"install_text": "##\nThe Asset Tracker provides GPS-enabled real-time location of fixed and mobile assets over LoRaWAN™.\n\nIt also supports user configurable triggers that can be based on the detection of motion, a set g-force acceleration threshold or a time interval as the basis for location reporting. \n\nThe Tracker also comes with a user configurable multi-function button that can be configured to address different use case requirements.\n",
"install_end_text": "",
"device_annotation": "",
"device_parameters": [],
"networks": [
"../../../../network/lorawan-swisscom/v1.0.0/payload.js",
"../../../../network/lorawan-actility/v1.0.0/payload.js",
"../../../../network/lorawan-brdot-/v1.0.0/payload.js",
"../../../../network/lorawan-chirpstack/v1.0.0/payload.js",
"../../../../network/lorawan-citykinect/v1.0.0/payload.js",
"../../../../network/lorawan-everynet/v1.0.0/payload.js",
"../../../../network/lorawan-helium/v1.0.0/payload.js",
"../../../../network/lorawan-kerlink/v1.0.0/payload.js",
"../../../../network/lorawan-loriot-/v1.0.0/payload.js",
"../../../../network/lorawan-machineq/v1.0.0/payload.js",
"../../../../network/lorawan-orbiwise/v1.0.0/payload.js",
"../../../../network/lorawan-senet/v1.0.0/payload.js",
"../../../../network/lorawan-senra/v1.0.0/payload.js",
"../../../../network/lorawan-tektelic/v1.0.0/payload.js",
"../../../../network/lorawan-ttittn-v3/v1.0.0/payload.js"
]
}
Loading

0 comments on commit 43dbe55

Please sign in to comment.