Skip to content

Commit

Permalink
Merge branch 'master' into reseller-uk
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaime-Trinidad committed Sep 9, 2024
2 parents 5576bc0 + 83c7ec4 commit b7c8e9c
Show file tree
Hide file tree
Showing 6 changed files with 288 additions and 62 deletions.
64 changes: 46 additions & 18 deletions vendor/elv/elv-bm-trx1.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* ELV modular system Payload-Parser
*
* Version: V1.9.0
* Version: V1.10.1
*
* */

Expand Down Expand Up @@ -786,7 +786,7 @@ function Decoder(bytes, port) {
}
case 0x14: //6-Axis-Sensor
{
index++;
index++;
decoded.Acc_x = !!(bytes[index] & 0x01);
decoded.Acc_y = !!(bytes[index] & 0x02);
decoded.Acc_z = !!(bytes[index] & 0x04);
Expand All @@ -797,26 +797,65 @@ function Decoder(bytes, port) {
}
case 0x15: //Window-State
{
index++;
index++;
data = bytes[index];
if (data < 100)
{
decoded.window_state = data;
decoded.Window_State = data;
}
else if (data == 255)
{
decoded.window_state = "Tilted"
decoded.Window_State = "Tilted"
}
else
{
decoded.window_state = "Undefined"
decoded.Window_State = "Undefined"
}
break;
}
case 0x16:
{
index++;
decoded.situation = bytes[index];
decoded.Situation = bytes[index];
break;
}
case 0x17: // UV-Index
{
decoded.UVI = bytes[++index];
break;
}
case 0x18: // UV-A
{
decoded.UVA = ( bytes[++index] << 24 ) | ( bytes[++index] << 16 ) | ( bytes[++index] << 8 ) | bytes[++index];
decoded.UVA /= 1000000;

break;
}
case 0x19: // UV-B
{
decoded.UVB = ( bytes[++index] << 24 ) | ( bytes[++index] << 16 ) | ( bytes[++index] << 8 ) | bytes[++index];
decoded.UVB /= 1000000;

break;
}
case 0x1A: // UV-C
{
decoded.UVC = ( bytes[++index] << 24 ) | ( bytes[++index] << 16 ) | ( bytes[++index] << 8 ) | bytes[++index];
decoded.UVC /= 1000000;

break;
}
case 0x1B: // Irradiance
{
decoded.Irradiance = ( bytes[++index] << 8 ) | bytes[++index];

if( decoded.Irradiance == 0xFFFF )
{
decoded.Irradiance = 0;
}

decoded.Irradiance /= 10;

break;
}
// case 0x??: // Further Data Type
Expand Down Expand Up @@ -853,14 +892,3 @@ function Decoder(bytes, port) {

return decoded;
}

function decodeDownlink(input) {
return {
data: {
bytes: input.bytes
},
warnings: [],
errors: []
}
}

6 changes: 3 additions & 3 deletions vendor/fludia/fm432g-10-15mn-decode.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ function decode_T1(payload,time_step){
function decode_T1_adjustable_step(payload){
var data = {};
data.time_step = payload[1];
data.index = (payload[2] & 0xFF) << 24 | (payload[3] & 0xFF) << 16 | (payload[4] & 0xFF) << 8 | (payload[5] & 0xFF);
data.index = ((payload[2] & 0xFF) << 24 | (payload[3] & 0xFF) << 16 | (payload[4] & 0xFF) << 8 | (payload[5] & 0xFF))/10;
data.increments = []
var nb_values_in_payload = (payload.length-6)/2
for(i=0;i<nb_values_in_payload;i++){
data.increments.push((payload[6+2*i] & 0xFF) << 8 | (payload[7+2*i] & 0xFF))
data.increments.push(((payload[6+2*i] & 0xFF) << 8 | (payload[7+2*i] & 0xFF))/10)
}
return data
}
Expand All @@ -142,7 +142,7 @@ function decode_T2_adjustable_step(payload){
data.number_of_starts = payload[1];
data.param_id = payload[4];
data.firmware_version = payload[5];
data.index = (payload[8] & 0xFF) << 24 | (payload[9] & 0xFF) << 16 | (payload[10] & 0xFF) << 8 | (payload[11] & 0xFF);
data.index = ((payload[8] & 0xFF) << 24 | (payload[9] & 0xFF) << 16 | (payload[10] & 0xFF) << 8 | (payload[11] & 0xFF))/10;
data.time_step = payload[12];
data.nb_values = payload[13];
data.redundancy = payload[14];
Expand Down
89 changes: 48 additions & 41 deletions vendor/nexelec/sign-codec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function decodeUplink(input)

function dataOutput(octetTypeMessage)
{
outputTypeMessage=["Reserved",periodicDataOutput(stringHex),historicalCO2DataOutput(stringHex),historicalTemperatureDataOutput(stringHex),"Reserved",productStatusDataOutput(stringHex),
outputTypeMessage=["Reserved",periodicDataOutput(stringHex),historicalCO2DataOutput(stringHex),historicalTemperatureDataOutput(stringHex),historicalHumidityDataOutput(stringHex),productStatusDataOutput(stringHex),
productConfigurationDataOutput(stringHex)]
return outputTypeMessage[octetTypeMessage]
}
Expand All @@ -39,12 +39,13 @@ function decodeUplink(input)
if(octetTypeProduit==0xA9){return "Feel LoRa"}
if(octetTypeProduit==0xAA){return "Rise LoRa"}
if(octetTypeProduit==0xAB){return "Move LoRa"}
if(octetTypeProduit==0xAC){return "Wave LoRa"}
if(octetTypeProduit==0xAD){return "Sign LoRa"}
}

function typeOfMessage(octetTypeMessage)
{
const message_name =["Reserved","Periodic data","CO2 Historical Data","Temperature Historical Data" ,"Reserved","Product Status","Product Configuration"]
const message_name =["Reserved","Periodic data","CO2 Historical Data","Temperature Historical Data" ,"Humidity Historical Data","Product Status","Product Configuration"]
return message_name[octetTypeMessage]
}

Expand Down Expand Up @@ -272,7 +273,7 @@ function decodeUplink(input)

function loraRegion(octetLoRaRegion)
{
const message_name =["EU868","US915","AS923","AU915","KR920","IN865","RU864"]
const message_name =["Reserved","EU868","US915","Reserved","Reserved","Reserved","Reserved","Reserved","SF-RC1"]
return message_name[octetLoRaRegion]
}

Expand Down Expand Up @@ -335,37 +336,11 @@ function decodeUplink(input)
return string_bin;
}

/*
function hexToBinary(stringHex)
{
var hex2=stringHex.toUpperCase() // pour convertir des string en hexa il faut qu'ils soient en majuscule
var str1="";
var string_bin="";
var str=0;
var buffer=[];
// On crée un tableau d'hexa (buffer)
for(i=0; i<hex2.length;i++)
{
str=parseInt(hex2.charAt(i), 16);
buffer.push(str);
}
buffer = Buffer.from(buffer);
for(i=0; i<hex2.length;i++)
{
str1=hex2.charAt(i); // on prend le premier caractères (string)
str1=parseInt(str1, 16).toString(2).padStart(4,'0');
string_bin=string_bin+str1;
}
return string_bin
}
*/

//////////////////////////////////////////////////////////////////////
////// Product message decoding
////////////////////////////////////////////////////////////////////


function periodicDataOutput(stringHex)
{
var data_temperature = (parseInt(stringHex.substring(4,8),16) >> 6) & 0x3FF;
Expand Down Expand Up @@ -398,7 +373,7 @@ function decodeUplink(input)
"iziairCo2": iaqGlobalArgument(data_izi_air_co2),
"iziairCov": iaqGlobalArgument(data_izi_air_cov),
};


return data;
}
Expand All @@ -411,7 +386,7 @@ function decodeUplink(input)
var offset_octet = 0;

var data_nombre_mesures = (parseInt(stringHex.substring(4,6),16)>>2)&0x3F;
var data_time_between_measurement_sec = ((parseInt(stringHex.substring(4,8),16)>>2)&0xFF);
var data_time_between_measurement_min = ((parseInt(stringHex.substring(4,8),16)>>2)&0xFF);
var data_repetition = (parseInt(stringHex.substring(7,9),16))&0x3F;
var binary=hexToBinary(stringHex)

Expand All @@ -421,17 +396,17 @@ function decodeUplink(input)
mesure[i]= parseInt(binary.substring(offset_binaire,offset_binaire+10),2);

if(mesure[i] === 0x3FF){mesure[i] = 0;}
else{mesure[i] = Math.round(mesure[i] * 5)}
else{mesure[i] = parseFloat((mesure[i] * 5).toFixed(2))}
}

data={ "typeOfProduct": typeOfProduct(octetTypeProduit),
"typeOfMessage": typeOfMessage(octetTypeMessage),
"numberOfRecord": data_nombre_mesures,
"periodBetweenRecord":{"value":data_time_between_measurement_sec,"unit":"minutes"},
"periodBetweenRecord":{"value":data_time_between_measurement_min*10,"unit":"minutes"},
"redundancyOfRecord":data_repetition,
"co2":{"value":mesure,"unit":"ppm"},
}

return data
}

Expand All @@ -441,29 +416,59 @@ function decodeUplink(input)
var i = 0;

var data_nombre_mesures = (parseInt(stringHex.substring(4,6),16)>>2)&0x3F;
var data_time_between_measurement_sec = ((parseInt(stringHex.substring(4,8),16)>>2)&0xFF);
var data_time_between_measurement_min = ((parseInt(stringHex.substring(4,8),16)>>2)&0xFF);
var data_repetition = (parseInt(stringHex.substring(7,9),16))&0x3F;
var binary=hexToBinary(stringHex)

for(i=0;i<data_nombre_mesures;i++){

offset_binaire = 36 + (10*i);

mesure[i]= parseInt(binary.substring(offset_binaire,offset_binaire+10),2);

if(mesure[i] === 0x3FF){mesure[i] = 0;}
else{mesure[i] = Math.round((mesure[i]/10)-30)}
else{mesure[i] = parseFloat(((mesure[i] / 10) - 30).toFixed(2))}

}

data={ "typeOfProduct": typeOfProduct(octetTypeProduit),
"typeOfMessage": typeOfMessage(octetTypeMessage),
"numberOfRecord": data_nombre_mesures,
"periodBetweenRecord":{"value":data_time_between_measurement_sec,"unit":"minutes"},
"periodBetweenRecord":{"value":data_time_between_measurement_min*10,"unit":"minutes"},
"redundancyOfRecord":data_repetition,
"temperature":{"value":mesure,"unit":"°C"},
}

}
return data;
}

function historicalHumidityDataOutput(stringHex)
{
var mesure = [];
var i = 0;

var data_nombre_mesures = (parseInt(stringHex.substring(4,6),16)>>2)&0x3F;
var data_time_between_measurement_min = ((parseInt(stringHex.substring(4,8),16)>>2)&0xFF);
var data_repetition = (parseInt(stringHex.substring(7,9),16))&0x3F;
var binary=hexToBinary(stringHex)

for(i=0;i<data_nombre_mesures;i++){

offset_binaire = 36 + (10*i);

mesure[i]= parseInt(binary.substring(offset_binaire,offset_binaire+10),2);

if(mesure[i] === 0x3FF){mesure[i] = 0;}
else{mesure[i] = parseFloat((mesure[i]*0.1).toFixed(2))}

}

data={ "typeOfProduct": typeOfProduct(octetTypeProduit),
"typeOfMessage": typeOfMessage(octetTypeMessage),
"numberOfRecord": data_nombre_mesures,
"periodBetweenRecord":{"value":data_time_between_measurement_min*10,"unit":"minutes"},
"redundancyOfRecord":data_repetition,
"humidity":{"value":mesure,"unit":"%RH"},
}
return data;
}

Expand Down Expand Up @@ -546,6 +551,7 @@ function decodeUplink(input)
var data_date_produit_jour = (parseInt(stringHex.substring(29,31),16)) & 0x1F;
var data_date_produit_heure = (parseInt(stringHex.substring(31,33),16)>>3) & 0x1F;
var data_date_produit_minute = (parseInt(stringHex.substring(32,34),16)>>1) & 0x3F;
var data_datalog_humidity_on_off = (parseInt(stringHex.substring(33,34),16)) & 0x01;


data = {"typeOfProduct": typeOfProduct(octetTypeProduit),
Expand Down Expand Up @@ -574,6 +580,7 @@ function decodeUplink(input)
"deltaTemperature": deltaTemp(data_periodic_delta_temp),
"historicalCO2DataActivation":active(data_datalog_co2_on_off),
"historicalTemperatureDataActivation":active(data_datalog_temperature_on_off),
"historicalHumidityDataActivation":active(data_datalog_humidity_on_off),
"numberOfRecordsInADatalogMessage":data_datalog_new_measure,
"numberOfMessagesFor1Record":data_datalog_repetition,
"transmissionPeriodOfHistoricalMessage":transmissionPeriodHistorical(data_datalog_tx_period),
Expand Down
10 changes: 10 additions & 0 deletions vendor/nexelec/wave-codec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Uplink decoder decodes binary data uplink into a JSON object (optional)
# For documentation on writing encoders and decoders, see: https://thethingsstack.io/integrations/payload-formatters/javascript/
uplinkDecoder:
fileName: sign-codec.js

downlinkEncoder:
fileName: sign-codec.js

downlinkDecoder:
fileName: sign-codec.js
47 changes: 47 additions & 0 deletions vendor/nexelec/wave-profile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# LoRaWAN MAC version: 1.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4 or 1.1
macVersion: 1.0.4
# 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: RP002-1.0.3

# Whether the end device supports join (OTAA) or not (ABP)
supportsJoin: true
# If your device is an ABP device (supportsJoin is false), uncomment the following fields:
# RX1 delay
#rx1Delay: 5
# RX1 data rate offset
#rx1DataRateOffset: 0
# RX2 data rate index
#rx2DataRateIndex: 0
# RX2 frequency (MHz)
#rx2Frequency: 869.525
# Factory preset frequencies (MHz)
#factoryPresetFrequencies: [868.1, 868.3, 868.5, 867.1, 867.3, 867.5, 867.7, 867.9]

# Maximum EIRP
maxEIRP: 14
# Whether the end device supports 32-bit frame counters
supports32bitFCnt: true

# Whether the end device supports class B
supportsClassB: false
# If your device supports class B, uncomment the following fields:
# Maximum delay for the end device to answer a MAC request or confirmed downlink frame (seconds)
#classBTimeout: 60
# Ping slot period (seconds)
#pingSlotPeriod: 128
# Ping slot data rate index
#pingSlotDataRateIndex: 0
# Ping slot frequency (MHz). Set to 0 if the band supports ping slot frequency hopping.
#pingSlotFrequency: 869.525

# Whether the end device supports class C
supportsClassC: false
# If your device supports class C, uncomment the following fields:
# Maximum delay for the end device to answer a MAC request or confirmed downlink frame (seconds)
#classCTimeout: 60
Loading

0 comments on commit b7c8e9c

Please sign in to comment.