2019-07-04 16:18:38 +00:00
|
|
|
"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");
|
|
|
|
|
2019-07-09 12:14:12 +00:00
|
|
|
// console.debug(`Offsets: ${offset_id}, ${offset_lat}, ${offset_lng}`);
|
|
|
|
// console.debug(`Message hex: ${payload_buffer.toString("hex")}`)
|
|
|
|
|
2019-07-04 16:18:38 +00:00
|
|
|
return {
|
|
|
|
id: payload_buffer.readUInt32LE(offset_id),
|
2019-07-09 12:14:12 +00:00
|
|
|
latitude: payload_buffer.readFloatLE(offset_lat),
|
|
|
|
longitude: payload_buffer.readFloatLE(offset_lng)
|
2019-07-04 16:18:38 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export { decode_payload };
|