Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanbraun-private/e0db7e7389cb6406e20efa860c415ebc to your computer and use it in GitHub Desktop.
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
// 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