Skip to content

Commit

Permalink
Merge branch 'master' into fix-R718N3
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaime-Trinidad authored Nov 24, 2023
2 parents 7fbafa1 + c0550c5 commit 3661803
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vendor/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1987,3 +1987,7 @@ vendors:
website: https://www.senso8.com/
logo: senso8-logo.svg
linkedin: https://www.linkedin.com/company/arwin-technology-limited/

- id: tip
name: TIP Meter
website: https://www.tip-meter.de/
5 changes: 5 additions & 0 deletions vendor/tip/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This example contains just one end device: windsensor. It is referenced here in the index.

endDevices:
# Unique identifier of the end device (lowercase, alphanumeric with dashes, max 36 characters)
- sinus85 # look in windsensor.yaml for the end device definition
4 changes: 4 additions & 0 deletions vendor/tip/sinus85-codec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Uplink decoder decodes binary data uplink into a JSON object (optional)
# For documentation on writing encoders and decoders, see: https://www.thethingsindustries.com/docs/integrations/payload-formatters/javascript/
uplinkDecoder:
fileName: sinus85.js
28 changes: 28 additions & 0 deletions vendor/tip/sinus85-profile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Vendor profile ID, can be freely issued by the vendor
# This vendor profile ID is also used on the QR code for LoRaWAN devices, see
# https://lora-alliance.org/sites/default/files/2020-10/LoRa_Alliance_Vendor_ID_for_QR_Code.pdf
vendorProfileID: 1

# LoRaWAN MAC version: 1.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4 or 1.1
macVersion: '1.0.3'
# LoRaWAN Regional Parameters version. Values depend on the LoRaWAN version:
# 1.0: TS001-1.0
# 1.0.1: TS001-1.0.1
# 1.0.2: RP001-1.0.2 or RP001-1.0.2-RevB
# 1.0.3: RP001-1.0.3-RevA
# 1.0.4: RP002-1.0.0 or RP002-1.0.1
# 1.1: RP001-1.1-RevA or RP001-1.1-RevB
regionalParametersVersion: 'RP001-1.0.3-RevA'

# Whether the end device supports join (OTAA) or not (ABP)
supportsJoin: true

# Maximum EIRP
maxEIRP: 16

# Whether the end device supports 32-bit frame counters
supports32bitFCnt: true

# Whether the end device supports class B
supportsClassB: false
supportsClassC: false
126 changes: 126 additions & 0 deletions vendor/tip/sinus85.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
const reg2obisMapping = {
"1": "1.8.1",
"2": "2.8.1",
"3": "3.8.1",
"4": "4.8.1",
"5": "1.8.2",
"6": "2.8.2",
"7": "3.8.2",
"8": "4.8.2",
"9": "1.7.0",
"10": "3.7.0",
"11": "9.7.0",
"12": "14.7.0",
"13": "13.7.0",
"14": "T1 Wirk Energie Zähler Import",
"15": "21.7.0",
"16": "23.7.0",
"17": "29.7.0",
"18": "32.7.0",
"19": "31.7.0",
"20": "33.7.0",
"21": "T1 Wirk Energie Zähler Export",
"22": "T1 Blind Energie Zähler Import",
"23": "41.7.0",
"24": "43.7.0",
"25": "49.7.0",
"26": "52.7.0",
"27": "51.7.0",
"28": "53.7.0",
"29": "T1 Blind Energie Zähler Export",
"30": "T2 Wirk Energie Zähler Import",
"31": "61.7.0",
"32": "63.7.0",
"33": "69.7.0",
"34": "72.7.0",
"35": "71.7.0",
"36": "73.7.0",
"37": "T2 Wirk Energie Zähler Export",
"38": "T2 Blind Energie Zähler Import",
"39": "T2 Blind Energie Zähler Export",
};

const reg2obis = (reg_hex) => reg2obisMapping[reg_hex.toString()] || reg_hex.toString();

function parseHeaders(bytes) {
const result = {};
const hex_string = bytes.map(byte => byte.toString(16).padStart(2, '0')).join('');

// Determine Frame Control
result.Fctrl = hex_string.substring(0, 2);

// Determine Number of Registers
result.Number_Registers = parseInt(hex_string.substring(2, 4), 16) - 2;

// Determine Control Array Input
const expectedLength = 2 + 2 + 2 * result.Number_Registers + 8 + 6;
if (hex_string.length >= expectedLength) {
result.Control_Array = hex_string.substring(4, 4 + 2 * result.Number_Registers);
} else {
return {};
}

return result;
}

function padLeadingZeros(num, size) {
var s = num + "";
while (s.length < size) s = "0" + s;
return s;
}

function get_registers(bytes, header) {
var hex_string = bytes.map(byte => byte.toString(16).padStart(2, '0')).join('').toUpperCase();

var current_frame_ptr = 12;

//modular size
current_frame_ptr = 4 + 2 * parseInt(header.Number_Registers, 16); //fctl 2 + register 2 + Control_Array

//Check for sufficient data
if (hex_string.length >= 10 + 2 * (parseInt(header.Number_Registers, 16) - 1)) {
serial_nr = hex_string.substring(current_frame_ptr, current_frame_ptr + 8);
current_frame_ptr += 8;

current_frame_ptr += 6;
} else {
return {};
}

var range = parseInt(header.Number_Registers, 16);
var measures = {};
var _ctl, _endpointstr, _value, _reg;

for (let i = 1; i <= range; i++) {
_ctl = "";
_endpointstr = "";

_endpointstr = reg2obis(parseInt(header.Control_Array.substring((i - 1) * 2, i * 2), 16).toString(10));

_value = hex_string.substring(current_frame_ptr, current_frame_ptr + 8);
_reg = parseInt(_value, 16).toString(10);

measures[_endpointstr] = _reg;
current_frame_ptr += 8;
}

return measures;
}


function decodeUplink(input) {
//Read Codec Header from Message
var header = parseHeaders(input.bytes);

if (Object.keys(header).length === 0 && header.constructor === Object) {
return {
errors: [
"IIoT Box Decoder: Header decoder returned empty header, stop decoding message",
],
};
}

return {
data: get_registers(input.bytes, header),
};
}
13 changes: 13 additions & 0 deletions vendor/tip/sinus85.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Sinus 85
description: Direct measuring digital three-phase meter for DIN rail mounting

# Firmware versions (at least one is mandatory)
firmwareVersions:
- # Firmware version
version: '1.0.3'
numeric: 1
profiles:
EU863-870:
id: sinus85-profile
lorawanCertified: true
codec: sinus85-codec

0 comments on commit 3661803

Please sign in to comment.