Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaime-Trinidad authored Jul 27, 2023
2 parents 4077ed2 + af31e0d commit bb7bcba
Show file tree
Hide file tree
Showing 16 changed files with 463 additions and 192 deletions.
148 changes: 121 additions & 27 deletions vendor/enginko/decodel-level.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ function decodeUplink(payload) {
content = parseTimeSync(payload.trim());
break;

case '0A':
content = parseIO(payload.trim());
break;

case '14':
content = parseLevel(payload.trim());
break;
Expand Down Expand Up @@ -61,34 +65,34 @@ function TTNto(content) {
}

function parseTimeSync(payload) {
const uplinkId = payload.substring(0, 2);
if (uplinkId.toUpperCase() === '01') {
const syncID = {
variable: 'syncID',
value: payload.substring(2, 10)
};
const syncVersion = {
variable: 'syncVersion',
value: payload.substring(10, 12) + "." + payload.substring(12, 14) + "." + payload.substring(14, 16)
};
const applicationType = {
variable: 'applicationType',
value: payload.substring(16, 20)
};
const rfu = {
variable: 'rfu',
value: payload.substring(20)
};
const uplinkId = payload.substring(0, 2);
if (uplinkId.toUpperCase() === '01') {
const syncID = {
variable: 'syncID',
value: payload.substring(2, 10)
};
const syncVersion = {
variable: 'syncVersion',
value: payload.substring(10, 12) + "." + payload.substring(12, 14) + "." + payload.substring(14, 16)
};
const applicationType = {
variable: 'applicationType',
value: payload.substring(16, 20)
};
const rfu = {
variable: 'rfu',
value: payload.substring(20)
};

return [
syncID,
syncVersion,
applicationType,
rfu
];
} else {
return null;
}
return [
syncID,
syncVersion,
applicationType,
rfu
];
} else {
return null;
}
}

function parseLevel(payload) {
Expand Down Expand Up @@ -476,3 +480,93 @@ function parseDateByte(payload) {
date = new Date(year, month - 1, day, hour, minute, second, 0).toLocaleString();
return date;
}

function parseIO(payload) {
var uplinkId = payload.substring(0, 2);

if (uplinkId.toUpperCase() === '0A') {
var date = {
variable: 'date',
value: parseDate(payload.substring(2, 10)),
};
var firstByte = [];
var secondByte = [];
var thirdByte = [];
var fourthByte = [];
var k = 0;

for (var i = 0; i < 3; i++) {
firstByte[i] = parseInt(payload.substring(k + 10, k + 10 + 2), 16);
secondByte[i] = parseInt(payload.substring(k + 10 + 2, k + 10 + 4), 16);
thirdByte[i] = parseInt(payload.substring(k + 10 + 4, k + 10 + 6), 16);
fourthByte[i] = parseInt(payload.substring(k + 10 + 6, k + 10 + 8), 16);
k = k + 8;
}

var inputStatus8_1 = {
variable: 'inputStatus8_1',
value: parseFloat(firstByte[0].toString(2)),
};
var inputStatus9_16 = {
variable: 'inputStatus9_16',
value: parseFloat(secondByte[0].toString(2)),
};
var inputStatus17_24 = {
variable: 'inputStatus17_24',
value: parseFloat(thirdByte[0].toString(2)),
};
var inputStatus25_32 = {
variable: 'inputStatus25_32',
value: parseFloat(fourthByte[0].toString(2)),
};
var outputStatus8_1 = {
variable: 'outputStatus8_1',
value: parseFloat(firstByte[1].toString(2)),
};
var outputStatus9_16 = {
variable: 'outputStatus9_16',
value: parseFloat(secondByte[1].toString(2)),
};
var outputStatus17_24 = {
variable: 'outputStatus17_24',
value: parseFloat(thirdByte[1].toString(2)),
};
var outputStatus25_32 = {
variable: 'outputStatus25_32',
value: parseFloat(fourthByte[1].toString(2)),
};
var inputTrigger8_1 = {
variable: 'inputTrigger8_1',
value: parseFloat(firstByte[2].toString(2)),
};
var inputTrigger9_16 = {
variable: 'inputTrigger9_16',
value: parseFloat(secondByte[2].toString(2)),
};
var inputTrigger17_24 = {
variable: 'inputTrigger17_24',
value: parseFloat(thirdByte[2].toString(2)),
};
var inputTrigger25_32 = {
variable: 'inputTrigger25_32',
value: parseFloat(fourthByte[2].toString(2)),
};
return [
date,
inputStatus8_1,
inputStatus9_16,
inputStatus17_24,
inputStatus25_32,
outputStatus8_1,
outputStatus9_16,
outputStatus17_24,
outputStatus25_32,
inputTrigger8_1,
inputTrigger9_16,
inputTrigger17_24,
inputTrigger25_32,
];
} else {
return null;
}
}
56 changes: 28 additions & 28 deletions vendor/enginko/decoder-digital.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,34 +101,34 @@ function TTNto(content) {
}

function parseTimeSync(payload) {
const uplinkId = payload.substring(0, 2);
if (uplinkId.toUpperCase() === '01') {
const syncID = {
variable: 'syncID',
value: payload.substring(2, 10)
};
const syncVersion = {
variable: 'syncVersion',
value: payload.substring(10, 12) + "." + payload.substring(12, 14) + "." + payload.substring(14, 16)
};
const applicationType = {
variable: 'applicationType',
value: payload.substring(16, 20)
};
const rfu = {
variable: 'rfu',
value: payload.substring(20)
};

return [
syncID,
syncVersion,
applicationType,
rfu
];
} else {
return null;
}
const uplinkId = payload.substring(0, 2);
if (uplinkId.toUpperCase() === '01') {
const syncID = {
variable: 'syncID',
value: payload.substring(2, 10)
};
const syncVersion = {
variable: 'syncVersion',
value: payload.substring(10, 12) + "." + payload.substring(12, 14) + "." + payload.substring(14, 16)
};
const applicationType = {
variable: 'applicationType',
value: payload.substring(16, 20)
};
const rfu = {
variable: 'rfu',
value: payload.substring(20)
};

return [
syncID,
syncVersion,
applicationType,
rfu
];
} else {
return null;
}
}

function parseDigitalData(payload) {
Expand Down
56 changes: 28 additions & 28 deletions vendor/enginko/decoder-environmental.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,34 +102,34 @@ function TTNto(content) {
}

function parseTimeSync(payload) {
const uplinkId = payload.substring(0, 2);
if (uplinkId.toUpperCase() === '01') {
const syncID = {
variable: 'syncID',
value: payload.substring(2, 10)
};
const syncVersion = {
variable: 'syncVersion',
value: payload.substring(10, 12) + "." + payload.substring(12, 14) + "." + payload.substring(14, 16)
};
const applicationType = {
variable: 'applicationType',
value: payload.substring(16, 20)
};
const rfu = {
variable: 'rfu',
value: payload.substring(20)
};
const uplinkId = payload.substring(0, 2);
if (uplinkId.toUpperCase() === '01') {
const syncID = {
variable: 'syncID',
value: payload.substring(2, 10)
};
const syncVersion = {
variable: 'syncVersion',
value: payload.substring(10, 12) + "." + payload.substring(12, 14) + "." + payload.substring(14, 16)
};
const applicationType = {
variable: 'applicationType',
value: payload.substring(16, 20)
};
const rfu = {
variable: 'rfu',
value: payload.substring(20)
};

return [
syncID,
syncVersion,
applicationType,
rfu
];
} else {
return null;
}
return [
syncID,
syncVersion,
applicationType,
rfu
];
} else {
return null;
}
}

function parseTER(payload) {
Expand Down Expand Up @@ -196,7 +196,7 @@ function parseTERMeasurement(payload, number) {
unit: 'hPa',
};
}

return [date, temperature, humidity, pressure];
}

Expand Down
Loading

0 comments on commit bb7bcba

Please sign in to comment.