-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from tago-io/feat/new-decoders-wittra-and-fractum
feat/new-decoders-wittra-and-fractum
- Loading branch information
Showing
16 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
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
13
decoders/connector/fractum/datalogger-sl-01/connector.jsonc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"$schema": "../../../../schema/connector.json", | ||
"name": "DataLogger SL-01 (Application for Rain Gauge)", | ||
"images": { | ||
"logo": "./assets/logo.png" | ||
}, | ||
"versions": { | ||
"v1.0.0": { | ||
"src": "./v1.0.0/payload.js", | ||
"manifest": "./v1.0.0/payload-config.jsonc" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Sensor NB-IoT By FRACTUM |
26 changes: 26 additions & 0 deletions
26
decoders/connector/fractum/datalogger-sl-01/v1.0.0/payload-config.jsonc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"$schema": "../../../../../schema/connector_details.json", | ||
"description": "../description.md", | ||
"install_text": "\r\n**Application already developed for Rain Gauge**\r\n\r\nThe SmartLogger 01 sensor is a multi-channel IoT Datalogger that runs on NB-IoT technology, \r\nenabling continuous monitoring in remote applications. \r\nThe collected data is recorded in the equipment's internal memory and published \r\nperiodically to other cloud systems.\r\n\r\n** **\r\n**FEATURES:**\r\n* NB-IoT Transmission Technology\r\n* MQTT protocol\r\n* 02 Current Inputs of 4-20mA\r\n* 02 Pulse Inputs\r\n* 02 Indication Led's\r\n* External I2C interface \r\n* USB interface\r\n* 1Wire interface\r\n* 17Ah 3.6V battery\r\n* Antenna with IP68 External SMA connection\r\n* IP68 enclosure\r\n* 1Gbit Internal Memory\r\n** **\r\n\r\n**General:**\r\n* Power: 3.6V battery\r\n* Current Consumption in Sleep: 300μA\r\n* Indication: Transmit and receive leds\r\n* Connectorization: removable terminal\r\n* Operating Temperature: -40 to +85°C\r\n* Operating Humidity: 10% to 90% (non-condensing)\r\n\r\n**Made in Brazil by [Fractum](https://www.fractum.com.br/)**", | ||
"install_end_text": "## SmartLogger 01 Documentation:\r\n\r\n### Download the file:\r\n### [**Datasheet SL-01**](https://www.fractum.com.br/_files/ugd/662363_3232b151fc1144738f254e8d8a7a7521.pdf) ", | ||
"device_annotation": "", | ||
"device_parameters": [ | ||
{ | ||
"default": "", | ||
"group": "main", | ||
"label": "Device Latitude", | ||
"name": "lat", | ||
"type": "number" | ||
}, | ||
{ | ||
"default": "", | ||
"group": "main", | ||
"label": "Device longitude", | ||
"name": "lng", | ||
"type": "number" | ||
} | ||
], | ||
"networks": [ | ||
"../../../../network/mqtt/v1.0.0/payload.js" | ||
] | ||
} |
92 changes: 92 additions & 0 deletions
92
decoders/connector/fractum/datalogger-sl-01/v1.0.0/payload.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
|
||
const rawValues = payload.find((item) => item.variable === 'payload'); | ||
|
||
|
||
if (rawValues) | ||
{ | ||
const valuesString = rawValues.value; | ||
const splitValues = valuesString.split(";"); | ||
|
||
const filterIMEI = splitValues[1]; | ||
const filterSN = splitValues[25]; | ||
const filterTAG = splitValues[24]; | ||
const filterBattery = splitValues[9]; | ||
const filterTemperature = splitValues[10]; | ||
const filterMoisture = splitValues[11]; | ||
const filterPackage = splitValues[18]; | ||
const filterI0 = splitValues[4]; | ||
const filterI1 = splitValues[5]; | ||
const filterInt0 = splitValues[6]; | ||
const filterCSQ = splitValues[20]; | ||
const filterRSSI = splitValues[21]; | ||
const filterOperator = splitValues[23]; | ||
const filterDate = splitValues[16]; | ||
const filterHour = splitValues[17]; | ||
|
||
const imeiValues = filterIMEI.split(":"); | ||
const snValues = filterSN.split(":"); | ||
const tagValues = filterTAG.split(":"); | ||
const batteryValues = filterBattery.split(":"); | ||
const temperatureValues = filterTemperature.split(":"); | ||
const moistureValues = filterMoisture.split(":"); | ||
const packageValues = filterPackage.split(":"); | ||
const i0Values = filterI0.split(":"); | ||
const i1Values = filterI1.split(":"); | ||
const int0Values = filterInt0.split(":"); | ||
const csqValues = filterCSQ.split(":"); | ||
const rssiValues = filterRSSI.split(":"); | ||
const operatorValues = filterOperator.split(":"); | ||
const dateValues = filterDate.split(":"); | ||
|
||
const imei = imeiValues[1]; | ||
const sn = snValues[1]; | ||
const tag = tagValues[1]; | ||
const battery = batteryValues[1]; | ||
const temperature = temperatureValues[1]; | ||
const moisture = moistureValues[1]; | ||
const package = packageValues[1]; | ||
const i0 = i0Values[1]; | ||
const i1 = i1Values[1]; | ||
const int0 = int0Values[1]; | ||
const csq = csqValues[1]; | ||
const rssi = rssiValues[1]; | ||
const operator = operatorValues[1]; | ||
const date = dateValues[1]; | ||
const hour = filterHour.substring(5,13); | ||
const timestampAux = date+ " " + hour + ".000"; | ||
const timezoneAux = date + " " + hour; | ||
|
||
let i_0 = ((15*i0)/16) - (15/4); | ||
let i_1 = ((15*i1)/16) - (15/4); | ||
if(i_1 < 0){ | ||
i_1 = 0; | ||
}; | ||
if(i_0 < 0){ | ||
i_0 = 0; | ||
}; | ||
|
||
const lat = device.params.find((x) => x.key === 'lat'); | ||
const long = device.params.find((y) => y.key === 'lng'); | ||
|
||
const latitude = Number(lat.value); | ||
const longitude = Number(long.value); | ||
|
||
|
||
payload = []; | ||
payload.push({ "variable": "imei", "value": imei}); | ||
payload.push({ "variable": "sn", "value": sn}); | ||
payload.push({ "variable": "tag", "value": tag, "location": {"lat": latitude, "lng": longitude}}); | ||
payload.push({ "variable": "temperature", "value": temperature, "unit": "°C", "time": timestampAux}); | ||
payload.push({ "variable": "battery", "value": battery, "unit": "V"}); | ||
payload.push({ "variable": "package", "value": package}); | ||
payload.push({ "variable": "moisture", "value": moisture, "unit": "%UR", "time": timestampAux}); | ||
payload.push({ "variable": "I0", "value": i_0, "time": timestampAux, "unit": "mA"}); | ||
payload.push({ "variable": "I1", "value": i_1, "time": timestampAux, "unit": "mA"}); | ||
payload.push({ "variable": "INT0", "value": int0, "time": timestampAux, "unit": "mm/m²"}); | ||
payload.push({ "variable": "CSQ", "value": csq}); | ||
payload.push({ "variable": "RSSI", "value": rssi}); | ||
payload.push({ "variable": "operator", "value": operator}); | ||
payload.push({ "variable": "date", "value": timezoneAux}); | ||
|
||
} | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"$schema": "../../../../schema/connector.json", | ||
"name": "Custom WiTTRA", | ||
"images": { | ||
"logo": "./assets/logo.webp" | ||
}, | ||
"versions": { | ||
"v1.0.0": { | ||
"src": "./v1.0.0/payload.js", | ||
"manifest": "./v1.0.0/payload-config.jsonc" | ||
} | ||
} | ||
} |
Empty file.
11 changes: 11 additions & 0 deletions
11
decoders/connector/wittra/custom-wittra/v1.0.0/payload-config.jsonc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "../../../../../schema/connector_details.json", | ||
"description": "../description.md", | ||
"install_text": "Use this quick setup to create an integration between WiTTRA and TagoIO if you didn't find your specific device in the list.\n", | ||
"install_end_text": "", | ||
"device_annotation": "", | ||
"device_parameters": [], | ||
"networks": [ | ||
"../../../../network/wittra/v1.0.0/payload.js" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Parses the payload and returns an array of data objects. | ||
* | ||
* @param {Object} payload - The payload object containing the data to be parsed. | ||
* @param {string} group - The group identifier for the data. | ||
* @param {string} receivedTime - The time the payload was received. | ||
* @returns {Array} An array of data objects extracted from the payload. | ||
*/ | ||
function parseWittraPayload(payload, group, receivedTime) { | ||
let data = []; | ||
const time = receivedTime || new Date().toISOString(); | ||
|
||
// Helper function to add data to the array | ||
function addData(variable, value, unit, metadata, location) { | ||
data.push({ variable, value, unit, group, time, metadata, location }); | ||
} | ||
|
||
// Iterate through the payload keys | ||
for (const key of Object.keys(payload)) { | ||
const value = payload[key]; | ||
|
||
if (typeof value === "object" && !Array.isArray(value)) { | ||
// Handle nested objects | ||
for (const subKey of Object.keys(value)) { | ||
const subValue = value[subKey]; | ||
addData(`${key}_${subKey}`, subValue, undefined, undefined); | ||
} | ||
} else if (Array.isArray(value)) { | ||
// Handle arrays by putting information in the metadata | ||
value.forEach((item, index) => { | ||
addData(`${key}_${index}`, null, undefined, item); | ||
}); | ||
} else { | ||
// Handle simple key-value pairs | ||
addData(key, value, undefined, undefined); | ||
} | ||
} | ||
|
||
// Handle location separately | ||
if (payload.location) { | ||
const { latitude, longitude, ...locationMetadata } = payload.location; | ||
if (latitude && longitude) { | ||
data = data.filter((x) => !x.variable.includes("latitude") && !x.variable.includes("longitude")); | ||
addData("location", `${latitude},${longitude}`, undefined, { lat: latitude, lng: longitude, ...locationMetadata }, { lat: latitude, lng: longitude }); | ||
} | ||
} | ||
|
||
return data; | ||
} | ||
|
||
// Handle Received Data | ||
const wittraPayload = payload.find((x) => x.variable === "wittra_payload"); | ||
if (wittraPayload) { | ||
const contentJSON = JSON.parse(wittraPayload.value); | ||
const parsedData = parseWittraPayload(contentJSON.payload, wittraPayload.group, contentJSON.timestamp); | ||
payload = parsedData; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$schema": "../../../schema/network.json", | ||
"name": "WiTTRA", | ||
"images": { | ||
"logo": "", | ||
"icon": "./assets/icon.webp", | ||
"banner": "./assets/banner.png" | ||
}, | ||
"versions": { | ||
"v1.0.0": { | ||
"src": "./v1.0.0/payload.js", | ||
"manifest": "./v1.0.0/payload-config.jsonc" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"$schema": "../../../../schema/network_details.json", | ||
"description": "../description.md", | ||
"serial_number_config": { | ||
"required": true, | ||
"label": "EUI", | ||
"case": "upper" | ||
}, | ||
"device_parameters": [], | ||
"middleware_endpoint": "wittra.middleware.tago.io", | ||
"documentation_url": "help.tago.io/portal/en/community/topic/how-to-integrate-with-wittra" | ||
} |
Empty file.