fix gnss timestamp
This commit is contained in:
parent
59dc57a618
commit
62a2dc2c4a
@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS wifi_scan (
|
|||||||
lp_ttn_end_device_uplinks_id UUID,
|
lp_ttn_end_device_uplinks_id UUID,
|
||||||
mac VARCHAR(255),
|
mac VARCHAR(255),
|
||||||
rssi NUMERIC,
|
rssi NUMERIC,
|
||||||
scanned_at_utc DATE NOT NULL;
|
scanned_at_utc TIMESTAMP NOT NULL,
|
||||||
created_at_utc TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
created_at_utc TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
updated_at_utc TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
updated_at_utc TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
FOREIGN KEY (lp_ttn_end_device_uplinks_id) REFERENCES lp_ttn_end_device_uplinks(lp_ttn_end_device_uplinks_id)
|
FOREIGN KEY (lp_ttn_end_device_uplinks_id) REFERENCES lp_ttn_end_device_uplinks(lp_ttn_end_device_uplinks_id)
|
||||||
@ -64,7 +64,7 @@ CREATE TABLE IF NOT EXISTS location (
|
|||||||
gnss_longitude DOUBLE,
|
gnss_longitude DOUBLE,
|
||||||
ttn_gw_latitude DOUBLE,
|
ttn_gw_latitude DOUBLE,
|
||||||
ttn_gw_longitude DOUBLE,
|
ttn_gw_longitude DOUBLE,
|
||||||
gnss_location_at_utc DATE;
|
gnss_location_at_utc TIMESTAMP,
|
||||||
created_at_utc TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
created_at_utc TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
updated_at_utc TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
updated_at_utc TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
FOREIGN KEY (lp_ttn_end_device_uplinks_id) REFERENCES lp_ttn_end_device_uplinks(lp_ttn_end_device_uplinks_id)
|
FOREIGN KEY (lp_ttn_end_device_uplinks_id) REFERENCES lp_ttn_end_device_uplinks(lp_ttn_end_device_uplinks_id)
|
||||||
|
@ -51,14 +51,14 @@ router.post(
|
|||||||
)?.measurementValue,
|
)?.measurementValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
const gnssTimestamp = {
|
const gnssMetadata = message.uplink_message.decoded_payload?.messages[0].find(
|
||||||
timestamp: message.uplink_message.decoded_payload?.messages[0].find(
|
|
||||||
(e) => e.type === "Latitude"
|
(e) => e.type === "Latitude"
|
||||||
)?.timestamp
|
);
|
||||||
|
|
||||||
|
const gnssTimestamp = {
|
||||||
|
timestamp: gnssMetadata?.timestamp ? new Date(gnssMetadata.timestamp) : undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const wifiScans =
|
const wifiScans =
|
||||||
message.uplink_message.decoded_payload?.messages[0]
|
message.uplink_message.decoded_payload?.messages[0]
|
||||||
.find((e) => e.type === "Wi-Fi Scan")
|
.find((e) => e.type === "Wi-Fi Scan")
|
||||||
@ -107,8 +107,7 @@ router.post(
|
|||||||
|
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
|
gnss_timestamp: gnssTimestamp.timestamp,
|
||||||
gnss_timestamp: new Date(gnssTimestamp.timestamp),
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
createDatabaseEntries().then();
|
createDatabaseEntries().then();
|
||||||
|
@ -10,7 +10,7 @@ export class Location extends Model {
|
|||||||
public gnss_longitude!: number;
|
public gnss_longitude!: number;
|
||||||
public ttn_gw_latitude!: number;
|
public ttn_gw_latitude!: number;
|
||||||
public ttn_gw_longitude!: number;
|
public ttn_gw_longitude!: number;
|
||||||
public gnss_timestamp!: Date;
|
public gnss_location_at_utc!: Date;
|
||||||
public created_at_utc!: Date;
|
public created_at_utc!: Date;
|
||||||
public updated_at_utc!: Date;
|
public updated_at_utc!: Date;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ export class WifiScan extends Model {
|
|||||||
public wifi_scan_id!: string;
|
public wifi_scan_id!: string;
|
||||||
public mac!: string;
|
public mac!: string;
|
||||||
public rssi!: number;
|
public rssi!: number;
|
||||||
|
public scanned_at_utc!: Date;
|
||||||
public created_at_utc!: Date;
|
public created_at_utc!: Date;
|
||||||
public updated_at_utc!: Date;
|
public updated_at_utc!: Date;
|
||||||
}
|
}
|
||||||
@ -32,6 +33,8 @@ WifiScan.init(
|
|||||||
},
|
},
|
||||||
scanned_at_utc: {
|
scanned_at_utc: {
|
||||||
type: DataTypes.DATE,
|
type: DataTypes.DATE,
|
||||||
|
defaultValue: DataTypes.NOW,
|
||||||
|
allowNull: false,
|
||||||
},
|
},
|
||||||
created_at_utc: {
|
created_at_utc: {
|
||||||
type: DataTypes.DATE,
|
type: DataTypes.DATE,
|
||||||
|
@ -19,7 +19,7 @@ interface CreateLocationTriangulationParams {
|
|||||||
}[];
|
}[];
|
||||||
ttn_gw: LocationSignal[];
|
ttn_gw: LocationSignal[];
|
||||||
gnss?: Coordinates;
|
gnss?: Coordinates;
|
||||||
gnss_timestamp: Date;
|
gnss_timestamp?: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LocationSignal extends Coordinates {
|
interface LocationSignal extends Coordinates {
|
||||||
@ -67,7 +67,7 @@ export class LocationService {
|
|||||||
ttn_gw_longitude: data.ttn_gw?.longitude,
|
ttn_gw_longitude: data.ttn_gw?.longitude,
|
||||||
gnss_latitude: data.gnss?.latitude,
|
gnss_latitude: data.gnss?.latitude,
|
||||||
gnss_longitude: data.gnss?.longitude,
|
gnss_longitude: data.gnss?.longitude,
|
||||||
gnss_timestamp: data.gnss_timestamp,
|
gnss_location_at_utc: data.gnss_timestamp,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ export class LocationService {
|
|||||||
wifi: wifi_location,
|
wifi: wifi_location,
|
||||||
ttn_gw: gateway_location,
|
ttn_gw: gateway_location,
|
||||||
gnss: data.gnss,
|
gnss: data.gnss,
|
||||||
|
gnss_timestamp: data.gnss_timestamp,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user