Skip to content

Commit

Permalink
#165 Add real timestamp from payload to tracker logs
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianGrabitzky committed Sep 19, 2023
1 parent 2f619ab commit 6283ab8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Server/src/routes/tracker.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class TrackerRoute {
res.sendStatus(200)
return
}
const timestamp = new Date()
const timestamp = new Date(trackerDataPayload.received_at)
const longitude = trackerDataPayload.uplink_message.decoded_payload.longitudeDeg
const latitude = trackerDataPayload.uplink_message?.decoded_payload?.latitudeDeg
const heading = trackerDataPayload.uplink_message.decoded_payload.headingDeg
Expand Down Expand Up @@ -198,6 +198,7 @@ export class TrackerRoute {
let latitude = 0.0
let heading = 0
let speed = 0
let timestamp = new Date()
let field0Present = false

let battery = undefined
Expand All @@ -213,6 +214,7 @@ export class TrackerRoute {
latitude = gpsField.Lat
heading = gpsField.Head
speed = gpsField.Spd
timestamp = new Date(gpsField.GpsUTC.replace(" ", "T").concat("Z"))
break
}
case 6: {
Expand All @@ -231,7 +233,7 @@ export class TrackerRoute {
}
await TrackerService.appendLog(
associatedVehicle,
new Date(), // TODO: use payload timestamp
timestamp,
[longitude, latitude],
heading,
speed,
Expand Down

0 comments on commit 6283ab8

Please sign in to comment.