Skip to content

Commit

Permalink
Merge pull request #23 from thiasB/master
Browse files Browse the repository at this point in the history
adapt decoder function to The Things Stack V3
  • Loading branch information
sabas1080 authored Mar 6, 2021
2 parents 8411049 + 5e1aefd commit 0af5bfd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions decoders/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,19 @@ function lppDecode(bytes) {
}

// To use with TTN
function Decoder(bytes, fPort) {

function decodeUplink(input) {

bytes = input.bytes;
fPort = input.fPort;

// flat output (like original decoder):
var response = {};
lppDecode(bytes, 1).forEach(function(field) {
response[field['name'] + '_' + field['channel']] = field['value'];
});
return response;
return {
data: response
};

// field output
//return {'fields': lppDecode(bytes, fPort)};
Expand All @@ -171,4 +176,4 @@ function Decoder(bytes, fPort) {
/*
msg.fields = lppDecode(msg.payload);
return msg;
*/
*/

0 comments on commit 0af5bfd

Please sign in to comment.