LoRaWAN-Signal-Mapping/server/ttn-app-server/DecodePayload.mjs

18 lines
403 B
JavaScript
Raw Normal View History

"use strict";
const offset_id = 0;
const offset_lat = 32 / 8;
const offset_lng = (32 / 8) + (32 / 8);
function decode_payload(payload_base64) {
let payload_buffer = Buffer.from(payload_base64, "base64");
return {
id: payload_buffer.readUInt32LE(offset_id),
latitude: patload_buffer.readFloatLE(offset_lat),
longitude: patload_buffer.readFloatLE(offset_lng)
};
}
export { decode_payload };