Created
April 27, 2024 07:13
-
-
Save stefanbraun-private/e0db7e7389cb6406e20efa860c415ebc to your computer and use it in GitHub Desktop.
Datacake - monitoring LoRaWAN GPS tracker - payload decoder extracts JSON values into Datacake fields
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
// based on example from https://docs.datacake.de/integrations/webhook | |
// and https://docs.datacake.de/lorawan/payload-decoders/location-and-gps | |
// and https://docs.datacake.de/lorawan/converting-payload | |
// | |
// ==>webhook from Helium provides already the decoded JSON data! | |
function Decoder(bytes, port) { | |
// Extract Serial for Routing into Device | |
var device = rawPayload.dev_eui; | |
// Load Data | |
var latitude = rawPayload.decoded.payload.latitude; | |
var longitude = rawPayload.decoded.payload.longitude; | |
var altitude = rawPayload.decoded.payload.altitude; | |
var battery = rawPayload.decoded.payload.battery; | |
var fcnt = rawPayload.fcnt; | |
// Forward Data into Device using Serial | |
return [ | |
{ | |
device: device, | |
field: "LOCATION", | |
value: "(" + latitude + "," + longitude + ")" | |
}, | |
{ | |
device: device, | |
field: "ALTITUDE", | |
value: altitude | |
}, | |
{ | |
device: device, | |
field: "BATTERY_VOLTAGE", | |
value: battery | |
}, | |
{ | |
device: device, | |
field: "UPLINK_FRAME_COUNTER", | |
value: fcnt | |
}, | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment