teltonika
This commit is contained in:
525
app.js
525
app.js
@ -1,141 +1,158 @@
|
|||||||
require("dotenv").config({ path: ".env" });
|
require("dotenv").config({ path: ".env" })
|
||||||
require("events").EventEmitter.prototype._maxListeners = 30;
|
require("events").EventEmitter.prototype._maxListeners = 30
|
||||||
const morgan = require("morgan");
|
const morgan = require("morgan")
|
||||||
|
|
||||||
const net = require("net");
|
const net = require("net")
|
||||||
const dgram = require("dgram");
|
const dgram = require("dgram")
|
||||||
const crc = require("crc");
|
const crc = require("crc")
|
||||||
const moment = require("moment");
|
const moment = require("moment")
|
||||||
const LibDevice = require("./library/LibDevice");
|
const LibDevice = require("./library/LibDevice")
|
||||||
const GpsTracksModels = require("./models/GpsTracksModels");
|
const GpsTracksModels = require("./models/GpsTracksModels")
|
||||||
const ZoneModels = require("./models/ZoneModels");
|
const ZoneModels = require("./models/ZoneModels")
|
||||||
const VhcModels = require("./models/VhcModels");
|
const VhcModels = require("./models/VhcModels")
|
||||||
const LibMail = require("./library/LibMail");
|
const LibMail = require("./library/LibMail")
|
||||||
const LibHelper = require("./library/LibHelper");
|
const LibHelper = require("./library/LibHelper")
|
||||||
const nanoid = require("nanoid").nanoid;
|
const nanoid = require("nanoid").nanoid
|
||||||
const express = require("express");
|
const LibWinston = require("./library/LibWinston")
|
||||||
const routes = require("./routes/routes");
|
|
||||||
const app = express();
|
const express = require("express")
|
||||||
const LibWinston = require("./library/LibWinston");
|
// const routes = require("./routes/routes")
|
||||||
|
const listen = require("./routes/listen")
|
||||||
|
const app = express()
|
||||||
|
|
||||||
|
const logName = "libUdp"
|
||||||
|
const Logger = LibWinston.initialize(logName)
|
||||||
|
|
||||||
const logName = "libUdp";
|
|
||||||
const Logger = LibWinston.initialize(logName);
|
|
||||||
async function commitMessage(now, logDevice) {
|
async function commitMessage(now, logDevice) {
|
||||||
try {
|
try {
|
||||||
if (!logDevice.original_hex) {
|
if (!logDevice.original_hex) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const vhc = await VhcModels.getVhcByDeviceId(logDevice.device_id);
|
const vhc = await VhcModels.getVhcByDeviceId(logDevice.device_id)
|
||||||
const lastTrack = await GpsTracksModels.get2LastLocByDeviceId(logDevice.device_id);
|
const lastTrack = await GpsTracksModels.get2LastLocByDeviceId(logDevice.device_id)
|
||||||
|
|
||||||
if (["heartbeat", "alarm"].includes(logDevice.action)) {
|
if (["heartbeat", "alarm"].includes(logDevice.action)) {
|
||||||
if (logDevice.ignition == GpsTracksModels.STTS_IGNITION_HIGH) {
|
if (logDevice.ignition == GpsTracksModels.STTS_IGNITION_HIGH) {
|
||||||
if (logDevice.speed) {
|
if (logDevice.speed) {
|
||||||
logDevice.stts_engine = GpsTracksModels.STTS_EN_MOVING;
|
logDevice.stts_engine = GpsTracksModels.STTS_EN_MOVING
|
||||||
} else {
|
} else {
|
||||||
if (lastTrack.length > 0) {
|
if (lastTrack.length > 0) {
|
||||||
const checkLastHeartbeat = await GpsTracksModels.getLastHeartbeatToDeterminIdling(logDevice.device_id, lastTrack[0].crt, now);
|
const checkLastHeartbeat = await GpsTracksModels.getLastHeartbeatToDeterminIdling(
|
||||||
|
logDevice.device_id,
|
||||||
|
lastTrack[0].crt,
|
||||||
|
now
|
||||||
|
)
|
||||||
if (checkLastHeartbeat.length >= 3) {
|
if (checkLastHeartbeat.length >= 3) {
|
||||||
logDevice.stts_engine = GpsTracksModels.STTS_EN_IDLING;
|
logDevice.stts_engine = GpsTracksModels.STTS_EN_IDLING
|
||||||
} else {
|
} else {
|
||||||
logDevice.stts_engine = lastTrack[0].stts_engine;
|
logDevice.stts_engine = lastTrack[0].stts_engine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logDevice.stts_engine = GpsTracksModels.STTS_EN_STOPING;
|
logDevice.stts_engine = GpsTracksModels.STTS_EN_STOPING
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (["location"].includes(logDevice.action)) {
|
if (["location"].includes(logDevice.action)) {
|
||||||
const lastHeartbeatOrAlarm = await GpsTracksModels.get2LastHeartbeatOrAlarm(logDevice.device_id);
|
const lastHeartbeatOrAlarm = await GpsTracksModels.get2LastHeartbeatOrAlarm(logDevice.device_id)
|
||||||
if (lastHeartbeatOrAlarm.length > 0) {
|
if (lastHeartbeatOrAlarm.length > 0) {
|
||||||
logDevice.ignition = lastHeartbeatOrAlarm[0].ignition;
|
logDevice.ignition = lastHeartbeatOrAlarm[0].ignition
|
||||||
logDevice.stts_gps = lastHeartbeatOrAlarm[0].stts_gps;
|
logDevice.stts_gps = lastHeartbeatOrAlarm[0].stts_gps
|
||||||
logDevice.stts_gsm = lastHeartbeatOrAlarm[0].stts_gsm;
|
logDevice.stts_gsm = lastHeartbeatOrAlarm[0].stts_gsm
|
||||||
} else {
|
} else {
|
||||||
logDevice.ignition = lastHeartbeatOrAlarm[0].ignition;
|
logDevice.ignition = lastHeartbeatOrAlarm[0].ignition
|
||||||
logDevice.stts_gps = lastHeartbeatOrAlarm[0].stts_gps;
|
logDevice.stts_gps = lastHeartbeatOrAlarm[0].stts_gps
|
||||||
logDevice.stts_gsm = lastHeartbeatOrAlarm[0].stts_gsm;
|
logDevice.stts_gsm = lastHeartbeatOrAlarm[0].stts_gsm
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logDevice.ignition == GpsTracksModels.STTS_IGNITION_HIGH) {
|
if (logDevice.ignition == GpsTracksModels.STTS_IGNITION_HIGH) {
|
||||||
if (logDevice.speed) {
|
if (logDevice.speed) {
|
||||||
logDevice.stts_engine = GpsTracksModels.STTS_EN_MOVING;
|
logDevice.stts_engine = GpsTracksModels.STTS_EN_MOVING
|
||||||
} else {
|
} else {
|
||||||
if (lastTrack.length > 0) {
|
if (lastTrack.length > 0) {
|
||||||
const checkLastHeartbeat = await GpsTracksModels.getLastHeartbeatToDeterminIdling(logDevice.device_id, lastTrack[0].crt, now);
|
const checkLastHeartbeat = await GpsTracksModels.getLastHeartbeatToDeterminIdling(
|
||||||
|
logDevice.device_id,
|
||||||
|
lastTrack[0].crt,
|
||||||
|
now
|
||||||
|
)
|
||||||
if (checkLastHeartbeat.length >= 3) {
|
if (checkLastHeartbeat.length >= 3) {
|
||||||
logDevice.stts_engine = GpsTracksModels.STTS_EN_IDLING;
|
logDevice.stts_engine = GpsTracksModels.STTS_EN_IDLING
|
||||||
} else {
|
} else {
|
||||||
logDevice.stts_engine = lastTrack[0].stts_engine;
|
logDevice.stts_engine = lastTrack[0].stts_engine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logDevice.stts_engine = GpsTracksModels.STTS_EN_STOPING;
|
logDevice.stts_engine = GpsTracksModels.STTS_EN_STOPING
|
||||||
}
|
}
|
||||||
logDevice.stts_oil_electricity = lastHeartbeatOrAlarm[0]?.stts_oil_electricity ?? 0;
|
logDevice.stts_oil_electricity = lastHeartbeatOrAlarm[0]?.stts_oil_electricity ?? 0
|
||||||
logDevice.stts_alarm = lastHeartbeatOrAlarm[0].stts_alarm;
|
logDevice.stts_alarm = lastHeartbeatOrAlarm[0].stts_alarm
|
||||||
logDevice.stts_charge = lastHeartbeatOrAlarm[0].stts_charge;
|
logDevice.stts_charge = lastHeartbeatOrAlarm[0].stts_charge
|
||||||
logDevice.stts_acc = lastHeartbeatOrAlarm[0].stts_acc;
|
logDevice.stts_acc = lastHeartbeatOrAlarm[0].stts_acc
|
||||||
logDevice.stts_volt = lastHeartbeatOrAlarm[0].stts_volt;
|
logDevice.stts_volt = lastHeartbeatOrAlarm[0].stts_volt
|
||||||
logDevice.stts_switch = lastHeartbeatOrAlarm[0].stts_switch;
|
logDevice.stts_switch = lastHeartbeatOrAlarm[0].stts_switch
|
||||||
}
|
}
|
||||||
|
|
||||||
if (["heartbeat"].includes(logDevice.action)) {
|
if (["heartbeat"].includes(logDevice.action)) {
|
||||||
if (lastTrack.length > 0) {
|
if (lastTrack.length > 0) {
|
||||||
logDevice.latitude = lastTrack[0].latitude;
|
logDevice.latitude = lastTrack[0].latitude
|
||||||
logDevice.longitude = lastTrack[0].longitude;
|
logDevice.longitude = lastTrack[0].longitude
|
||||||
logDevice.speed = lastTrack[0].speed;
|
logDevice.speed = lastTrack[0].speed
|
||||||
logDevice.orientation = lastTrack[0].orientation;
|
logDevice.orientation = lastTrack[0].orientation
|
||||||
if (logDevice.latitude) {
|
if (logDevice.latitude) {
|
||||||
logDevice.stts_reverse_geo = GpsTracksModels.STTS_REVERSE_GEO_NOT;
|
logDevice.stts_reverse_geo = GpsTracksModels.STTS_REVERSE_GEO_NOT
|
||||||
}
|
}
|
||||||
|
|
||||||
logDevice.length_gps = lastTrack[0].length_gps;
|
logDevice.length_gps = lastTrack[0].length_gps
|
||||||
logDevice.pos_stlt_gps = lastTrack[0].pos_stlt_gps;
|
logDevice.pos_stlt_gps = lastTrack[0].pos_stlt_gps
|
||||||
logDevice.pos_type_gps = lastTrack[0].pos_type_gps;
|
logDevice.pos_type_gps = lastTrack[0].pos_type_gps
|
||||||
logDevice.is_pos_gps = lastTrack[0].is_pos_gps;
|
logDevice.is_pos_gps = lastTrack[0].is_pos_gps
|
||||||
|
|
||||||
logDevice.crt = now;
|
logDevice.crt = now
|
||||||
logDevice.crt_format = moment.unix(now).format("YYYY-MM-DD HH:mm:ss");
|
logDevice.crt_format = moment.unix(now).format("YYYY-MM-DD HH:mm:ss")
|
||||||
logDevice.crt_d = now;
|
logDevice.crt_d = now
|
||||||
logDevice.crt_d_format = moment.unix(now).format("YYYY-MM-DD HH:mm:ss");
|
logDevice.crt_d_format = moment.unix(now).format("YYYY-MM-DD HH:mm:ss")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= UPDATE SUM MILEAGE DARI t_vehicle ====================
|
// ================= UPDATE SUM MILEAGE DARI t_vehicle ====================
|
||||||
if (logDevice.latitude != null && logDevice.longitude != null && lastTrack.length > 0) {
|
if (logDevice.latitude != null && logDevice.longitude != null && lastTrack.length > 0) {
|
||||||
const distance = LibHelper.haversineGreatCircleDistance(lastTrack[0].latitude, lastTrack[0].longitude, logDevice.latitude, logDevice.longitude, LibHelper.EARTH_RADIUS_KM);
|
const distance = LibHelper.haversineGreatCircleDistance(
|
||||||
|
lastTrack[0].latitude,
|
||||||
|
lastTrack[0].longitude,
|
||||||
|
logDevice.latitude,
|
||||||
|
logDevice.longitude,
|
||||||
|
LibHelper.EARTH_RADIUS_KM
|
||||||
|
)
|
||||||
|
|
||||||
const distance_km = LibHelper.kmToKm(distance, 100000000);
|
const distance_km = LibHelper.kmToKm(distance, 100000000)
|
||||||
|
|
||||||
if (distance_km >= 3) {
|
if (distance_km >= 3) {
|
||||||
GpsTracksModels.bundleCreate2(logDevice, logDevice);
|
GpsTracksModels.bundleCreate2(logDevice, logDevice)
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
logDevice.pre_milleage = distance_km;
|
logDevice.pre_milleage = distance_km
|
||||||
|
|
||||||
// 1. Hitung sum_milleage dari log sebelumnya
|
// 1. Hitung sum_milleage dari log sebelumnya
|
||||||
const logBaseMileage = lastTrack[0]?.sum_milleage ?? 0;
|
const logBaseMileage = lastTrack[0]?.sum_milleage ?? 0
|
||||||
logDevice.sum_milleage = (logBaseMileage + logDevice.pre_milleage).toFixed(8);
|
logDevice.sum_milleage = (logBaseMileage + logDevice.pre_milleage).toFixed(8)
|
||||||
|
|
||||||
// 2. Hitung vhc_milleage dari master vehicle
|
// 2. Hitung vhc_milleage dari master vehicle
|
||||||
if (vhc.length > 0) {
|
if (vhc.length > 0) {
|
||||||
const vhcBaseMileage = vhc[0]?.sum_milleage ?? 0;
|
const vhcBaseMileage = vhc[0]?.sum_milleage ?? 0
|
||||||
logDevice.vhc_id = vhc[0]?.vid ?? 0;
|
logDevice.vhc_id = vhc[0]?.vid ?? 0
|
||||||
logDevice.vhc_milleage = (vhcBaseMileage + logDevice.pre_milleage).toFixed(8);
|
logDevice.vhc_milleage = (vhcBaseMileage + logDevice.pre_milleage).toFixed(8)
|
||||||
|
|
||||||
VhcModels.update(logDevice.vhc_id, {
|
VhcModels.update(logDevice.vhc_id, {
|
||||||
sum_milleage: logDevice.vhc_milleage,
|
sum_milleage: logDevice.vhc_milleage,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Simpan ke DB
|
// 4. Simpan ke DB
|
||||||
GpsTracksModels.bundleCreate2(logDevice, logDevice);
|
GpsTracksModels.bundleCreate2(logDevice, logDevice)
|
||||||
}
|
}
|
||||||
|
|
||||||
// V1
|
// V1
|
||||||
@ -178,16 +195,16 @@ async function commitMessage(now, logDevice) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if (logDevice.latitude != null && logDevice.longitude != null) {
|
if (logDevice.latitude != null && logDevice.longitude != null) {
|
||||||
const currTrack = await GpsTracksModels.bundleCreate2(logDevice, logDevice);
|
const currTrack = await GpsTracksModels.bundleCreate2(logDevice, logDevice)
|
||||||
|
|
||||||
const inCircle = await ZoneModels.getInCircle(logDevice.latitude, logDevice.longitude);
|
const inCircle = await ZoneModels.getInCircle(logDevice.latitude, logDevice.longitude)
|
||||||
const inShape = await ZoneModels.getInShape(logDevice.latitude, logDevice.longitude);
|
const inShape = await ZoneModels.getInShape(logDevice.latitude, logDevice.longitude)
|
||||||
const insideSpawnZone = [];
|
const insideSpawnZone = []
|
||||||
for (let zone of inCircle) {
|
for (let zone of inCircle) {
|
||||||
insideSpawnZone.push(zone);
|
insideSpawnZone.push(zone)
|
||||||
}
|
}
|
||||||
for (let zone of inShape) {
|
for (let zone of inShape) {
|
||||||
insideSpawnZone.push(zone);
|
insideSpawnZone.push(zone)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,12 +219,12 @@ async function commitMessage(now, logDevice) {
|
|||||||
leave_at_d: 0,
|
leave_at_d: 0,
|
||||||
order_by: "ORDER BY id DESC",
|
order_by: "ORDER BY id DESC",
|
||||||
limit: 1,
|
limit: 1,
|
||||||
});
|
})
|
||||||
|
|
||||||
if (lastSpawn.length > 0) {
|
if (lastSpawn.length > 0) {
|
||||||
let is_leave_zone = 1;
|
let is_leave_zone = 1
|
||||||
for (const insideZone of insideSpawnZone) {
|
for (const insideZone of insideSpawnZone) {
|
||||||
if (insideZone.zid === lastSpawn[0].zone_id) is_leave_zone = 0;
|
if (insideZone.zid === lastSpawn[0].zone_id) is_leave_zone = 0
|
||||||
}
|
}
|
||||||
if (is_leave_zone === 1 && lastSpawn[0].device_id == logDevice.device_id) {
|
if (is_leave_zone === 1 && lastSpawn[0].device_id == logDevice.device_id) {
|
||||||
GpsTracksModels.updt2SpawnZone(
|
GpsTracksModels.updt2SpawnZone(
|
||||||
@ -222,7 +239,7 @@ async function commitMessage(now, logDevice) {
|
|||||||
updt_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
updt_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
||||||
},
|
},
|
||||||
lastSpawn[0].id
|
lastSpawn[0].id
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let zone of insideSpawnZone) {
|
for (let zone of insideSpawnZone) {
|
||||||
@ -234,12 +251,16 @@ async function commitMessage(now, logDevice) {
|
|||||||
z_workflow_name: zone.workflow_type_name,
|
z_workflow_name: zone.workflow_type_name,
|
||||||
shiptocode: zone.shiptocode,
|
shiptocode: zone.shiptocode,
|
||||||
z_fulladdress: zone.fulladdress,
|
z_fulladdress: zone.fulladdress,
|
||||||
v_nopol: (vhc[0] ? vhc[0].nopol1 : 0 || "") + (vhc[0] ? vhc[0].nopol2 : 0 || "") + (vhc[0] ? vhc[0].nopol3 : 0 || ""),
|
v_nopol:
|
||||||
|
(vhc[0] ? vhc[0].nopol1 : 0 || "") +
|
||||||
|
(vhc[0] ? vhc[0].nopol2 : 0 || "") +
|
||||||
|
(vhc[0] ? vhc[0].nopol3 : 0 || ""),
|
||||||
da_name: vhc[0] ? vhc[0].da_name : 0 || "",
|
da_name: vhc[0] ? vhc[0].da_name : 0 || "",
|
||||||
da_phone: "+" + (vhc[0] ? vhc[0].da_phone_code : 0 || "") + (vhc[0] ? vhc[0].da_phone : 0 || ""),
|
da_phone:
|
||||||
};
|
"+" + (vhc[0] ? vhc[0].da_phone_code : 0 || "") + (vhc[0] ? vhc[0].da_phone : 0 || ""),
|
||||||
|
}
|
||||||
|
|
||||||
if (logDevice.device_id === "0865784052395871") console.log(1234567890);
|
if (logDevice.device_id === "0865784052395871") console.log(1234567890)
|
||||||
GpsTracksModels.create2SpawnZone({
|
GpsTracksModels.create2SpawnZone({
|
||||||
device_id: logDevice.device_id,
|
device_id: logDevice.device_id,
|
||||||
master_id: Number(currTrack.result.insertId),
|
master_id: Number(currTrack.result.insertId),
|
||||||
@ -255,20 +276,20 @@ async function commitMessage(now, logDevice) {
|
|||||||
source: GpsTracksModels.SOURCE_GPS_TRACKER,
|
source: GpsTracksModels.SOURCE_GPS_TRACKER,
|
||||||
crt: now,
|
crt: now,
|
||||||
crt_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
crt_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
||||||
});
|
})
|
||||||
if (logDevice.device_id === "0865784052395871") console.log("DISINI");
|
if (logDevice.device_id === "0865784052395871") console.log("DISINI")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GpsTracksModels.bundleCreate2(logDevice, logDevice);
|
GpsTracksModels.bundleCreate2(logDevice, logDevice)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const devices = [];
|
const devices = []
|
||||||
const netConn = require("./config/netConn");
|
const netConn = require("./config/netConn")
|
||||||
/**
|
/**
|
||||||
* uniquely identify a socket with Node.js
|
* uniquely identify a socket with Node.js
|
||||||
* https://stackoverflow.com/questions/6805432/how-to-uniquely-identify-a-socket-with-node-js
|
* https://stackoverflow.com/questions/6805432/how-to-uniquely-identify-a-socket-with-node-js
|
||||||
@ -278,13 +299,13 @@ net.createServer(
|
|||||||
allowHalfOpen: true,
|
allowHalfOpen: true,
|
||||||
},
|
},
|
||||||
function (c) {
|
function (c) {
|
||||||
c.id = nanoid();
|
c.id = nanoid()
|
||||||
|
|
||||||
c.pipe(c);
|
c.pipe(c)
|
||||||
|
|
||||||
c.on("data", async (buffer_req) => {
|
c.on("data", async (buffer_req) => {
|
||||||
const now = moment().unix();
|
const now = moment().unix()
|
||||||
const me = LibDevice.identifyProtocolFromBuffer(buffer_req);
|
const me = LibDevice.identifyProtocolFromBuffer(buffer_req)
|
||||||
|
|
||||||
const logDevice = {
|
const logDevice = {
|
||||||
original_hex: me.ori_string,
|
original_hex: me.ori_string,
|
||||||
@ -320,198 +341,240 @@ net.createServer(
|
|||||||
crt_d_format: null,
|
crt_d_format: null,
|
||||||
crt_s: now,
|
crt_s: now,
|
||||||
crt_s_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
crt_s_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
||||||
};
|
}
|
||||||
|
|
||||||
if (me.protocol_name == "gt06") {
|
if (me.protocol_name == "gt06") {
|
||||||
let dvc_id = devices[c.id];
|
let dvc_id = devices[c.id]
|
||||||
const act = LibDevice.gt06Action(me, dvc_id || null);
|
const act = LibDevice.gt06Action(me, dvc_id || null)
|
||||||
|
|
||||||
if (act.action_type == "login") {
|
if (act.action_type == "login") {
|
||||||
logDevice.action = act.action_type;
|
logDevice.action = act.action_type
|
||||||
logDevice.device_id = act.device_id;
|
logDevice.device_id = act.device_id
|
||||||
|
|
||||||
devices[c.id] = act.device_id;
|
devices[c.id] = act.device_id
|
||||||
netConn[act.device_id] = c;
|
netConn[act.device_id] = c
|
||||||
if (typeof act.buffer_resp != "undefined") {
|
if (typeof act.buffer_resp != "undefined") {
|
||||||
c.write(act.buffer_resp);
|
c.write(act.buffer_resp)
|
||||||
}
|
}
|
||||||
} else if (act.action_type == "location") {
|
} else if (act.action_type == "location") {
|
||||||
logDevice.action = act.action_type;
|
logDevice.action = act.action_type
|
||||||
logDevice.device_id = act.device_id;
|
logDevice.device_id = act.device_id
|
||||||
|
|
||||||
logDevice.latitude = act.gps_data.latitude || null;
|
logDevice.latitude = act.gps_data.latitude || null
|
||||||
logDevice.longitude = act.gps_data.longitude || null;
|
logDevice.longitude = act.gps_data.longitude || null
|
||||||
logDevice.speed = act.gps_data.speed;
|
logDevice.speed = act.gps_data.speed
|
||||||
logDevice.orientation = act.gps_data.orientation;
|
logDevice.orientation = act.gps_data.orientation
|
||||||
if (logDevice.latitude) {
|
if (logDevice.latitude) {
|
||||||
logDevice.stts_reverse_geo = GpsTracksModels.STTS_REVERSE_GEO_NOT;
|
logDevice.stts_reverse_geo = GpsTracksModels.STTS_REVERSE_GEO_NOT
|
||||||
}
|
}
|
||||||
|
|
||||||
logDevice.length_gps = act.gps_data.quantity_pos_satellites_c;
|
logDevice.length_gps = act.gps_data.quantity_pos_satellites_c
|
||||||
logDevice.pos_stlt_gps = act.gps_data.quantity_pos_satellites_b;
|
logDevice.pos_stlt_gps = act.gps_data.quantity_pos_satellites_b
|
||||||
logDevice.pos_type_gps = Number(act.gps_data.realtime_dif_gps) === 0 ? GpsTracksModels.STTS_POS_TYPE_GPS_RLTM : GpsTracksModels.STTS_POS_TYPE_GPS_DIFF;
|
logDevice.pos_type_gps =
|
||||||
logDevice.is_pos_gps = Number(act.gps_data.positioning_gps) ? GpsTracksModels.STTS_IS_POS_GPS_HAS : GpsTracksModels.STTS_IS_POS_GPS_NOT;
|
Number(act.gps_data.realtime_dif_gps) === 0
|
||||||
|
? GpsTracksModels.STTS_POS_TYPE_GPS_RLTM
|
||||||
|
: GpsTracksModels.STTS_POS_TYPE_GPS_DIFF
|
||||||
|
logDevice.is_pos_gps = Number(act.gps_data.positioning_gps)
|
||||||
|
? GpsTracksModels.STTS_IS_POS_GPS_HAS
|
||||||
|
: GpsTracksModels.STTS_IS_POS_GPS_NOT
|
||||||
|
|
||||||
// logDevice.crt = moment(act.gps_data.date).unix();
|
// logDevice.crt = moment(act.gps_data.date).unix();
|
||||||
// logDevice.crt_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss");
|
// logDevice.crt_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss");
|
||||||
// logDevice.crt_d = moment(act.gps_data.date).unix();
|
// logDevice.crt_d = moment(act.gps_data.date).unix();
|
||||||
// logDevice.crt_d_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss");
|
// logDevice.crt_d_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss");
|
||||||
|
|
||||||
let deviceTime = moment(act.gps_data.date).unix();
|
let deviceTime = moment(act.gps_data.date).unix()
|
||||||
let now = moment().unix();
|
let now = moment().unix()
|
||||||
let diff = Math.abs(deviceTime - now);
|
let diff = Math.abs(deviceTime - now)
|
||||||
|
|
||||||
// Jika beda waktu terlalu besar (> 300 detik atau 5 menit), pakai waktu server
|
// Jika beda waktu terlalu besar (> 300 detik atau 5 menit), pakai waktu server
|
||||||
if (diff > 300) {
|
if (diff > 300) {
|
||||||
console.warn(`[WAKTU TIDAK VALID] Device ${logDevice.device_id} mengirim waktu tidak sinkron, pakai waktu server.`);
|
console.warn(
|
||||||
deviceTime = now;
|
`[WAKTU TIDAK VALID] Device ${logDevice.device_id} mengirim waktu tidak sinkron, pakai waktu server.`
|
||||||
|
)
|
||||||
|
deviceTime = now
|
||||||
}
|
}
|
||||||
|
|
||||||
logDevice.crt = deviceTime;
|
logDevice.crt = deviceTime
|
||||||
logDevice.crt_format = moment.unix(deviceTime).format("YYYY-MM-DD HH:mm:ss");
|
logDevice.crt_format = moment.unix(deviceTime).format("YYYY-MM-DD HH:mm:ss")
|
||||||
logDevice.crt_d = deviceTime;
|
logDevice.crt_d = deviceTime
|
||||||
logDevice.crt_d_format = moment.unix(deviceTime).format("YYYY-MM-DD HH:mm:ss");
|
logDevice.crt_d_format = moment.unix(deviceTime).format("YYYY-MM-DD HH:mm:ss")
|
||||||
logDevice.crt_device_raw = moment(act.gps_data.date).unix(); // waktu asli dari device (sebelum validasi)
|
logDevice.crt_device_raw = moment(act.gps_data.date).unix() // waktu asli dari device (sebelum validasi)
|
||||||
} else if (act.action_type == "heartbeat") {
|
} else if (act.action_type == "heartbeat") {
|
||||||
logDevice.action = act.action_type;
|
logDevice.action = act.action_type
|
||||||
logDevice.device_id = act.device_id;
|
logDevice.device_id = act.device_id
|
||||||
|
|
||||||
logDevice.ignition = Number(act.stts_data.terminal_info.acc) ? GpsTracksModels.STTS_IGNITION_HIGH : GpsTracksModels.STTS_IGNITION_LOW;
|
logDevice.ignition = Number(act.stts_data.terminal_info.acc)
|
||||||
logDevice.stts_gps = act.stts_data.terminal_info.gps_tracking ? GpsTracksModels.STTS_GPS_ON : GpsTracksModels.STTS_GPS_OFF;
|
? GpsTracksModels.STTS_IGNITION_HIGH
|
||||||
logDevice.stts_gsm = Number(act.stts_data.gsm_signal_strength) + 1;
|
: GpsTracksModels.STTS_IGNITION_LOW
|
||||||
|
logDevice.stts_gps = act.stts_data.terminal_info.gps_tracking
|
||||||
|
? GpsTracksModels.STTS_GPS_ON
|
||||||
|
: GpsTracksModels.STTS_GPS_OFF
|
||||||
|
logDevice.stts_gsm = Number(act.stts_data.gsm_signal_strength) + 1
|
||||||
|
|
||||||
logDevice.stts_oil_electricity = Number(act.stts_data.terminal_info.oil_electricity) === 0 ? GpsTracksModels.STTS_OIL_ELECTRIC_ON : GpsTracksModels.STTS_OIL_ELECTRIC_OFF;
|
logDevice.stts_oil_electricity =
|
||||||
|
Number(act.stts_data.terminal_info.oil_electricity) === 0
|
||||||
|
? GpsTracksModels.STTS_OIL_ELECTRIC_ON
|
||||||
|
: GpsTracksModels.STTS_OIL_ELECTRIC_OFF
|
||||||
|
|
||||||
let stts_alarm = Number(act.stts_data.terminal_info.stts);
|
let stts_alarm = Number(act.stts_data.terminal_info.stts)
|
||||||
if (stts_alarm == 0) {
|
if (stts_alarm == 0) {
|
||||||
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_NORMAL;
|
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_NORMAL
|
||||||
} else if (stts_alarm == 1) {
|
} else if (stts_alarm == 1) {
|
||||||
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_SHOCK;
|
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_SHOCK
|
||||||
} else if (stts_alarm == 2) {
|
} else if (stts_alarm == 2) {
|
||||||
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_POWER_CUT;
|
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_POWER_CUT
|
||||||
} else if (stts_alarm == 3) {
|
} else if (stts_alarm == 3) {
|
||||||
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_LOW_BATTERY;
|
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_LOW_BATTERY
|
||||||
} else if (stts_alarm == 4) {
|
} else if (stts_alarm == 4) {
|
||||||
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_SOS;
|
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_SOS
|
||||||
}
|
}
|
||||||
|
|
||||||
logDevice.stts_charge = Number(act.stts_data.terminal_info.charge) ? GpsTracksModels.STTS_CHARGE_ON : GpsTracksModels.STTS_CHARGE_OFF;
|
logDevice.stts_charge = Number(act.stts_data.terminal_info.charge)
|
||||||
logDevice.stts_acc = Number(act.stts_data.terminal_info.acc) ? GpsTracksModels.STTS_ACC_HIGH : GpsTracksModels.STTS_ACC_LOW;
|
? GpsTracksModels.STTS_CHARGE_ON
|
||||||
logDevice.stts_switch = Number(act.stts_data.terminal_info.is_active) ? GpsTracksModels.STTS_SWITCH_ON : GpsTracksModels.STTS_SWITCH_OFF;
|
: GpsTracksModels.STTS_CHARGE_OFF
|
||||||
logDevice.stts_volt = Number(act.stts_data.voltage_level) + 1;
|
logDevice.stts_acc = Number(act.stts_data.terminal_info.acc)
|
||||||
|
? GpsTracksModels.STTS_ACC_HIGH
|
||||||
|
: GpsTracksModels.STTS_ACC_LOW
|
||||||
|
logDevice.stts_switch = Number(act.stts_data.terminal_info.is_active)
|
||||||
|
? GpsTracksModels.STTS_SWITCH_ON
|
||||||
|
: GpsTracksModels.STTS_SWITCH_OFF
|
||||||
|
logDevice.stts_volt = Number(act.stts_data.voltage_level) + 1
|
||||||
|
|
||||||
if (typeof act.buffer_resp != "undefined") {
|
if (typeof act.buffer_resp != "undefined") {
|
||||||
c.write(act.buffer_resp);
|
c.write(act.buffer_resp)
|
||||||
}
|
}
|
||||||
} else if (act.action_type == "alarm") {
|
} else if (act.action_type == "alarm") {
|
||||||
logDevice.action = act.action_type;
|
logDevice.action = act.action_type
|
||||||
logDevice.device_id = act.device_id;
|
logDevice.device_id = act.device_id
|
||||||
|
|
||||||
logDevice.latitude = act.gps_data.latitude || null;
|
logDevice.latitude = act.gps_data.latitude || null
|
||||||
logDevice.longitude = act.gps_data.longitude || null;
|
logDevice.longitude = act.gps_data.longitude || null
|
||||||
logDevice.speed = act.gps_data.speed;
|
logDevice.speed = act.gps_data.speed
|
||||||
logDevice.orientation = act.gps_data.orientation;
|
logDevice.orientation = act.gps_data.orientation
|
||||||
if (logDevice.latitude) {
|
if (logDevice.latitude) {
|
||||||
logDevice.stts_reverse_geo = GpsTracksModels.STTS_REVERSE_GEO_NOT;
|
logDevice.stts_reverse_geo = GpsTracksModels.STTS_REVERSE_GEO_NOT
|
||||||
}
|
}
|
||||||
|
|
||||||
logDevice.length_gps = act.gps_data.quantity_pos_satellites_c;
|
logDevice.length_gps = act.gps_data.quantity_pos_satellites_c
|
||||||
logDevice.pos_stlt_gps = act.gps_data.quantity_pos_satellites_b;
|
logDevice.pos_stlt_gps = act.gps_data.quantity_pos_satellites_b
|
||||||
logDevice.pos_type_gps = Number(act.gps_data.realtime_dif_gps) === 0 ? GpsTracksModels.STTS_POS_TYPE_GPS_RLTM : GpsTracksModels.STTS_POS_TYPE_GPS_DIFF;
|
logDevice.pos_type_gps =
|
||||||
logDevice.is_pos_gps = Number(act.gps_data.positioning_gps) ? GpsTracksModels.STTS_IS_POS_GPS_HAS : GpsTracksModels.STTS_IS_POS_GPS_NOT;
|
Number(act.gps_data.realtime_dif_gps) === 0
|
||||||
|
? GpsTracksModels.STTS_POS_TYPE_GPS_RLTM
|
||||||
|
: GpsTracksModels.STTS_POS_TYPE_GPS_DIFF
|
||||||
|
logDevice.is_pos_gps = Number(act.gps_data.positioning_gps)
|
||||||
|
? GpsTracksModels.STTS_IS_POS_GPS_HAS
|
||||||
|
: GpsTracksModels.STTS_IS_POS_GPS_NOT
|
||||||
|
|
||||||
logDevice.ignition = Number(act.stts_data.terminal_info.acc) ? GpsTracksModels.STTS_IGNITION_HIGH : GpsTracksModels.STTS_IGNITION_LOW;
|
logDevice.ignition = Number(act.stts_data.terminal_info.acc)
|
||||||
logDevice.stts_gps = act.stts_data.terminal_info.gps_tracking ? GpsTracksModels.STTS_GPS_ON : GpsTracksModels.STTS_GPS_OFF;
|
? GpsTracksModels.STTS_IGNITION_HIGH
|
||||||
logDevice.stts_gsm = Number(act.stts_data.gsm_signal_strength) + 1;
|
: GpsTracksModels.STTS_IGNITION_LOW
|
||||||
|
logDevice.stts_gps = act.stts_data.terminal_info.gps_tracking
|
||||||
|
? GpsTracksModels.STTS_GPS_ON
|
||||||
|
: GpsTracksModels.STTS_GPS_OFF
|
||||||
|
logDevice.stts_gsm = Number(act.stts_data.gsm_signal_strength) + 1
|
||||||
|
|
||||||
logDevice.stts_oil_electricity = Number(act.stts_data.terminal_info.oil_electricity) === 0 ? GpsTracksModels.STTS_OIL_ELECTRIC_ON : GpsTracksModels.STTS_OIL_ELECTRIC_OFF;
|
logDevice.stts_oil_electricity =
|
||||||
|
Number(act.stts_data.terminal_info.oil_electricity) === 0
|
||||||
|
? GpsTracksModels.STTS_OIL_ELECTRIC_ON
|
||||||
|
: GpsTracksModels.STTS_OIL_ELECTRIC_OFF
|
||||||
|
|
||||||
let stts_alarm = Number(act.stts_data.terminal_info.stts);
|
let stts_alarm = Number(act.stts_data.terminal_info.stts)
|
||||||
if (stts_alarm == 0) {
|
if (stts_alarm == 0) {
|
||||||
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_NORMAL;
|
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_NORMAL
|
||||||
} else if (stts_alarm == 1) {
|
} else if (stts_alarm == 1) {
|
||||||
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_SHOCK;
|
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_SHOCK
|
||||||
} else if (stts_alarm == 2) {
|
} else if (stts_alarm == 2) {
|
||||||
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_POWER_CUT;
|
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_POWER_CUT
|
||||||
} else if (stts_alarm == 3) {
|
} else if (stts_alarm == 3) {
|
||||||
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_LOW_BATTERY;
|
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_LOW_BATTERY
|
||||||
} else if (stts_alarm == 4) {
|
} else if (stts_alarm == 4) {
|
||||||
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_SOS;
|
logDevice.stts_alarm = GpsTracksModels.STTS_ALARM_SOS
|
||||||
}
|
}
|
||||||
|
|
||||||
logDevice.stts_charge = Number(act.stts_data.terminal_info.charge) ? GpsTracksModels.STTS_CHARGE_ON : GpsTracksModels.STTS_CHARGE_OFF;
|
logDevice.stts_charge = Number(act.stts_data.terminal_info.charge)
|
||||||
logDevice.stts_acc = Number(act.stts_data.terminal_info.acc) ? GpsTracksModels.STTS_ACC_HIGH : GpsTracksModels.STTS_ACC_LOW;
|
? GpsTracksModels.STTS_CHARGE_ON
|
||||||
logDevice.stts_switch = Number(act.stts_data.terminal_info.is_active) ? GpsTracksModels.STTS_SWITCH_ON : GpsTracksModels.STTS_SWITCH_OFF;
|
: GpsTracksModels.STTS_CHARGE_OFF
|
||||||
logDevice.stts_volt = Number(act.stts_data.voltage_level) + 1;
|
logDevice.stts_acc = Number(act.stts_data.terminal_info.acc)
|
||||||
|
? GpsTracksModels.STTS_ACC_HIGH
|
||||||
|
: GpsTracksModels.STTS_ACC_LOW
|
||||||
|
logDevice.stts_switch = Number(act.stts_data.terminal_info.is_active)
|
||||||
|
? GpsTracksModels.STTS_SWITCH_ON
|
||||||
|
: GpsTracksModels.STTS_SWITCH_OFF
|
||||||
|
logDevice.stts_volt = Number(act.stts_data.voltage_level) + 1
|
||||||
|
|
||||||
logDevice.crt = moment(act.gps_data.date).unix();
|
logDevice.crt = moment(act.gps_data.date).unix()
|
||||||
logDevice.crt_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss");
|
logDevice.crt_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss")
|
||||||
logDevice.crt_d = moment(act.gps_data.date).unix();
|
logDevice.crt_d = moment(act.gps_data.date).unix()
|
||||||
logDevice.crt_d_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss");
|
logDevice.crt_d_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
|
||||||
if (typeof act.buffer_resp != "undefined") {
|
if (typeof act.buffer_resp != "undefined") {
|
||||||
c.write(act.buffer_resp);
|
c.write(act.buffer_resp)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logDevice.action = act.action_type;
|
logDevice.action = act.action_type
|
||||||
logDevice.device_id = act.device_id;
|
logDevice.device_id = act.device_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commitMessage(now, logDevice);
|
commitMessage(now, logDevice)
|
||||||
});
|
})
|
||||||
c.on("end", () => {});
|
c.on("end", () => {})
|
||||||
c.on("close", () => {});
|
c.on("close", () => {})
|
||||||
|
|
||||||
c.on("drain", (a) => {
|
c.on("drain", (a) => {
|
||||||
console.log("client drain", a);
|
console.log("client drain", a)
|
||||||
});
|
})
|
||||||
c.on("error", (a) => {
|
c.on("error", (a) => {
|
||||||
console.error("client error", a);
|
console.error("client error", a)
|
||||||
});
|
})
|
||||||
c.on("lookup", (a) => {
|
c.on("lookup", (a) => {
|
||||||
console.log("client lookup", a);
|
console.log("client lookup", a)
|
||||||
});
|
})
|
||||||
c.on("ready", (a) => {
|
c.on("ready", (a) => {
|
||||||
console.log("client ready", a);
|
console.log("client ready", a)
|
||||||
});
|
})
|
||||||
c.on("timeout", (a) => {
|
c.on("timeout", (a) => {
|
||||||
console.log("client timeout", a);
|
console.log("client timeout", a)
|
||||||
});
|
})
|
||||||
|
|
||||||
c.pipe(c);
|
c.pipe(c)
|
||||||
}
|
}
|
||||||
).listen(process.env.PORT, () => {
|
).listen(process.env.PORT, () => {
|
||||||
console.log("Server gps tracker running at port " + process.env.PORT);
|
console.log("Server gps tracker running at port " + process.env.PORT)
|
||||||
});
|
})
|
||||||
|
|
||||||
app.use(morgan("combined"));
|
// ========= server express =========
|
||||||
app.use(express.json({ limit: "10mb" }));
|
app.use(morgan("combined"))
|
||||||
app.use(express.urlencoded({ extended: true, limit: "10mb" }));
|
app.use(express.json({ limit: "10mb" }))
|
||||||
|
app.use(express.urlencoded({ extended: true, limit: "10mb" }))
|
||||||
app.use(async function (req, res, next) {
|
app.use(async function (req, res, next) {
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
res.header("Access-Control-Allow-Origin", "*")
|
||||||
res.header("Access-Control-Allow-Methods", "OPTIONS,GET,HEAD,PUT,PATCH,POST,DELETE");
|
res.header("Access-Control-Allow-Methods", "OPTIONS,GET,HEAD,PUT,PATCH,POST,DELETE")
|
||||||
res.header("Access-Control-Allow-Headers", "Accept, Authorization, Content-Type, X-Requested-With, Range, x-api-key, x-forwarded-for");
|
res.header(
|
||||||
next();
|
"Access-Control-Allow-Headers",
|
||||||
});
|
"Accept, Authorization, Content-Type, X-Requested-With, Range, x-api-key, x-forwarded-for"
|
||||||
|
)
|
||||||
|
next()
|
||||||
|
})
|
||||||
|
|
||||||
routes.use(app);
|
listen.use(app)
|
||||||
app.listen(process.env.PORT_EXPRESS, () => {
|
app.listen(process.env.PORT_EXPRESS, () => {
|
||||||
console.log("Express server running at port " + process.env.PORT_EXPRESS);
|
console.log("Express server running at port " + process.env.PORT_EXPRESS)
|
||||||
});
|
})
|
||||||
|
|
||||||
const udp = dgram.createSocket("udp4");
|
const udp = dgram.createSocket("udp4")
|
||||||
|
|
||||||
const devices1 = [];
|
const devices1 = []
|
||||||
udp.on("message", (msg, rinfo) => {
|
udp.on("message", (msg, rinfo) => {
|
||||||
const buffer_req = Buffer.from(msg, "utf8");
|
const buffer_req = Buffer.from(msg, "utf8")
|
||||||
console.log("20203", buffer_req);
|
console.log("20203", buffer_req)
|
||||||
console.log("20203", rinfo);
|
console.log("20203", rinfo)
|
||||||
Logger.log("info", buffer_req.toString("hex"));
|
Logger.log("info", buffer_req.toString("hex"))
|
||||||
|
|
||||||
const now = moment().unix();
|
const now = moment().unix()
|
||||||
const me = LibDevice.identifyProtocolFromBuffer(buffer_req, { isEelinkCustom: 1 });
|
const me = LibDevice.identifyProtocolFromBuffer(buffer_req, { isEelinkCustom: 1 })
|
||||||
console.log("port 20203 ", me);
|
console.log("port 20203 ", me)
|
||||||
|
|
||||||
const logDevice = {
|
const logDevice = {
|
||||||
original_hex: me.ori_buffer,
|
original_hex: me.ori_buffer,
|
||||||
@ -545,38 +608,38 @@ udp.on("message", (msg, rinfo) => {
|
|||||||
crt_d_format: null,
|
crt_d_format: null,
|
||||||
crt_s: now,
|
crt_s: now,
|
||||||
crt_s_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
crt_s_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
||||||
};
|
}
|
||||||
|
|
||||||
if (me.protocol_name === "eelinkCustom") {
|
if (me.protocol_name === "eelinkCustom") {
|
||||||
let dvc_id = devices1[`${rinfo.address}:${rinfo.port}`];
|
let dvc_id = devices1[`${rinfo.address}:${rinfo.port}`]
|
||||||
const act = LibDevice.eelinkCustomAction(me, dvc_id || null);
|
const act = LibDevice.eelinkCustomAction(me, dvc_id || null)
|
||||||
console.log("act 20203", act);
|
console.log("act 20203", act)
|
||||||
|
|
||||||
if (act.action_type == "exist_data") {
|
if (act.action_type == "exist_data") {
|
||||||
logDevice.action = act.action_type;
|
logDevice.action = act.action_type
|
||||||
logDevice.device_id = act.device_id;
|
logDevice.device_id = act.device_id
|
||||||
|
|
||||||
devices1[`${rinfo.address}:${rinfo.port}`] = act.device_id;
|
devices1[`${rinfo.address}:${rinfo.port}`] = act.device_id
|
||||||
if (typeof act.buffer_resp != "undefined") {
|
if (typeof act.buffer_resp != "undefined") {
|
||||||
udp.send(act.buffer_resp, 0, act.buffer_resp.length, rinfo.port, rinfo.address, function (err, bytes) {
|
udp.send(act.buffer_resp, 0, act.buffer_resp.length, rinfo.port, rinfo.address, function (err, bytes) {
|
||||||
if (err) throw err;
|
if (err) throw err
|
||||||
console.log("UDP message sent to " + rinfo.address + ":" + rinfo.port);
|
console.log("UDP message sent to " + rinfo.address + ":" + rinfo.port)
|
||||||
console.log("20203", bytes);
|
console.log("20203", bytes)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
udp.on("error", (err) => {
|
udp.on("error", (err) => {
|
||||||
console.log(`udp error:\n${err.stack}`);
|
console.log(`udp error:\n${err.stack}`)
|
||||||
udp.close();
|
udp.close()
|
||||||
});
|
})
|
||||||
udp.on("close", function () {
|
udp.on("close", function () {
|
||||||
console.log("udp socket is closed !");
|
console.log("udp socket is closed !")
|
||||||
});
|
})
|
||||||
udp.on("listening", () => {
|
udp.on("listening", () => {
|
||||||
const address = udp.address();
|
const address = udp.address()
|
||||||
console.log(`udp listening ${address.address}:${address.port}`);
|
console.log(`udp listening ${address.address}:${address.port}`)
|
||||||
});
|
})
|
||||||
|
|
||||||
udp.bind(process.env.PORT_UDP);
|
udp.bind(process.env.PORT_UDP)
|
||||||
|
|||||||
@ -1,113 +1,121 @@
|
|||||||
const moment = require("moment");
|
const moment = require("moment")
|
||||||
const Validator = require("validatorjs");
|
const Validator = require("validatorjs")
|
||||||
const Helper = require("../library/LibHelper");
|
const Helper = require("../library/LibHelper")
|
||||||
const response = require("../config/response");
|
const response = require("../config/response")
|
||||||
const LibMail = require("../library/LibMail");
|
const LibMail = require("../library/LibMail")
|
||||||
const LibDevice = require("../library/LibDevice");
|
const LibDevice = require("../library/LibDevice")
|
||||||
const DanaModels = require("../models/DanaModels");
|
const DanaModels = require("../models/DanaModels")
|
||||||
const GpsTracksModels = require("../models/GpsTracksModels");
|
const GpsTracksModels = require("../models/GpsTracksModels")
|
||||||
const { nanoid } = require("nanoid");
|
const { nanoid } = require("nanoid")
|
||||||
const VhcModels = require("../models/VhcModels");
|
const VhcModels = require("../models/VhcModels")
|
||||||
const ZoneModels = require("../models/ZoneModels");
|
const ZoneModels = require("../models/ZoneModels")
|
||||||
const LibHelper = require("../library/LibHelper");
|
const LibHelper = require("../library/LibHelper")
|
||||||
|
|
||||||
Validator.useLang("en");
|
Validator.useLang("en")
|
||||||
|
|
||||||
const devices = [];
|
const devices = []
|
||||||
|
|
||||||
async function commitMessage(now, logDevice) {
|
async function commitMessage(now, logDevice) {
|
||||||
try {
|
try {
|
||||||
if (!logDevice.original_hex) {
|
if (!logDevice.original_hex) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const vhc = await VhcModels.getVhcByDeviceId(logDevice.device_id);
|
const vhc = await VhcModels.getVhcByDeviceId(logDevice.device_id)
|
||||||
const lastTrack = await GpsTracksModels.get2LastLocByDeviceId(logDevice.device_id);
|
const lastTrack = await GpsTracksModels.get2LastLocByDeviceId(logDevice.device_id)
|
||||||
if (["heartbeat", "alarm"].includes(logDevice.action)) {
|
if (["heartbeat", "alarm"].includes(logDevice.action)) {
|
||||||
if (logDevice.ignition == GpsTracksModels.STTS_IGNITION_HIGH) {
|
if (logDevice.ignition == GpsTracksModels.STTS_IGNITION_HIGH) {
|
||||||
if (logDevice.speed) {
|
if (logDevice.speed) {
|
||||||
logDevice.stts_engine = GpsTracksModels.STTS_EN_MOVING;
|
logDevice.stts_engine = GpsTracksModels.STTS_EN_MOVING
|
||||||
} else {
|
} else {
|
||||||
if (lastTrack.length > 0) {
|
if (lastTrack.length > 0) {
|
||||||
const checkLastHeartbeat = await GpsTracksModels.getLastHeartbeatToDeterminIdling(logDevice.device_id, lastTrack[0].crt, now);
|
const checkLastHeartbeat = await GpsTracksModels.getLastHeartbeatToDeterminIdling(
|
||||||
|
logDevice.device_id,
|
||||||
|
lastTrack[0].crt,
|
||||||
|
now
|
||||||
|
)
|
||||||
if (checkLastHeartbeat.length >= 3) {
|
if (checkLastHeartbeat.length >= 3) {
|
||||||
logDevice.stts_engine = GpsTracksModels.STTS_EN_IDLING;
|
logDevice.stts_engine = GpsTracksModels.STTS_EN_IDLING
|
||||||
} else {
|
} else {
|
||||||
logDevice.stts_engine = lastTrack[0].stts_engine;
|
logDevice.stts_engine = lastTrack[0].stts_engine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logDevice.stts_engine = GpsTracksModels.STTS_EN_STOPING;
|
logDevice.stts_engine = GpsTracksModels.STTS_EN_STOPING
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (["location"].includes(logDevice.action)) {
|
if (["location"].includes(logDevice.action)) {
|
||||||
console.log("logDevice:", logDevice);
|
// console.log("logDevice:", logDevice)
|
||||||
|
|
||||||
const lastHeartbeatOrAlarm = await GpsTracksModels.get2LastHeartbeatOrAlarm(logDevice.device_id);
|
const lastHeartbeatOrAlarm = await GpsTracksModels.get2LastHeartbeatOrAlarm(logDevice.device_id)
|
||||||
if (lastHeartbeatOrAlarm.length > 0) {
|
if (lastHeartbeatOrAlarm.length > 0) {
|
||||||
logDevice.ignition = lastHeartbeatOrAlarm[0].ignition;
|
logDevice.ignition = lastHeartbeatOrAlarm[0].ignition
|
||||||
logDevice.stts_gps = lastHeartbeatOrAlarm[0].stts_gps;
|
logDevice.stts_gps = lastHeartbeatOrAlarm[0].stts_gps
|
||||||
logDevice.stts_gsm = lastHeartbeatOrAlarm[0].stts_gsm;
|
logDevice.stts_gsm = lastHeartbeatOrAlarm[0].stts_gsm
|
||||||
logDevice.stts_oil_electricity = lastHeartbeatOrAlarm[0].stts_oil_electricity;
|
logDevice.stts_oil_electricity = lastHeartbeatOrAlarm[0].stts_oil_electricity
|
||||||
logDevice.stts_alarm = lastHeartbeatOrAlarm[0].stts_alarm;
|
logDevice.stts_alarm = lastHeartbeatOrAlarm[0].stts_alarm
|
||||||
logDevice.stts_charge = lastHeartbeatOrAlarm[0].stts_charge;
|
logDevice.stts_charge = lastHeartbeatOrAlarm[0].stts_charge
|
||||||
logDevice.stts_acc = lastHeartbeatOrAlarm[0].stts_acc;
|
logDevice.stts_acc = lastHeartbeatOrAlarm[0].stts_acc
|
||||||
logDevice.stts_volt = lastHeartbeatOrAlarm[0].stts_volt;
|
logDevice.stts_volt = lastHeartbeatOrAlarm[0].stts_volt
|
||||||
logDevice.stts_switch = lastHeartbeatOrAlarm[0].stts_switch;
|
logDevice.stts_switch = lastHeartbeatOrAlarm[0].stts_switch
|
||||||
} else {
|
} else {
|
||||||
logDevice.ignition = null;
|
logDevice.ignition = logDevice.ignition || 0
|
||||||
logDevice.stts_gps = null;
|
logDevice.stts_gps = logDevice.stts_gps || 0
|
||||||
logDevice.stts_gsm = null;
|
logDevice.stts_gsm = logDevice.stts_gsm || 0
|
||||||
logDevice.stts_oil_electricity = null;
|
logDevice.stts_oil_electricity = logDevice.stts_oil_electricity || 0
|
||||||
logDevice.stts_alarm = null;
|
logDevice.stts_alarm = logDevice.stts_alarm || 0
|
||||||
logDevice.stts_charge = null;
|
logDevice.stts_charge = logDevice.stts_charge || 0
|
||||||
logDevice.stts_acc = null;
|
logDevice.stts_acc = logDevice.stts_acc || 0
|
||||||
logDevice.stts_volt = null;
|
logDevice.stts_volt = logDevice.stts_volt || 0
|
||||||
logDevice.stts_switch = null;
|
logDevice.stts_switch = logDevice.stts_switch || 0
|
||||||
}
|
}
|
||||||
// set engine stts moving,idling,stopped
|
// set engine stts moving,idling,stopped
|
||||||
if (logDevice.ignition == GpsTracksModels.STTS_IGNITION_HIGH) {
|
if (logDevice.ignition == GpsTracksModels.STTS_IGNITION_HIGH) {
|
||||||
if (logDevice.speed) {
|
if (logDevice.speed) {
|
||||||
logDevice.stts_engine = GpsTracksModels.STTS_EN_MOVING;
|
logDevice.stts_engine = GpsTracksModels.STTS_EN_MOVING
|
||||||
} else {
|
} else {
|
||||||
if (lastTrack.length > 0) {
|
if (lastTrack.length > 0) {
|
||||||
const checkLastHeartbeat = await GpsTracksModels.getLastHeartbeatToDeterminIdling(logDevice.device_id, lastTrack[0].crt, now);
|
const checkLastHeartbeat = await GpsTracksModels.getLastHeartbeatToDeterminIdling(
|
||||||
|
logDevice.device_id,
|
||||||
|
lastTrack[0].crt,
|
||||||
|
now
|
||||||
|
)
|
||||||
if (checkLastHeartbeat.length >= 3) {
|
if (checkLastHeartbeat.length >= 3) {
|
||||||
logDevice.stts_engine = GpsTracksModels.STTS_EN_IDLING;
|
logDevice.stts_engine = GpsTracksModels.STTS_EN_IDLING
|
||||||
} else {
|
} else {
|
||||||
logDevice.stts_engine = lastTrack[0].stts_engine;
|
logDevice.stts_engine = lastTrack[0].stts_engine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// get stts_alarm, stts_charge, stts_acc, stts_volt, stts_switch
|
// get stts_alarm, stts_charge, stts_acc, stts_volt, stts_switch
|
||||||
} else {
|
} else {
|
||||||
logDevice.stts_engine = GpsTracksModels.STTS_EN_STOPING;
|
logDevice.stts_engine = GpsTracksModels.STTS_EN_STOPING
|
||||||
}
|
}
|
||||||
logDevice.stts_oil_electricity = lastHeartbeatOrAlarm[0].stts_oil_electricity;
|
logDevice.stts_oil_electricity = lastHeartbeatOrAlarm[0]?.stts_oil_electricity || 0
|
||||||
logDevice.stts_alarm = lastHeartbeatOrAlarm[0].stts_alarm;
|
logDevice.stts_alarm = lastHeartbeatOrAlarm[0]?.stts_alarm || 0
|
||||||
logDevice.stts_charge = lastHeartbeatOrAlarm[0].stts_charge;
|
logDevice.stts_charge = lastHeartbeatOrAlarm[0]?.stts_charge || 0
|
||||||
logDevice.stts_acc = lastHeartbeatOrAlarm[0].stts_acc;
|
logDevice.stts_acc = lastHeartbeatOrAlarm[0]?.stts_acc || 0
|
||||||
logDevice.stts_volt = lastHeartbeatOrAlarm[0].stts_volt;
|
logDevice.stts_volt = lastHeartbeatOrAlarm[0]?.stts_volt || 0
|
||||||
logDevice.stts_switch = lastHeartbeatOrAlarm[0].stts_switch;
|
logDevice.stts_switch = lastHeartbeatOrAlarm[0]?.stts_switch || 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// sekarang heartbeat diinject data lokasi juga dari lokasi terakhir
|
// sekarang heartbeat diinject data lokasi juga dari lokasi terakhir
|
||||||
if (["heartbeat"].includes(logDevice.action)) {
|
if (["heartbeat"].includes(logDevice.action)) {
|
||||||
if (lastTrack.length > 0) {
|
if (lastTrack.length > 0) {
|
||||||
logDevice.latitude = lastTrack[0].latitude;
|
logDevice.latitude = lastTrack[0].latitude
|
||||||
logDevice.longitude = lastTrack[0].longitude;
|
logDevice.longitude = lastTrack[0].longitude
|
||||||
logDevice.speed = lastTrack[0].speed;
|
logDevice.speed = lastTrack[0].speed
|
||||||
logDevice.orientation = lastTrack[0].orientation;
|
logDevice.orientation = lastTrack[0].orientation
|
||||||
if (logDevice.latitude) {
|
if (logDevice.latitude) {
|
||||||
logDevice.stts_reverse_geo = GpsTracksModels.STTS_REVERSE_GEO_NOT;
|
logDevice.stts_reverse_geo = GpsTracksModels.STTS_REVERSE_GEO_NOT
|
||||||
}
|
}
|
||||||
|
|
||||||
logDevice.length_gps = lastTrack[0].length_gps;
|
logDevice.length_gps = lastTrack[0].length_gps
|
||||||
logDevice.pos_stlt_gps = lastTrack[0].pos_stlt_gps;
|
logDevice.pos_stlt_gps = lastTrack[0].pos_stlt_gps
|
||||||
logDevice.pos_type_gps = lastTrack[0].pos_type_gps;
|
logDevice.pos_type_gps = lastTrack[0].pos_type_gps
|
||||||
logDevice.is_pos_gps = lastTrack[0].is_pos_gps;
|
logDevice.is_pos_gps = lastTrack[0].is_pos_gps
|
||||||
|
|
||||||
// jika gapengen dimunculin di last movement
|
// jika gapengen dimunculin di last movement
|
||||||
// logDevice.crt = lastTrack[0].crt;
|
// logDevice.crt = lastTrack[0].crt;
|
||||||
@ -115,27 +123,33 @@ async function commitMessage(now, logDevice) {
|
|||||||
// logDevice.crt_d = lastTrack[0].crt_d;
|
// logDevice.crt_d = lastTrack[0].crt_d;
|
||||||
// logDevice.crt_d_format = lastTrack[0].crt_d_format;
|
// logDevice.crt_d_format = lastTrack[0].crt_d_format;
|
||||||
// jika pengen di munculin di last movement
|
// jika pengen di munculin di last movement
|
||||||
logDevice.crt = now;
|
logDevice.crt = now
|
||||||
logDevice.crt_format = moment.unix(now).format("YYYY-MM-DD HH:mm:ss");
|
logDevice.crt_format = moment.unix(now).format("YYYY-MM-DD HH:mm:ss")
|
||||||
logDevice.crt_d = now;
|
logDevice.crt_d = now
|
||||||
logDevice.crt_d_format = moment.unix(now).format("YYYY-MM-DD HH:mm:ss");
|
logDevice.crt_d_format = moment.unix(now).format("YYYY-MM-DD HH:mm:ss")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// count milleage
|
// count milleage
|
||||||
if (logDevice.latitude != null && logDevice.longitude != null && lastTrack.length > 0) {
|
if (logDevice.latitude != null && logDevice.longitude != null && lastTrack.length > 0) {
|
||||||
const distance = LibHelper.haversineGreatCircleDistance(lastTrack[0].latitude, lastTrack[0].longitude, logDevice.latitude, logDevice.longitude, LibHelper.EARTH_RADIUS_KM);
|
const distance = LibHelper.haversineGreatCircleDistance(
|
||||||
const distance_km = LibHelper.kmToKm(distance, 100000000);
|
lastTrack[0].latitude,
|
||||||
|
lastTrack[0].longitude,
|
||||||
|
logDevice.latitude,
|
||||||
|
logDevice.longitude,
|
||||||
|
LibHelper.EARTH_RADIUS_KM
|
||||||
|
)
|
||||||
|
const distance_km = LibHelper.kmToKm(distance, 100000000)
|
||||||
// console.log(`GPS TRACKER UP LOCATION => device_id:${logDevice.device_id} vhc_id:${(vhc[0]) ? vhc[0].vid : 0}, distance_km:${distance_km}`);
|
// console.log(`GPS TRACKER UP LOCATION => device_id:${logDevice.device_id} vhc_id:${(vhc[0]) ? vhc[0].vid : 0}, distance_km:${distance_km}`);
|
||||||
// validasi jika lebih dari 3km, ga disimpan
|
// validasi jika lebih dari 3km, ga disimpan
|
||||||
if (distance_km >= 3) {
|
if (distance_km >= 3) {
|
||||||
GpsTracksModels.bundleCreate2(logDevice, logDevice); // jika tidak disimpan malah jadi bug, jadi akan update lokasi terus dengan kalkulasi jarak sebelumnya jadi makan lama makin lebar, mending disimpen terus milleagenya jadi 0 aja
|
GpsTracksModels.bundleCreate2(logDevice, logDevice) // jika tidak disimpan malah jadi bug, jadi akan update lokasi terus dengan kalkulasi jarak sebelumnya jadi makan lama makin lebar, mending disimpen terus milleagenya jadi 0 aja
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
logDevice.pre_milleage = distance_km;
|
logDevice.pre_milleage = distance_km
|
||||||
logDevice.sum_milleage = (lastTrack[0].sum_milleage + logDevice.pre_milleage).toFixed(8);
|
logDevice.sum_milleage = (lastTrack[0].sum_milleage + logDevice.pre_milleage).toFixed(8)
|
||||||
if (vhc.length > 0) {
|
if (vhc.length > 0) {
|
||||||
logDevice.vhc_id = vhc[0] ? vhc[0].vid : 0;
|
logDevice.vhc_id = vhc[0] ? vhc[0].vid : 0
|
||||||
// if (lastTrack[0].vhc_id == logDevice.vhc_id) {
|
// if (lastTrack[0].vhc_id == logDevice.vhc_id) {
|
||||||
// logDevice.vhc_milleage = (lastTrack[0].vhc_milleage + logDevice.pre_milleage).toFixed(8);
|
// logDevice.vhc_milleage = (lastTrack[0].vhc_milleage + logDevice.pre_milleage).toFixed(8);
|
||||||
// } else {
|
// } else {
|
||||||
@ -147,9 +161,9 @@ async function commitMessage(now, logDevice) {
|
|||||||
// logDevice.vhc_milleage = ((vhc[0] ? vhc[0].sum_milleage : 0) + logDevice.pre_milleage).toFixed(8);
|
// logDevice.vhc_milleage = ((vhc[0] ? vhc[0].sum_milleage : 0) + logDevice.pre_milleage).toFixed(8);
|
||||||
// }
|
// }
|
||||||
// force mileage dari vechile
|
// force mileage dari vechile
|
||||||
logDevice.vhc_milleage = ((vhc[0]?.sum_milleage || 0) + logDevice.pre_milleage).toFixed(8);
|
logDevice.vhc_milleage = ((vhc[0]?.sum_milleage || 0) + logDevice.pre_milleage).toFixed(8)
|
||||||
|
|
||||||
VhcModels.update(vhc[0] ? vhc[0].vid : 0, { sum_milleage: logDevice.vhc_milleage });
|
VhcModels.update(vhc[0] ? vhc[0].vid : 0, { sum_milleage: logDevice.vhc_milleage })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,16 +171,16 @@ async function commitMessage(now, logDevice) {
|
|||||||
if (logDevice.latitude != null && logDevice.longitude != null) {
|
if (logDevice.latitude != null && logDevice.longitude != null) {
|
||||||
// && vhc.length > 0
|
// && vhc.length > 0
|
||||||
// log tracking
|
// log tracking
|
||||||
const currTrack = await GpsTracksModels.bundleCreate2(logDevice, logDevice);
|
const currTrack = await GpsTracksModels.bundleCreate2(logDevice, logDevice)
|
||||||
// console.log('GT06 HAS LOCATION AND CHECK ZONE');
|
// console.log('GT06 HAS LOCATION AND CHECK ZONE');
|
||||||
const inCircle = await ZoneModels.getInCircle(logDevice.latitude, logDevice.longitude);
|
const inCircle = await ZoneModels.getInCircle(logDevice.latitude, logDevice.longitude)
|
||||||
const inShape = await ZoneModels.getInShape(logDevice.latitude, logDevice.longitude);
|
const inShape = await ZoneModels.getInShape(logDevice.latitude, logDevice.longitude)
|
||||||
const insideSpawnZone = [];
|
const insideSpawnZone = []
|
||||||
for (let zone of inCircle) {
|
for (let zone of inCircle) {
|
||||||
insideSpawnZone.push(zone);
|
insideSpawnZone.push(zone)
|
||||||
}
|
}
|
||||||
for (let zone of inShape) {
|
for (let zone of inShape) {
|
||||||
insideSpawnZone.push(zone);
|
insideSpawnZone.push(zone)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -181,12 +195,12 @@ async function commitMessage(now, logDevice) {
|
|||||||
leave_at_d: 0,
|
leave_at_d: 0,
|
||||||
order_by: "ORDER BY id DESC",
|
order_by: "ORDER BY id DESC",
|
||||||
limit: 1,
|
limit: 1,
|
||||||
});
|
})
|
||||||
|
|
||||||
if (lastSpawn.length > 0) {
|
if (lastSpawn.length > 0) {
|
||||||
let is_leave_zone = 1;
|
let is_leave_zone = 1
|
||||||
for (const insideZone of insideSpawnZone) {
|
for (const insideZone of insideSpawnZone) {
|
||||||
if (insideZone.zid === lastSpawn[0].zone_id) is_leave_zone = 0;
|
if (insideZone.zid === lastSpawn[0].zone_id) is_leave_zone = 0
|
||||||
}
|
}
|
||||||
if (is_leave_zone === 1 && lastSpawn[0].device_id == logDevice.device_id) {
|
if (is_leave_zone === 1 && lastSpawn[0].device_id == logDevice.device_id) {
|
||||||
GpsTracksModels.updt2SpawnZone(
|
GpsTracksModels.updt2SpawnZone(
|
||||||
@ -201,7 +215,7 @@ async function commitMessage(now, logDevice) {
|
|||||||
updt_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
updt_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
||||||
},
|
},
|
||||||
lastSpawn[0].id
|
lastSpawn[0].id
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let zone of insideSpawnZone) {
|
for (let zone of insideSpawnZone) {
|
||||||
@ -213,13 +227,17 @@ async function commitMessage(now, logDevice) {
|
|||||||
z_workflow_name: zone.workflow_type_name,
|
z_workflow_name: zone.workflow_type_name,
|
||||||
shiptocode: zone.shiptocode,
|
shiptocode: zone.shiptocode,
|
||||||
z_fulladdress: zone.fulladdress,
|
z_fulladdress: zone.fulladdress,
|
||||||
v_nopol: (vhc[0] ? vhc[0].nopol1 : 0 || "") + (vhc[0] ? vhc[0].nopol2 : 0 || "") + (vhc[0] ? vhc[0].nopol3 : 0 || ""),
|
v_nopol:
|
||||||
|
(vhc[0] ? vhc[0].nopol1 : 0 || "") +
|
||||||
|
(vhc[0] ? vhc[0].nopol2 : 0 || "") +
|
||||||
|
(vhc[0] ? vhc[0].nopol3 : 0 || ""),
|
||||||
da_name: vhc[0] ? vhc[0].da_name : 0 || "",
|
da_name: vhc[0] ? vhc[0].da_name : 0 || "",
|
||||||
da_phone: "+" + (vhc[0] ? vhc[0].da_phone_code : 0 || "") + (vhc[0] ? vhc[0].da_phone : 0 || ""),
|
da_phone:
|
||||||
};
|
"+" + (vhc[0] ? vhc[0].da_phone_code : 0 || "") + (vhc[0] ? vhc[0].da_phone : 0 || ""),
|
||||||
|
}
|
||||||
// LibMail.sendVhcSpawnZoneMail(`${(vhc[0]) ? vhc[0].nopol1 : 0 || ''}${(vhc[0]) ? vhc[0].nopol2 : 0 || ''}${(vhc[0]) ? vhc[0].nopol3 : 0 || ''} entering zone ${mailData.z_name}`, mailData.pic_mail, mailData);
|
// LibMail.sendVhcSpawnZoneMail(`${(vhc[0]) ? vhc[0].nopol1 : 0 || ''}${(vhc[0]) ? vhc[0].nopol2 : 0 || ''}${(vhc[0]) ? vhc[0].nopol3 : 0 || ''} entering zone ${mailData.z_name}`, mailData.pic_mail, mailData);
|
||||||
|
|
||||||
if (logDevice.device_id === "0865784052395871") console.log(1234567890);
|
if (logDevice.device_id === "0865784052395871") console.log(1234567890)
|
||||||
GpsTracksModels.create2SpawnZone({
|
GpsTracksModels.create2SpawnZone({
|
||||||
device_id: logDevice.device_id,
|
device_id: logDevice.device_id,
|
||||||
master_id: Number(currTrack.result.insertId),
|
master_id: Number(currTrack.result.insertId),
|
||||||
@ -235,27 +253,27 @@ async function commitMessage(now, logDevice) {
|
|||||||
source: GpsTracksModels.SOURCE_GPS_TRACKER,
|
source: GpsTracksModels.SOURCE_GPS_TRACKER,
|
||||||
crt: now,
|
crt: now,
|
||||||
crt_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
crt_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
||||||
});
|
})
|
||||||
if (logDevice.device_id === "0865784052395871") console.log("DISINI");
|
if (logDevice.device_id === "0865784052395871") console.log("DISINI")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// log tracking
|
// log tracking
|
||||||
GpsTracksModels.bundleCreate2(logDevice, logDevice);
|
GpsTracksModels.bundleCreate2(logDevice, logDevice)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ListenController {
|
class ListenController {
|
||||||
async gps(req, res) {
|
async gps(req, res) {
|
||||||
let apiRes = {};
|
let apiRes = {}
|
||||||
try {
|
try {
|
||||||
const c = { id: req.body._id };
|
const c = { id: req.body._id }
|
||||||
let buffer_req = Buffer.from(req.body.data, "base64");
|
let buffer_req = Buffer.from(req.body.data, "base64")
|
||||||
const now = moment().unix();
|
const now = moment().unix()
|
||||||
const me = LibDevice.identifyProtocolFromBuffer(buffer_req);
|
const me = LibDevice.identifyProtocolFromBuffer(buffer_req)
|
||||||
|
|
||||||
const logDevice = {
|
const logDevice = {
|
||||||
original_hex: me.ori_string,
|
original_hex: me.ori_string,
|
||||||
@ -291,100 +309,228 @@ class ListenController {
|
|||||||
crt_d_format: null,
|
crt_d_format: null,
|
||||||
crt_s: now,
|
crt_s: now,
|
||||||
crt_s_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
crt_s_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
||||||
};
|
}
|
||||||
|
|
||||||
if (me.protocol_name == "gt06") {
|
if (me.protocol_name == "gt06") {
|
||||||
let dvc_id = devices[c.id];
|
let dvc_id = devices[c.id]
|
||||||
const act = LibDevice.gt06Action(me, dvc_id || null);
|
const act = LibDevice.gt06Action(me, dvc_id || null)
|
||||||
|
|
||||||
if (act.action_type == "login") {
|
if (act.action_type == "login") {
|
||||||
logDevice.action = act.action_type;
|
logDevice.action = act.action_type
|
||||||
logDevice.device_id = act.device_id;
|
logDevice.device_id = act.device_id
|
||||||
devices[c.id] = act.device_id;
|
devices[c.id] = act.device_id
|
||||||
} else if (act.action_type == "location") {
|
} else if (act.action_type == "location") {
|
||||||
logDevice.action = act.action_type;
|
logDevice.action = act.action_type
|
||||||
logDevice.device_id = act.device_id;
|
logDevice.device_id = act.device_id
|
||||||
logDevice.latitude = act.gps_data.latitude || null;
|
logDevice.latitude = act.gps_data.latitude || null
|
||||||
logDevice.longitude = act.gps_data.longitude || null;
|
logDevice.longitude = act.gps_data.longitude || null
|
||||||
logDevice.speed = act.gps_data.speed;
|
logDevice.speed = act.gps_data.speed
|
||||||
logDevice.orientation = act.gps_data.orientation;
|
logDevice.orientation = act.gps_data.orientation
|
||||||
if (logDevice.latitude) {
|
if (logDevice.latitude) {
|
||||||
logDevice.stts_reverse_geo = GpsTracksModels.STTS_REVERSE_GEO_NOT;
|
logDevice.stts_reverse_geo = GpsTracksModels.STTS_REVERSE_GEO_NOT
|
||||||
}
|
}
|
||||||
logDevice.length_gps = act.gps_data.quantity_pos_satellites_c;
|
logDevice.length_gps = act.gps_data.quantity_pos_satellites_c
|
||||||
logDevice.pos_stlt_gps = act.gps_data.quantity_pos_satellites_b;
|
logDevice.pos_stlt_gps = act.gps_data.quantity_pos_satellites_b
|
||||||
logDevice.pos_type_gps = Number(act.gps_data.realtime_dif_gps) === 0 ? GpsTracksModels.STTS_POS_TYPE_GPS_RLTM : GpsTracksModels.STTS_POS_TYPE_GPS_DIFF;
|
logDevice.pos_type_gps =
|
||||||
logDevice.is_pos_gps = Number(act.gps_data.positioning_gps) ? GpsTracksModels.STTS_IS_POS_GPS_HAS : GpsTracksModels.STTS_IS_POS_GPS_NOT;
|
Number(act.gps_data.realtime_dif_gps) === 0
|
||||||
logDevice.crt = moment(act.gps_data.date).unix();
|
? GpsTracksModels.STTS_POS_TYPE_GPS_RLTM
|
||||||
logDevice.crt_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss");
|
: GpsTracksModels.STTS_POS_TYPE_GPS_DIFF
|
||||||
logDevice.crt_d = moment(act.gps_data.date).unix();
|
logDevice.is_pos_gps = Number(act.gps_data.positioning_gps)
|
||||||
logDevice.crt_d_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss");
|
? GpsTracksModels.STTS_IS_POS_GPS_HAS
|
||||||
|
: GpsTracksModels.STTS_IS_POS_GPS_NOT
|
||||||
|
logDevice.crt = moment(act.gps_data.date).unix()
|
||||||
|
logDevice.crt_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
logDevice.crt_d = moment(act.gps_data.date).unix()
|
||||||
|
logDevice.crt_d_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss")
|
||||||
} else if (act.action_type == "heartbeat") {
|
} else if (act.action_type == "heartbeat") {
|
||||||
logDevice.action = act.action_type;
|
logDevice.action = act.action_type
|
||||||
logDevice.device_id = act.device_id;
|
logDevice.device_id = act.device_id
|
||||||
logDevice.ignition = Number(act.stts_data.terminal_info.acc) ? GpsTracksModels.STTS_IGNITION_HIGH : GpsTracksModels.STTS_IGNITION_LOW;
|
logDevice.ignition = Number(act.stts_data.terminal_info.acc)
|
||||||
logDevice.stts_gps = act.stts_data.terminal_info.gps_tracking ? GpsTracksModels.STTS_GPS_ON : GpsTracksModels.STTS_GPS_OFF;
|
? GpsTracksModels.STTS_IGNITION_HIGH
|
||||||
logDevice.stts_gsm = Number(act.stts_data.gsm_signal_strength) + 1;
|
: GpsTracksModels.STTS_IGNITION_LOW
|
||||||
logDevice.stts_oil_electricity = Number(act.stts_data.terminal_info.oil_electricity) === 0 ? GpsTracksModels.STTS_OIL_ELECTRIC_ON : GpsTracksModels.STTS_OIL_ELECTRIC_OFF;
|
logDevice.stts_gps = act.stts_data.terminal_info.gps_tracking
|
||||||
|
? GpsTracksModels.STTS_GPS_ON
|
||||||
|
: GpsTracksModels.STTS_GPS_OFF
|
||||||
|
logDevice.stts_gsm = Number(act.stts_data.gsm_signal_strength) + 1
|
||||||
|
logDevice.stts_oil_electricity =
|
||||||
|
Number(act.stts_data.terminal_info.oil_electricity) === 0
|
||||||
|
? GpsTracksModels.STTS_OIL_ELECTRIC_ON
|
||||||
|
: GpsTracksModels.STTS_OIL_ELECTRIC_OFF
|
||||||
|
|
||||||
let stts_alarm = Number(act.stts_data.terminal_info.stts);
|
let stts_alarm = Number(act.stts_data.terminal_info.stts)
|
||||||
logDevice.stts_alarm = stts_alarm === 1 ? GpsTracksModels.STTS_ALARM_SHOCK : stts_alarm === 2 ? GpsTracksModels.STTS_ALARM_POWER_CUT : stts_alarm === 3 ? GpsTracksModels.STTS_ALARM_LOW_BATTERY : stts_alarm === 4 ? GpsTracksModels.STTS_ALARM_SOS : GpsTracksModels.STTS_ALARM_NORMAL;
|
logDevice.stts_alarm =
|
||||||
|
stts_alarm === 1
|
||||||
|
? GpsTracksModels.STTS_ALARM_SHOCK
|
||||||
|
: stts_alarm === 2
|
||||||
|
? GpsTracksModels.STTS_ALARM_POWER_CUT
|
||||||
|
: stts_alarm === 3
|
||||||
|
? GpsTracksModels.STTS_ALARM_LOW_BATTERY
|
||||||
|
: stts_alarm === 4
|
||||||
|
? GpsTracksModels.STTS_ALARM_SOS
|
||||||
|
: GpsTracksModels.STTS_ALARM_NORMAL
|
||||||
|
|
||||||
logDevice.stts_charge = Number(act.stts_data.terminal_info.charge) ? GpsTracksModels.STTS_CHARGE_ON : GpsTracksModels.STTS_CHARGE_OFF;
|
logDevice.stts_charge = Number(act.stts_data.terminal_info.charge)
|
||||||
logDevice.stts_acc = Number(act.stts_data.terminal_info.acc) ? GpsTracksModels.STTS_ACC_HIGH : GpsTracksModels.STTS_ACC_LOW;
|
? GpsTracksModels.STTS_CHARGE_ON
|
||||||
logDevice.stts_switch = Number(act.stts_data.terminal_info.is_active) ? GpsTracksModels.STTS_SWITCH_ON : GpsTracksModels.STTS_SWITCH_OFF;
|
: GpsTracksModels.STTS_CHARGE_OFF
|
||||||
logDevice.stts_volt = Number(act.stts_data.voltage_level) + 1;
|
logDevice.stts_acc = Number(act.stts_data.terminal_info.acc)
|
||||||
|
? GpsTracksModels.STTS_ACC_HIGH
|
||||||
|
: GpsTracksModels.STTS_ACC_LOW
|
||||||
|
logDevice.stts_switch = Number(act.stts_data.terminal_info.is_active)
|
||||||
|
? GpsTracksModels.STTS_SWITCH_ON
|
||||||
|
: GpsTracksModels.STTS_SWITCH_OFF
|
||||||
|
logDevice.stts_volt = Number(act.stts_data.voltage_level) + 1
|
||||||
} else if (act.action_type == "alarm") {
|
} else if (act.action_type == "alarm") {
|
||||||
logDevice.action = act.action_type;
|
logDevice.action = act.action_type
|
||||||
logDevice.device_id = act.device_id;
|
logDevice.device_id = act.device_id
|
||||||
logDevice.latitude = act.gps_data.latitude || null;
|
logDevice.latitude = act.gps_data.latitude || null
|
||||||
logDevice.longitude = act.gps_data.longitude || null;
|
logDevice.longitude = act.gps_data.longitude || null
|
||||||
logDevice.speed = act.gps_data.speed;
|
logDevice.speed = act.gps_data.speed
|
||||||
logDevice.orientation = act.gps_data.orientation;
|
logDevice.orientation = act.gps_data.orientation
|
||||||
if (logDevice.latitude) {
|
if (logDevice.latitude) {
|
||||||
logDevice.stts_reverse_geo = GpsTracksModels.STTS_REVERSE_GEO_NOT;
|
logDevice.stts_reverse_geo = GpsTracksModels.STTS_REVERSE_GEO_NOT
|
||||||
}
|
}
|
||||||
logDevice.length_gps = act.gps_data.quantity_pos_satellites_c;
|
logDevice.length_gps = act.gps_data.quantity_pos_satellites_c
|
||||||
logDevice.pos_stlt_gps = act.gps_data.quantity_pos_satellites_b;
|
logDevice.pos_stlt_gps = act.gps_data.quantity_pos_satellites_b
|
||||||
logDevice.pos_type_gps = Number(act.gps_data.realtime_dif_gps) === 0 ? GpsTracksModels.STTS_POS_TYPE_GPS_RLTM : GpsTracksModels.STTS_POS_TYPE_GPS_DIFF;
|
logDevice.pos_type_gps =
|
||||||
logDevice.is_pos_gps = Number(act.gps_data.positioning_gps) ? GpsTracksModels.STTS_IS_POS_GPS_HAS : GpsTracksModels.STTS_IS_POS_GPS_NOT;
|
Number(act.gps_data.realtime_dif_gps) === 0
|
||||||
logDevice.ignition = Number(act.stts_data.terminal_info.acc) ? GpsTracksModels.STTS_IGNITION_HIGH : GpsTracksModels.STTS_IGNITION_LOW;
|
? GpsTracksModels.STTS_POS_TYPE_GPS_RLTM
|
||||||
logDevice.stts_gps = act.stts_data.terminal_info.gps_tracking ? GpsTracksModels.STTS_GPS_ON : GpsTracksModels.STTS_GPS_OFF;
|
: GpsTracksModels.STTS_POS_TYPE_GPS_DIFF
|
||||||
logDevice.stts_gsm = Number(act.stts_data.gsm_signal_strength) + 1;
|
logDevice.is_pos_gps = Number(act.gps_data.positioning_gps)
|
||||||
logDevice.stts_oil_electricity = Number(act.stts_data.terminal_info.oil_electricity) === 0 ? GpsTracksModels.STTS_OIL_ELECTRIC_ON : GpsTracksModels.STTS_OIL_ELECTRIC_OFF;
|
? GpsTracksModels.STTS_IS_POS_GPS_HAS
|
||||||
|
: GpsTracksModels.STTS_IS_POS_GPS_NOT
|
||||||
|
logDevice.ignition = Number(act.stts_data.terminal_info.acc)
|
||||||
|
? GpsTracksModels.STTS_IGNITION_HIGH
|
||||||
|
: GpsTracksModels.STTS_IGNITION_LOW
|
||||||
|
logDevice.stts_gps = act.stts_data.terminal_info.gps_tracking
|
||||||
|
? GpsTracksModels.STTS_GPS_ON
|
||||||
|
: GpsTracksModels.STTS_GPS_OFF
|
||||||
|
logDevice.stts_gsm = Number(act.stts_data.gsm_signal_strength) + 1
|
||||||
|
logDevice.stts_oil_electricity =
|
||||||
|
Number(act.stts_data.terminal_info.oil_electricity) === 0
|
||||||
|
? GpsTracksModels.STTS_OIL_ELECTRIC_ON
|
||||||
|
: GpsTracksModels.STTS_OIL_ELECTRIC_OFF
|
||||||
|
|
||||||
let stts_alarm = Number(act.stts_data.terminal_info.stts);
|
let stts_alarm = Number(act.stts_data.terminal_info.stts)
|
||||||
logDevice.stts_alarm = stts_alarm === 1 ? GpsTracksModels.STTS_ALARM_SHOCK : stts_alarm === 2 ? GpsTracksModels.STTS_ALARM_POWER_CUT : stts_alarm === 3 ? GpsTracksModels.STTS_ALARM_LOW_BATTERY : stts_alarm === 4 ? GpsTracksModels.STTS_ALARM_SOS : GpsTracksModels.STTS_ALARM_NORMAL;
|
logDevice.stts_alarm =
|
||||||
|
stts_alarm === 1
|
||||||
|
? GpsTracksModels.STTS_ALARM_SHOCK
|
||||||
|
: stts_alarm === 2
|
||||||
|
? GpsTracksModels.STTS_ALARM_POWER_CUT
|
||||||
|
: stts_alarm === 3
|
||||||
|
? GpsTracksModels.STTS_ALARM_LOW_BATTERY
|
||||||
|
: stts_alarm === 4
|
||||||
|
? GpsTracksModels.STTS_ALARM_SOS
|
||||||
|
: GpsTracksModels.STTS_ALARM_NORMAL
|
||||||
|
|
||||||
logDevice.stts_charge = Number(act.stts_data.terminal_info.charge) ? GpsTracksModels.STTS_CHARGE_ON : GpsTracksModels.STTS_CHARGE_OFF;
|
logDevice.stts_charge = Number(act.stts_data.terminal_info.charge)
|
||||||
logDevice.stts_acc = Number(act.stts_data.terminal_info.acc) ? GpsTracksModels.STTS_ACC_HIGH : GpsTracksModels.STTS_ACC_LOW;
|
? GpsTracksModels.STTS_CHARGE_ON
|
||||||
logDevice.stts_switch = Number(act.stts_data.terminal_info.is_active) ? GpsTracksModels.STTS_SWITCH_ON : GpsTracksModels.STTS_SWITCH_OFF;
|
: GpsTracksModels.STTS_CHARGE_OFF
|
||||||
logDevice.stts_volt = Number(act.stts_data.voltage_level) + 1;
|
logDevice.stts_acc = Number(act.stts_data.terminal_info.acc)
|
||||||
logDevice.crt = moment(act.gps_data.date).unix();
|
? GpsTracksModels.STTS_ACC_HIGH
|
||||||
logDevice.crt_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss");
|
: GpsTracksModels.STTS_ACC_LOW
|
||||||
logDevice.crt_d = moment(act.gps_data.date).unix();
|
logDevice.stts_switch = Number(act.stts_data.terminal_info.is_active)
|
||||||
logDevice.crt_d_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss");
|
? GpsTracksModels.STTS_SWITCH_ON
|
||||||
|
: GpsTracksModels.STTS_SWITCH_OFF
|
||||||
|
logDevice.stts_volt = Number(act.stts_data.voltage_level) + 1
|
||||||
|
logDevice.crt = moment(act.gps_data.date).unix()
|
||||||
|
logDevice.crt_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
logDevice.crt_d = moment(act.gps_data.date).unix()
|
||||||
|
logDevice.crt_d_format = moment(act.gps_data.date).format("YYYY-MM-DD HH:mm:ss")
|
||||||
} else {
|
} else {
|
||||||
logDevice.action = act.action_type;
|
logDevice.action = act.action_type
|
||||||
logDevice.device_id = act.device_id;
|
logDevice.device_id = act.device_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await commitMessage(now, logDevice);
|
await commitMessage(now, logDevice)
|
||||||
|
|
||||||
apiRes = JSON.parse(JSON.stringify(response[200]));
|
apiRes = JSON.parse(JSON.stringify(response[200]))
|
||||||
apiRes.meta.message = "success";
|
apiRes.meta.message = "success"
|
||||||
apiRes.data = logDevice;
|
apiRes.data = logDevice
|
||||||
return res.status(200).json(apiRes);
|
return res.status(200).json(apiRes)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("error", e);
|
console.log("error", e)
|
||||||
apiRes = JSON.parse(JSON.stringify(response[500]));
|
apiRes = JSON.parse(JSON.stringify(response[500]))
|
||||||
apiRes.meta.message += Helper.setErrMsg(": " + e.message);
|
apiRes.meta.message += Helper.setErrMsg(": " + e.message)
|
||||||
return res.status(500).json(apiRes);
|
return res.status(500).json(apiRes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async teltonika(req, res) {
|
||||||
|
let apiRes = {}
|
||||||
|
try {
|
||||||
|
const imei = req.body.imei.toString().padStart(16, "0")
|
||||||
|
const records = req.body.records
|
||||||
|
|
||||||
|
// for (const rec of records) {
|
||||||
|
// console.log(
|
||||||
|
// `→ ${rec.timestamp} ${imei} | GNSS: ${JSON.stringify(rec.gnss)} || IO: ${JSON.stringify(rec.io)}`
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
|
||||||
|
// -- Commit each record to DB --
|
||||||
|
// records.forEach(async (rec) => {
|
||||||
|
for (const rec of records) {
|
||||||
|
// console.log("rec ====> ", rec)
|
||||||
|
|
||||||
|
const now = moment().unix()
|
||||||
|
const logDevice = {
|
||||||
|
original_hex: "0xTELTONIKA",
|
||||||
|
protocol: "teltonika8e",
|
||||||
|
action: "location",
|
||||||
|
device_id: imei,
|
||||||
|
latitude: rec.gnss.latitude || null,
|
||||||
|
longitude: rec.gnss.longitude || null,
|
||||||
|
speed: rec.gnss.speed || 0,
|
||||||
|
orientation: rec.gnss.angle || 0,
|
||||||
|
ignition: rec.io.Ignition ? GpsTracksModels.STTS_IGNITION_HIGH : GpsTracksModels.STTS_IGNITION_LOW,
|
||||||
|
stts_engine: 0,
|
||||||
|
stts_gps: rec.gnss.satellites || 0,
|
||||||
|
length_gps: 0,
|
||||||
|
pos_stlt_gps: 0,
|
||||||
|
pos_type_gps: 0,
|
||||||
|
is_pos_gps: 0,
|
||||||
|
stts_gsm: 0,
|
||||||
|
stts_oil_electricity: 0,
|
||||||
|
stts_alarm: 0,
|
||||||
|
stts_charge: 0,
|
||||||
|
stts_acc: 0,
|
||||||
|
stts_volt: 0,
|
||||||
|
stts_switch: 0,
|
||||||
|
stts_reverse_geo: 0,
|
||||||
|
pre_milleage: 0,
|
||||||
|
source: GpsTracksModels.SOURCE_GPS_TRACKER,
|
||||||
|
vhc_id: 0,
|
||||||
|
drv_id: 0,
|
||||||
|
drv_milleage: rec.io["Trip Odometer"] || 0,
|
||||||
|
crt: now,
|
||||||
|
crt_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
||||||
|
crt_d: rec.gnss.timestamp / 1000,
|
||||||
|
crt_d_format: moment.unix(rec.gnss.timestamp / 1000).format("YYYY-MM-DD HH:mm:ss"),
|
||||||
|
crt_s: now,
|
||||||
|
crt_s_format: moment.unix(now).format("YYYY-MM-DD HH:mm:ss"),
|
||||||
|
fuel_curr: rec.io["Fuel Level"] || 0,
|
||||||
|
fuel_count: rec.io["Fuel Consumed (counted)"] || 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
await commitMessage(now, logDevice)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IO: {"Ignition":0,"Movement":1,"GSM Signal":5,"Sleep Mode":0,"GNSS Status":1,"Accelerator Pedal Position":0,"External Voltage":13087,"Battery Voltage":4100,"Fuel Level":144,"Engine RPM":0,"Engine Temperature":950,"Trip Odometer":48250,"Total Odometer":288320,"Total Mileage":125662000,"Fuel Consumed (counted)":229}
|
||||||
|
|
||||||
|
apiRes = JSON.parse(JSON.stringify(response[200]))
|
||||||
|
apiRes.meta.message = "success"
|
||||||
|
// apiRes.data = "logDevice"
|
||||||
|
return res.status(200).json(apiRes)
|
||||||
|
} catch (err) {
|
||||||
|
console.error("❌ error:", err.message)
|
||||||
|
apiRes = JSON.parse(JSON.stringify(response[500]))
|
||||||
|
apiRes.meta.message += Helper.setErrMsg(": " + err.message)
|
||||||
|
return res.status(500).json(apiRes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const object = new ListenController();
|
const object = new ListenController()
|
||||||
|
|
||||||
module.exports = object;
|
module.exports = object
|
||||||
|
|||||||
@ -41,7 +41,7 @@ async function job() {
|
|||||||
id bigint NOT NULL AUTO_INCREMENT,
|
id bigint NOT NULL AUTO_INCREMENT,
|
||||||
original_hex text,
|
original_hex text,
|
||||||
protocol enum('gt06','tk119','smartphone') DEFAULT NULL,
|
protocol enum('gt06','tk119','smartphone') DEFAULT NULL,
|
||||||
action enum('login','heartbeat','location','alarm','other') DEFAULT NULL,
|
action enum('login','heartbeat','location','alarm','other','teltonika8e') DEFAULT NULL,
|
||||||
device_id varchar(16) DEFAULT NULL,
|
device_id varchar(16) DEFAULT NULL,
|
||||||
latitude double DEFAULT NULL,
|
latitude double DEFAULT NULL,
|
||||||
longitude double DEFAULT NULL,
|
longitude double DEFAULT NULL,
|
||||||
@ -66,6 +66,8 @@ async function job() {
|
|||||||
sum_milleage double NOT NULL DEFAULT '0' COMMENT 'in km. summary device milleage. calculated based on this device',
|
sum_milleage double NOT NULL DEFAULT '0' COMMENT 'in km. summary device milleage. calculated based on this device',
|
||||||
vhc_milleage double NOT NULL DEFAULT '0' COMMENT 'in km. summary vhc milleage. calculated based on vhc, every change vhc this will get last milleage on that vhc',
|
vhc_milleage double NOT NULL DEFAULT '0' COMMENT 'in km. summary vhc milleage. calculated based on vhc, every change vhc this will get last milleage on that vhc',
|
||||||
drv_milleage double NOT NULL DEFAULT '0' COMMENT 'in km. summary drv milleage. calculated based on drv, every change drv this will get last milleage on that drv',
|
drv_milleage double NOT NULL DEFAULT '0' COMMENT 'in km. summary drv milleage. calculated based on drv, every change drv this will get last milleage on that drv',
|
||||||
|
fuel_curr INT UNSIGNED DEFAULT 0,
|
||||||
|
fuel_count INT UNSIGNED DEFAULT 0,
|
||||||
vhc_id int NOT NULL DEFAULT '0',
|
vhc_id int NOT NULL DEFAULT '0',
|
||||||
drv_id int NOT NULL DEFAULT '0',
|
drv_id int NOT NULL DEFAULT '0',
|
||||||
source int NOT NULL DEFAULT '1' COMMENT '1=>gps_tracker, 2=>smartphone',
|
source int NOT NULL DEFAULT '1' COMMENT '1=>gps_tracker, 2=>smartphone',
|
||||||
|
|||||||
@ -1,97 +1,741 @@
|
|||||||
class LibHelper {
|
class LibHelper {
|
||||||
|
static EARTH_RADIUS_M = 6371000
|
||||||
|
static EARTH_RADIUS_KM = 6371
|
||||||
|
static EARTH_RADIUS_MILES = 3959 // 3958.756 || 3959 || 3963
|
||||||
|
|
||||||
static EARTH_RADIUS_M = 6371000;
|
static setErrMsg(msg) {
|
||||||
static EARTH_RADIUS_KM = 6371;
|
if (process.env.NODE_ENV == "development") {
|
||||||
static EARTH_RADIUS_MILES = 3959; // 3958.756 || 3959 || 3963
|
return msg
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
static setErrMsg(msg) {
|
/**
|
||||||
if (process.env.NODE_ENV == 'development') {
|
* Calculates the great-circle distance between two points, with
|
||||||
return msg;
|
* the Haversine formula.
|
||||||
}
|
* @param float latitudeFrom Latitude of start point in [deg decimal]
|
||||||
return '';
|
* @param float longitudeFrom Longitude of start point in [deg decimal]
|
||||||
}
|
* @param float latitudeTo Latitude of target point in [deg decimal]
|
||||||
|
* @param float longitudeTo Longitude of target point in [deg decimal]
|
||||||
|
* @param float earthRadius Mean earth radius in [m]
|
||||||
|
* @return float Distance between points in [m] (same as earthRadius)
|
||||||
|
* reference: https://stackoverflow.com/questions/14750275/haversine-formula-with-php
|
||||||
|
* tolak ukur: tarik garis lurus
|
||||||
|
* more accurate using km/meters than miles i think ~ rafifmulia
|
||||||
|
*/
|
||||||
|
static haversineGreatCircleDistance(latFrom, lngFrom, latTo, lngTo, earthRadius = LibHelper.EARTH_RADIUS_M) {
|
||||||
|
// convert from degrees to radians
|
||||||
|
let latFromRads = LibHelper.degsToRads(latFrom)
|
||||||
|
let lngFromRads = LibHelper.degsToRads(lngFrom)
|
||||||
|
let latToRads = LibHelper.degsToRads(latTo)
|
||||||
|
let lngToRads = LibHelper.degsToRads(lngTo)
|
||||||
|
|
||||||
/**
|
let latDelta = latToRads - latFromRads
|
||||||
* Calculates the great-circle distance between two points, with
|
let lngDelta = lngToRads - lngFromRads
|
||||||
* the Haversine formula.
|
|
||||||
* @param float latitudeFrom Latitude of start point in [deg decimal]
|
|
||||||
* @param float longitudeFrom Longitude of start point in [deg decimal]
|
|
||||||
* @param float latitudeTo Latitude of target point in [deg decimal]
|
|
||||||
* @param float longitudeTo Longitude of target point in [deg decimal]
|
|
||||||
* @param float earthRadius Mean earth radius in [m]
|
|
||||||
* @return float Distance between points in [m] (same as earthRadius)
|
|
||||||
* reference: https://stackoverflow.com/questions/14750275/haversine-formula-with-php
|
|
||||||
* tolak ukur: tarik garis lurus
|
|
||||||
* more accurate using km/meters than miles i think ~ rafifmulia
|
|
||||||
*/
|
|
||||||
static haversineGreatCircleDistance(latFrom, lngFrom, latTo, lngTo, earthRadius = LibHelper.EARTH_RADIUS_M) {
|
|
||||||
// convert from degrees to radians
|
|
||||||
let latFromRads = LibHelper.degsToRads(latFrom);
|
|
||||||
let lngFromRads = LibHelper.degsToRads(lngFrom);
|
|
||||||
let latToRads = LibHelper.degsToRads(latTo);
|
|
||||||
let lngToRads = LibHelper.degsToRads(lngTo);
|
|
||||||
|
|
||||||
let latDelta = latToRads - latFromRads;
|
let angle =
|
||||||
let lngDelta = lngToRads - lngFromRads;
|
2 *
|
||||||
|
Math.asin(
|
||||||
|
Math.sqrt(
|
||||||
|
Math.pow(Math.sin(latDelta / 2), 2) +
|
||||||
|
Math.cos(latFromRads) * Math.cos(latToRads) * Math.pow(Math.sin(lngDelta / 2), 2)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
let distance = angle * earthRadius
|
||||||
|
|
||||||
let angle = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(latDelta / 2), 2) + Math.cos(latFromRads) * Math.cos(latToRads) * Math.pow(Math.sin(lngDelta / 2), 2)));
|
return distance
|
||||||
let distance = angle * earthRadius;
|
}
|
||||||
|
|
||||||
return distance;
|
// reference: https://www.codegrepper.com/code-examples/javascript/deg2rad+javascript
|
||||||
}
|
// degrees to radians
|
||||||
|
static degsToRads(deg) {
|
||||||
|
return (deg * Math.PI) / 180.0
|
||||||
|
}
|
||||||
|
// radians to degrees
|
||||||
|
static radsToDegs(rad) {
|
||||||
|
return (rad * 180.0) / Math.PI
|
||||||
|
}
|
||||||
|
|
||||||
// reference: https://www.codegrepper.com/code-examples/javascript/deg2rad+javascript
|
// round up with precisions digits => 4 == (10000)
|
||||||
// degrees to radians
|
// reference: https://stackoverflow.com/questions/11832914/how-to-round-to-at-most-2-decimal-places-if-necessary
|
||||||
static degsToRads(deg) {
|
static milesToKm(miles, precisionDigits = 10000) {
|
||||||
return (deg * Math.PI) / 180.0;
|
return Math.round((miles * 1.609 + Number.EPSILON) * precisionDigits) / precisionDigits
|
||||||
}
|
}
|
||||||
// radians to degrees
|
static milesToMeters(miles, precisionDigits = 10000) {
|
||||||
static radsToDegs(rad) {
|
return Math.round((miles * 1609 + Number.EPSILON) * precisionDigits) / precisionDigits
|
||||||
return rad * 180.0 / Math.PI;
|
}
|
||||||
}
|
static milesToMiles(meters, precisionDigits = 10000) {
|
||||||
|
return Math.round((meters + Number.EPSILON) * precisionDigits) / precisionDigits
|
||||||
|
}
|
||||||
|
static kmToMiles(km, precisionDigits = 10000) {
|
||||||
|
return Math.round((km / 1.609 + Number.EPSILON) * precisionDigits) / precisionDigits
|
||||||
|
}
|
||||||
|
static kmToMeters(km, precisionDigits = 10000) {
|
||||||
|
return Math.round((km * 1000 + Number.EPSILON) * precisionDigits) / precisionDigits
|
||||||
|
}
|
||||||
|
static kmToKm(meters, precisionDigits = 10000) {
|
||||||
|
return Math.round((meters + Number.EPSILON) * precisionDigits) / precisionDigits
|
||||||
|
}
|
||||||
|
static metersToKm(meters, precisionDigits = 10000) {
|
||||||
|
return Math.round((meters / 1000 + Number.EPSILON) * precisionDigits) / precisionDigits
|
||||||
|
}
|
||||||
|
static metersToMiles(meters, precisionDigits = 10000) {
|
||||||
|
return Math.round((meters / 1609 + Number.EPSILON) * precisionDigits) / precisionDigits
|
||||||
|
}
|
||||||
|
static metersToMeters(meters, precisionDigits = 10000) {
|
||||||
|
return Math.round((meters + Number.EPSILON) * precisionDigits) / precisionDigits
|
||||||
|
}
|
||||||
|
|
||||||
// round up with precisions digits => 4 == (10000)
|
static hex2bin(hex) {
|
||||||
// reference: https://stackoverflow.com/questions/11832914/how-to-round-to-at-most-2-decimal-places-if-necessary
|
return ("00000000" + parseInt(hex, 16).toString(2)).slice(-8)
|
||||||
static milesToKm(miles, precisionDigits = 10000) {
|
}
|
||||||
return Math.round(((miles * 1.609) + Number.EPSILON) * precisionDigits) / precisionDigits;
|
|
||||||
}
|
|
||||||
static milesToMeters(miles, precisionDigits = 10000) {
|
|
||||||
return Math.round(((miles * 1609) + Number.EPSILON) * precisionDigits) / precisionDigits;
|
|
||||||
}
|
|
||||||
static milesToMiles(meters, precisionDigits = 10000) {
|
|
||||||
return Math.round(((meters) + Number.EPSILON) * precisionDigits) / precisionDigits;
|
|
||||||
}
|
|
||||||
static kmToMiles(km, precisionDigits = 10000) {
|
|
||||||
return Math.round(((km / 1.609) + Number.EPSILON) * precisionDigits) / precisionDigits;
|
|
||||||
}
|
|
||||||
static kmToMeters(km, precisionDigits = 10000) {
|
|
||||||
return Math.round(((km * 1000) + Number.EPSILON) * precisionDigits) / precisionDigits;
|
|
||||||
}
|
|
||||||
static kmToKm(meters, precisionDigits = 10000) {
|
|
||||||
return Math.round(((meters) + Number.EPSILON) * precisionDigits) / precisionDigits;
|
|
||||||
}
|
|
||||||
static metersToKm(meters, precisionDigits = 10000) {
|
|
||||||
return Math.round(((meters / 1000) + Number.EPSILON) * precisionDigits) / precisionDigits;
|
|
||||||
}
|
|
||||||
static metersToMiles(meters, precisionDigits = 10000) {
|
|
||||||
return Math.round(((meters / 1609) + Number.EPSILON) * precisionDigits) / precisionDigits;
|
|
||||||
}
|
|
||||||
static metersToMeters(meters, precisionDigits = 10000) {
|
|
||||||
return Math.round(((meters) + Number.EPSILON) * precisionDigits) / precisionDigits;
|
|
||||||
}
|
|
||||||
|
|
||||||
static hex2bin(hex) {
|
static splitEvery4Char(str) {
|
||||||
return ("00000000" + (parseInt(hex, 16)).toString(2)).slice(-8);
|
if (str) {
|
||||||
}
|
str = "" + str
|
||||||
|
let splitEvery4Char = str.match(/.{1,4}/g)
|
||||||
|
return splitEvery4Char.join(" ")
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
static splitEvery4Char(str) {
|
static ioID() {
|
||||||
if (str) {
|
return {
|
||||||
str = '' + str;
|
1: "Digital Input 1",
|
||||||
let splitEvery4Char = str.match(/.{1,4}/g)
|
2: "Digital Input 2",
|
||||||
return splitEvery4Char.join(' ')
|
3: "Digital Input 3",
|
||||||
}
|
4: "Pulse Counter Din1",
|
||||||
return '';
|
5: "Pulse Counter Din2",
|
||||||
}
|
6: "Analog Input 2",
|
||||||
};
|
9: "Analog Input 1",
|
||||||
|
10: "SD Status",
|
||||||
|
11: "ICCID1",
|
||||||
|
12: "Fuel Used GPS",
|
||||||
|
13: "Fuel Rate GPS",
|
||||||
|
15: "Eco Score",
|
||||||
|
16: "Total Odometer",
|
||||||
|
17: "Axis X",
|
||||||
|
18: "Axis Y",
|
||||||
|
19: "Axis Z",
|
||||||
|
21: "GSM Signal",
|
||||||
|
24: "Speed",
|
||||||
|
66: "External Voltage",
|
||||||
|
67: "Battery Voltage",
|
||||||
|
68: "Battery Current",
|
||||||
|
69: "GNSS Status",
|
||||||
|
71: "Dallas Temperature ID 4",
|
||||||
|
72: "Dallas Temperature 1",
|
||||||
|
73: "Dallas Temperature 2",
|
||||||
|
74: "Dallas Temperature 3",
|
||||||
|
75: "Dallas Temperature 4",
|
||||||
|
76: "Dallas Temperature ID 1",
|
||||||
|
77: "Dallas Temperature ID 2",
|
||||||
|
78: "iButton",
|
||||||
|
79: "Dallas Temperature ID 3",
|
||||||
|
80: "Data Mode",
|
||||||
|
113: "Battery Level",
|
||||||
|
179: "Digital Output 1",
|
||||||
|
180: "Digital Output 2",
|
||||||
|
181: "GNSS PDOP",
|
||||||
|
182: "GNSS HDOP",
|
||||||
|
199: "Trip Odometer",
|
||||||
|
200: "Sleep Mode",
|
||||||
|
201: "LLS 1 Fuel Level",
|
||||||
|
202: "LLS 1 Temperature",
|
||||||
|
203: "LLS 2 Fuel Level",
|
||||||
|
204: "LLS 2 Temperature",
|
||||||
|
205: "GSM Cell ID",
|
||||||
|
206: "GSM Area Code",
|
||||||
|
207: "RFID",
|
||||||
|
210: "LLS 3 Fuel Level",
|
||||||
|
211: "LLS 3 Temperature",
|
||||||
|
212: "LLS 4 Fuel Level",
|
||||||
|
213: "LLS 4 Temperature",
|
||||||
|
214: "LLS 5 Fuel Level",
|
||||||
|
215: "LLS 5 Temperature",
|
||||||
|
237: "Network Type",
|
||||||
|
238: "User ID",
|
||||||
|
239: "Ignition",
|
||||||
|
240: "Movement",
|
||||||
|
241: "Active GSM Operator",
|
||||||
|
263: "BT Status",
|
||||||
|
264: "Barcode ID",
|
||||||
|
303: "Instant Movement",
|
||||||
|
327: "UL202-02 Sensor Fuel level",
|
||||||
|
329: "AIN Speed",
|
||||||
|
380: "Digital output 3",
|
||||||
|
381: "Ground Sense",
|
||||||
|
383: "AXL Calibration Status",
|
||||||
|
387: "ISO6709 Coordinates",
|
||||||
|
403: "Driver Name",
|
||||||
|
404: "Driver card license type",
|
||||||
|
405: "Driver Gender",
|
||||||
|
406: "Driver Card ID",
|
||||||
|
407: "Driver card expiration date",
|
||||||
|
408: "Driver Card place of issue",
|
||||||
|
409: "Driver Status Event",
|
||||||
|
451: "BLE RFID #1",
|
||||||
|
452: "BLE RFID #2",
|
||||||
|
453: "BLE RFID #3",
|
||||||
|
454: "BLE RFID #4",
|
||||||
|
455: "BLE Button 1 state #1",
|
||||||
|
456: "BLE Button 1 state #2",
|
||||||
|
457: "BLE Button 1 state #3",
|
||||||
|
458: "BLE Button 1 state #4",
|
||||||
|
459: "BLE Button 2 state #1",
|
||||||
|
460: "BLE Button 2 state #2",
|
||||||
|
461: "BLE Button 2 state #3",
|
||||||
|
462: "BLE Button 2 state #4",
|
||||||
|
483: "UL202-02 Sensor Status",
|
||||||
|
500: "MSP500 vendor name",
|
||||||
|
501: "MSP500 vehicle number",
|
||||||
|
502: "MSP500 speed sensor",
|
||||||
|
622: "Frequency DIN1",
|
||||||
|
623: "Frequency DIN2",
|
||||||
|
636: "UMTS/LTE Cell ID",
|
||||||
|
637: "Wake Reason",
|
||||||
|
10800: "EYE Temperature 1",
|
||||||
|
10801: "EYE Temperature 2",
|
||||||
|
10802: "EYE Temperature 3",
|
||||||
|
10803: "EYE Temperature Liza4",
|
||||||
|
10804: "EYE Humidity 1",
|
||||||
|
10805: "EYE Humidity 2",
|
||||||
|
10806: "EYE Humidity 3",
|
||||||
|
10807: "EYE Humidity 4",
|
||||||
|
10808: "EYE Magnet 1",
|
||||||
|
10809: "EYE Magnet 2",
|
||||||
|
10810: "EYE Magnet 3",
|
||||||
|
10811: "EYE Magnet 4",
|
||||||
|
10812: "EYE Movement 1",
|
||||||
|
10813: "EYE Movement 2",
|
||||||
|
10814: "EYE Movement 3",
|
||||||
|
10815: "EYE Movement 4",
|
||||||
|
10816: "EYE Pitch 1",
|
||||||
|
10817: "EYE Pitch 2",
|
||||||
|
10818: "EYE Pitch 3",
|
||||||
|
10819: "EYE Pitch 4",
|
||||||
|
10820: "EYE Low Battery 1",
|
||||||
|
10821: "EYE Low Battery 2",
|
||||||
|
10822: "EYE Low Battery 3",
|
||||||
|
10823: "EYE Low Battery 4",
|
||||||
|
10824: "EYE Battery Voltage 1",
|
||||||
|
10825: "EYE Battery Voltage 2",
|
||||||
|
10826: "EYE Battery Voltage 3",
|
||||||
|
10827: "EYE Battery Voltage 4",
|
||||||
|
10832: "EYE Roll 1",
|
||||||
|
10833: "EYE Roll 2",
|
||||||
|
10834: "EYE Roll 3",
|
||||||
|
10835: "EYE Roll 4",
|
||||||
|
10836: "EYE Movement count 1",
|
||||||
|
10837: "EYE Movement count 2",
|
||||||
|
10838: "EYE Movement count 3",
|
||||||
|
10839: "EYE Movement count 4",
|
||||||
|
10840: "EYE Magnet count 1",
|
||||||
|
10841: "EYE Magnet count 2",
|
||||||
|
10842: "EYE Magnet count 3",
|
||||||
|
10843: "EYE Magnet count 4",
|
||||||
|
1148: "Connectivity quality",
|
||||||
|
14: "ICCID2",
|
||||||
|
20: "BLE Battery #2",
|
||||||
|
22: "BLE Battery #3",
|
||||||
|
23: "BLE Battery #4",
|
||||||
|
25: "BLE Temperature #1",
|
||||||
|
26: "BLE Temperature #2",
|
||||||
|
27: "BLE Temperature #3",
|
||||||
|
28: "BLE Temperature #4",
|
||||||
|
29: "BLE Battery #1",
|
||||||
|
30: "Number of DTC",
|
||||||
|
31: "Engine Load",
|
||||||
|
32: "Coolant Temperature",
|
||||||
|
33: "Short Fuel Trim",
|
||||||
|
34: "Fuel pressure",
|
||||||
|
35: "Intake MAP",
|
||||||
|
36: "Engine RPM",
|
||||||
|
37: "Vehicle Speed",
|
||||||
|
38: "Timing Advance",
|
||||||
|
39: "Intake Air Temperature",
|
||||||
|
40: "MAF",
|
||||||
|
41: "Throttle Position",
|
||||||
|
42: "Runtime since engine start",
|
||||||
|
43: "Distance Traveled MIL On",
|
||||||
|
44: "Relative Fuel Rail Pressure",
|
||||||
|
45: "Direct Fuel Rail Pressure",
|
||||||
|
46: "Commanded EGR",
|
||||||
|
47: "EGR Error",
|
||||||
|
48: "Fuel Level",
|
||||||
|
49: "Distance Since Codes Clear",
|
||||||
|
50: "Barometic Pressure",
|
||||||
|
51: "Control Module Voltage",
|
||||||
|
52: "Absolute Load Value",
|
||||||
|
53: "Ambient Air Temperature",
|
||||||
|
54: "Time Run With MIL On",
|
||||||
|
55: "Time Since Codes Cleared",
|
||||||
|
56: "Absolute Fuel Rail Pressure",
|
||||||
|
57: "Hybrid battery pack life",
|
||||||
|
58: "Engine Oil Temperature",
|
||||||
|
59: "Fuel injection timing",
|
||||||
|
60: "Fuel Rate",
|
||||||
|
61: "Geofence zone 06",
|
||||||
|
62: "Geofence zone 07",
|
||||||
|
63: "Geofence zone 08",
|
||||||
|
64: "Geofence zone 09",
|
||||||
|
65: "Geofence zone 10",
|
||||||
|
70: "Geofence zone 11",
|
||||||
|
81: "Vehicle Speed",
|
||||||
|
82: "Accelerator Pedal Position",
|
||||||
|
83: "Fuel Consumed",
|
||||||
|
84: "Fuel Level",
|
||||||
|
85: "Engine RPM",
|
||||||
|
86: "BLE Humidity #1",
|
||||||
|
87: "Total Mileage",
|
||||||
|
88: "Geofence zone 12",
|
||||||
|
89: "Fuel level",
|
||||||
|
90: "Door Status",
|
||||||
|
91: "Geofence zone 13",
|
||||||
|
92: "Geofence zone 14",
|
||||||
|
93: "Geofence zone 15",
|
||||||
|
94: "Geofence zone 16",
|
||||||
|
95: "Geofence zone 17",
|
||||||
|
96: "Geofence zone 18",
|
||||||
|
97: "Geofence zone 19",
|
||||||
|
98: "Geofence zone 20",
|
||||||
|
99: "Geofence zone 21",
|
||||||
|
100: "Program Number",
|
||||||
|
101: "Module ID 8B",
|
||||||
|
102: "Engine Worktime",
|
||||||
|
103: "Engine Worktime (counted)",
|
||||||
|
104: "BLE Humidity #2",
|
||||||
|
105: "Total Mileage (counted)",
|
||||||
|
106: "BLE Humidity #3",
|
||||||
|
107: "Fuel Consumed (counted)",
|
||||||
|
108: "BLE Humidity #4",
|
||||||
|
110: "Fuel Rate",
|
||||||
|
111: "AdBlue Level",
|
||||||
|
112: "AdBlue Level",
|
||||||
|
114: "Engine Load",
|
||||||
|
115: "Engine Temperature",
|
||||||
|
118: "Axle 1 Load",
|
||||||
|
119: "Axle 2 Load",
|
||||||
|
120: "Axle 3 Load",
|
||||||
|
121: "Axle 4 Load",
|
||||||
|
122: "Axle 5 Load",
|
||||||
|
123: "Control State Flags",
|
||||||
|
124: "Agricultural Machinery Flags",
|
||||||
|
125: "Harvesting Time",
|
||||||
|
126: "Area of Harvest",
|
||||||
|
127: "Mowing Efficiency",
|
||||||
|
128: "Grain Mown Volume",
|
||||||
|
129: "Grain Moisture",
|
||||||
|
130: "Harvesting Drum RPM",
|
||||||
|
131: "Gap Under Harvesting Drum",
|
||||||
|
132: "Security State Flags",
|
||||||
|
133: "Tachograph Total Vehicle Distance",
|
||||||
|
134: "Trip Distance",
|
||||||
|
135: "Tachograph Vehicle Speed",
|
||||||
|
136: "Tacho Driver Card Presence",
|
||||||
|
137: "Driver 1 States",
|
||||||
|
138: "Driver 2 States",
|
||||||
|
139: "Driver 1 Continuous Driving Time",
|
||||||
|
140: "Driver 2 Continuous Driving Time",
|
||||||
|
141: "Driver 1 Cumulative Break Time",
|
||||||
|
142: "Driver 2 Cumulative Break Time",
|
||||||
|
143: "Driver 1 Selected Activity Duration",
|
||||||
|
144: "Driver 2 Selected Activity Duration",
|
||||||
|
145: "Driver 1 Cumulative Driving Time",
|
||||||
|
146: "Driver 2 Cumulative Driving Time",
|
||||||
|
147: "Driver 1 ID High",
|
||||||
|
148: "Driver 1 ID Low",
|
||||||
|
149: "Driver 2 ID High",
|
||||||
|
150: "Driver 2 ID Low",
|
||||||
|
151: "Battery Temperature",
|
||||||
|
152: "HV Battery Level",
|
||||||
|
153: "Geofence zone 22",
|
||||||
|
154: "Geofence zone 23",
|
||||||
|
155: "Geofence zone 01",
|
||||||
|
156: "Geofence zone 02",
|
||||||
|
157: "Geofence zone 03",
|
||||||
|
158: "Geofence zone 04",
|
||||||
|
159: "Geofence zone 05",
|
||||||
|
160: "DTC Faults",
|
||||||
|
161: "Slope of Arm",
|
||||||
|
162: "Rotation of Arm",
|
||||||
|
163: "Eject of Arm",
|
||||||
|
164: "Horizontal Distance Arm Vehicle",
|
||||||
|
165: "Height Arm Above Ground",
|
||||||
|
166: "Drill RPM",
|
||||||
|
167: "Amount Of Spread Salt Square Meter",
|
||||||
|
168: "Battery Voltage",
|
||||||
|
169: "Amount Of Spread Fine Grained Salt",
|
||||||
|
170: "Amount Of Coarse Grained Salt",
|
||||||
|
171: "Amount Of Spread DiMix",
|
||||||
|
172: "Amount Of Spread Coarse Grained Calcium",
|
||||||
|
173: "Amount Of Spread Calcium Chloride",
|
||||||
|
174: "Amount Of Spread Sodium Chloride",
|
||||||
|
175: "Auto Geofence",
|
||||||
|
176: "Amount Of Spread Magnesium Chloride",
|
||||||
|
177: "Amount Of Spread Gravel",
|
||||||
|
178: "Amount Of Spread Sand",
|
||||||
|
183: "Width Pouring Left",
|
||||||
|
184: "Width Pouring Right",
|
||||||
|
185: "Salt Spreader Working Hours",
|
||||||
|
186: "Distance During Salting",
|
||||||
|
187: "Load Weight",
|
||||||
|
188: "Retarder Load",
|
||||||
|
189: "Cruise Time",
|
||||||
|
190: "Geofence zone 24",
|
||||||
|
191: "Geofence zone 25",
|
||||||
|
192: "Geofence zone 26",
|
||||||
|
193: "Geofence zone 27",
|
||||||
|
194: "Geofence zone 28",
|
||||||
|
195: "Geofence zone 29",
|
||||||
|
196: "Geofence zone 30",
|
||||||
|
197: "Geofence zone 31",
|
||||||
|
198: "Geofence zone 32",
|
||||||
|
208: "Geofence zone 33",
|
||||||
|
209: "Geofence zone 34",
|
||||||
|
216: "Geofence zone 35",
|
||||||
|
217: "Geofence zone 36",
|
||||||
|
218: "Geofence zone 37",
|
||||||
|
219: "Geofence zone 38",
|
||||||
|
220: "Geofence zone 39",
|
||||||
|
221: "Geofence zone 40",
|
||||||
|
222: "Geofence zone 41",
|
||||||
|
223: "Geofence zone 42",
|
||||||
|
224: "Geofence zone 43",
|
||||||
|
225: "Geofence zone 44",
|
||||||
|
226: "Geofence zone 45",
|
||||||
|
227: "Geofence zone 46",
|
||||||
|
228: "Geofence zone 47",
|
||||||
|
229: "Geofence zone 48",
|
||||||
|
230: "Geofence zone 49",
|
||||||
|
231: "Geofence zone 50",
|
||||||
|
232: "CNG Status",
|
||||||
|
233: "CNG Used",
|
||||||
|
234: "CNG Level",
|
||||||
|
235: "Oil Level",
|
||||||
|
236: "Alarm",
|
||||||
|
243: "Green driving event duration",
|
||||||
|
246: "Towing",
|
||||||
|
247: "Crash detection",
|
||||||
|
248: "Immobilizer",
|
||||||
|
249: "Jamming",
|
||||||
|
250: "Trip",
|
||||||
|
251: "Idling",
|
||||||
|
252: "Unplug",
|
||||||
|
253: "Green driving type",
|
||||||
|
254: "Green Driving Value",
|
||||||
|
255: "Over Speeding",
|
||||||
|
256: "VIN",
|
||||||
|
257: "Crash trace data",
|
||||||
|
258: "EcoMaximum",
|
||||||
|
259: "EcoAverage",
|
||||||
|
260: "EcoDuration",
|
||||||
|
270: "BLE Fuel Level #1",
|
||||||
|
273: "BLE Fuel Level #2",
|
||||||
|
276: "BLE Fuel Level #3",
|
||||||
|
279: "BLE Fuel Level #4",
|
||||||
|
281: "Fault Codes",
|
||||||
|
282: "Fault Codes",
|
||||||
|
283: "Driving State",
|
||||||
|
284: "Driving Records",
|
||||||
|
285: "Blood alcohol content",
|
||||||
|
304: "Vehicles Range On Battery",
|
||||||
|
305: "Vehicles Range On Additional Fuel",
|
||||||
|
306: "BLE Fuel Frequency #1",
|
||||||
|
307: "BLE Fuel Frequency #2",
|
||||||
|
308: "BLE Fuel Frequency #3",
|
||||||
|
309: "BLE Fuel Frequency #4",
|
||||||
|
317: "Crash event counter",
|
||||||
|
318: "GNSS Jamming",
|
||||||
|
325: "VIN",
|
||||||
|
331: "BLE 1 Custom #1",
|
||||||
|
332: "BLE 2 Custom #1",
|
||||||
|
333: "BLE 3 Custom #1",
|
||||||
|
334: "BLE 4 Custom #1",
|
||||||
|
335: "BLE Luminosity #1",
|
||||||
|
336: "BLE Luminosity #2",
|
||||||
|
337: "BLE Luminosity #3",
|
||||||
|
338: "BLE Luminosity #4",
|
||||||
|
385: "Beacon",
|
||||||
|
388: "Module ID 17B",
|
||||||
|
389: "OBD OEM Total Mileage",
|
||||||
|
390: "OBD OEM Fuel Level",
|
||||||
|
391: "Private mode",
|
||||||
|
400: "Distance to Next Service",
|
||||||
|
402: "OEM Distance Until Service",
|
||||||
|
411: "OEM Battery charge level",
|
||||||
|
449: "Ignition On Counter",
|
||||||
|
450: "CNG Level Kg",
|
||||||
|
463: "BLE 1 Custom #2",
|
||||||
|
464: "BLE 1 Custom #3",
|
||||||
|
465: "BLE 1 Custom #4",
|
||||||
|
466: "BLE 1 Custom #5",
|
||||||
|
467: "BLE 2 Custom #2",
|
||||||
|
468: "BLE 2 Custom #3",
|
||||||
|
469: "BLE 2 Custom #4",
|
||||||
|
470: "BLE 2 Custom #5",
|
||||||
|
471: "BLE 3 Custom #2",
|
||||||
|
472: "BLE 3 Custom #3",
|
||||||
|
473: "BLE 3 Custom #4",
|
||||||
|
474: "BLE 3 Custom #5",
|
||||||
|
475: "BLE 4 Custom #2",
|
||||||
|
476: "BLE 4 Custom #3",
|
||||||
|
477: "BLE 4 Custom #4",
|
||||||
|
478: "BLE 4 Custom #5",
|
||||||
|
517: "Security State Flags P4",
|
||||||
|
518: "Control State Flags P4",
|
||||||
|
519: "Indicator State Flags P4",
|
||||||
|
520: "Agricultural State Flags P4",
|
||||||
|
521: "Utility State Flags P4",
|
||||||
|
522: "Cistern State Flags P4",
|
||||||
|
540: "Throttle position group",
|
||||||
|
541: "Commanded Equivalence R",
|
||||||
|
542: "Intake MAP 2 bytes",
|
||||||
|
543: "Hybrid System Voltage",
|
||||||
|
544: "Hybrid System Current",
|
||||||
|
548: "Advanced BLE Beacon data",
|
||||||
|
652: "SSF KeyInIgnitionLock",
|
||||||
|
653: "SSF Handbrake Is Active",
|
||||||
|
654: "SSF Front Left Door Open",
|
||||||
|
655: "SSF Front Right Door Open",
|
||||||
|
656: "SSF Rear Left Door Open",
|
||||||
|
657: "SSF Rear Right Door Open",
|
||||||
|
658: "SSF Trunk Door Open",
|
||||||
|
659: "SSF Neutral Gear Active (automatic gear box)",
|
||||||
|
660: "SSF Parking Gear Active (automatic gear box)",
|
||||||
|
661: "SSF Reverse Gear Active",
|
||||||
|
662: "SSF Car Is Closed",
|
||||||
|
755: "OEM Remaining distance",
|
||||||
|
759: "Fuel Type",
|
||||||
|
855: "LNG Used",
|
||||||
|
856: "LNG Used (counted)",
|
||||||
|
857: "LNG Level",
|
||||||
|
858: "LNG Level",
|
||||||
|
859: "Distance from need of service",
|
||||||
|
860: "Distance from last service",
|
||||||
|
861: "Time to next service",
|
||||||
|
862: "Time from need of service",
|
||||||
|
863: "Time from last serivce",
|
||||||
|
864: "Distance to next oil service",
|
||||||
|
865: "Time to next oil service",
|
||||||
|
866: "LVCAN Vehicle Range",
|
||||||
|
867: "LVCAN Total CNG counted",
|
||||||
|
898: "SSF Ignition",
|
||||||
|
899: "SSF Webasto",
|
||||||
|
900: "SSF Engine Working",
|
||||||
|
901: "SSF Standalone Engine",
|
||||||
|
902: "SSF Ready To Drive",
|
||||||
|
903: "SSF Engine Working On CNG",
|
||||||
|
904: "SSF Work Mode",
|
||||||
|
905: "SSF Operator",
|
||||||
|
906: "SSF Interlock",
|
||||||
|
907: "SSF Engine Lock Active",
|
||||||
|
908: "SSF Request To Lock Engine",
|
||||||
|
909: "SSF Roof Open",
|
||||||
|
910: "SSF Footbrake Is Active",
|
||||||
|
911: "SSF Clutch Pushed",
|
||||||
|
912: "SSF Hazard Warning Lights",
|
||||||
|
913: "SSF Engine Cover Open",
|
||||||
|
914: "SSF Charging Wire Plugged",
|
||||||
|
915: "SSF Batttery Charging",
|
||||||
|
916: "SSF Electric Engine State",
|
||||||
|
917: "SSF Car Closed Factory Remote",
|
||||||
|
918: "SSF Factory Alarm Actuated",
|
||||||
|
919: "SSF Factory Alarm Emulated",
|
||||||
|
920: "SSF Signal Close Factory Remote",
|
||||||
|
921: "SSF Signal Open Factory Remote",
|
||||||
|
922: "SSF Rearming Signal",
|
||||||
|
923: "SSF Trunk Door Opened Factory Remote",
|
||||||
|
924: "SSF CAN Module In Sleep",
|
||||||
|
925: "SSF Factory Remote 3x",
|
||||||
|
926: "SSF Factory Armed",
|
||||||
|
927: "SSF Drive Is Active (automatic gear box)",
|
||||||
|
928: "CSF Parking Lights",
|
||||||
|
929: "CSF Dipped Head lights",
|
||||||
|
930: "CSF Full Beam Headlights",
|
||||||
|
931: "CSF Rear Fog Lights",
|
||||||
|
932: "CSF Front Fog Lights",
|
||||||
|
933: "CSF Additional Front Lights",
|
||||||
|
934: "CSF Additional Rear Lights",
|
||||||
|
935: "CSF Light Signal",
|
||||||
|
936: "CSF Air Conditioning",
|
||||||
|
937: "CSF Cruise Control",
|
||||||
|
938: "CSF Automatic Retarder",
|
||||||
|
939: "CSF Manual Retarder",
|
||||||
|
940: "CSF Driver's Seatbelt Fastened",
|
||||||
|
941: "CSF Front Driver's Seatbelt Fastened",
|
||||||
|
942: "CSF Left Driver's Seatbelt Fastened",
|
||||||
|
943: "CSF Right Driver's Seatbelt Fastened",
|
||||||
|
944: "CSF Centre Driver's Seatbelt Fastened",
|
||||||
|
945: "CSF Front Passenger Present",
|
||||||
|
946: "CSF PTO",
|
||||||
|
947: "CSF Front Differential Locked",
|
||||||
|
948: "CSF Rear Differential Locked",
|
||||||
|
949: "CSF Central Differential 4HI Locked",
|
||||||
|
950: "CSF Rear Differential 4LO Locked",
|
||||||
|
951: "CSF Trailer Axle 1 Lift Active",
|
||||||
|
952: "CSF Trailer Axle 2 Lift Active",
|
||||||
|
953: "ISF Check Engine Indicator",
|
||||||
|
954: "ISF ABS Indicator",
|
||||||
|
955: "ISF ESP Indicator",
|
||||||
|
956: "ISF ESP Turned Off",
|
||||||
|
957: "ISF Stop Indicator",
|
||||||
|
958: "ISF Oil Level Indicator",
|
||||||
|
959: "ISF Coolant liquid level",
|
||||||
|
960: "ISF Battery Not Charging Indicator",
|
||||||
|
961: "ISF Handbrake System Indicator",
|
||||||
|
962: "ISF AIRBAG Indicator",
|
||||||
|
963: "ISF EPS Indicator",
|
||||||
|
964: "ISF Warning Indicator",
|
||||||
|
965: "ISF Lights Failure Indicator",
|
||||||
|
966: "ISF Low Tire Pressure Indicator",
|
||||||
|
967: "ISF Wear Of Brake Pads Indicator",
|
||||||
|
968: "ISF Low Fuel Level Indicator",
|
||||||
|
969: "ISF Maintenence required Indicator",
|
||||||
|
970: "ISF Glow Plug Indicator",
|
||||||
|
971: "ISF FAP Indicator",
|
||||||
|
972: "ISF EPC (Electronic Power Control) Indicator",
|
||||||
|
973: "ISF Clogged Engine Oil Filter Indicator",
|
||||||
|
974: "ISF Low Engine Oil Pressure Indicator",
|
||||||
|
975: "ISF Too High Engine Oil Temperature Indicator",
|
||||||
|
976: "ISF Low Coolant Level Indicator",
|
||||||
|
977: "ISF Clogged Hydraulic System Oil filter Indicator",
|
||||||
|
978: "ISF Hydraulic System Low Pressure Indicator",
|
||||||
|
979: "ISF Hydraulic Oil Low Level Indicator",
|
||||||
|
980: "ISF Hydraulic System High Temperature Indicator",
|
||||||
|
981: "ISF Oil Overflow In Hydraulic Chamber Indicator",
|
||||||
|
982: "ISF Clogged Air Filter Indicator",
|
||||||
|
983: "ISF Clogged Fuel Filter Indicator",
|
||||||
|
984: "ISF Water in Fuel Indicator",
|
||||||
|
985: "ISF Clogged Brake System Filter Indicator",
|
||||||
|
986: "ISF Low Washer Fluid Level Indicator",
|
||||||
|
987: "ISF Low AdBlue Level Indicator",
|
||||||
|
988: "ISF Low Trailer Tyre Pressure Indicator",
|
||||||
|
989: "ISF Wear Of Trailer Brake Lining Indicator",
|
||||||
|
990: "ISF High Trailer Brake Temperature Indicator",
|
||||||
|
991: "ISF Incorrect Trailer Pneumatic Supply Indicator",
|
||||||
|
992: "ISF Low CNG Level Indicator",
|
||||||
|
993: "ASF Right Joystick Moved Right Active",
|
||||||
|
994: "ASF Right Joystick Moved Left Active",
|
||||||
|
995: "ASF Right Joystick Moved Forward Active",
|
||||||
|
996: "ASF Right Joystick Moved Back Active",
|
||||||
|
997: "ASF Left Joystick Moved Right Active",
|
||||||
|
998: "ASF Left Joystick Moved Left Active",
|
||||||
|
999: "ASF Left Joystick Moved Forward Active",
|
||||||
|
1000: "ASF Left Joystick Moved Back Active",
|
||||||
|
1001: "ASF First Rear hydraulic",
|
||||||
|
1002: "ASF Second Rear hydraulic",
|
||||||
|
1003: "ASF Third Rear hydraulic",
|
||||||
|
1004: "ASF Fourth Rear hydraulic",
|
||||||
|
1005: "ASF First Front hydraulic",
|
||||||
|
1006: "ASF Second Front hydraulic",
|
||||||
|
1007: "ASF Third Front hydraulic",
|
||||||
|
1008: "ASF Fourth Front hydraulic",
|
||||||
|
1009: "ASF Front Three-point Hitch",
|
||||||
|
1010: "ASF Rear Three-point Hitch",
|
||||||
|
1011: "ASF Front Power Take-off",
|
||||||
|
1012: "ASF Rear Power Take-off",
|
||||||
|
1013: "ASF Mowing Active",
|
||||||
|
1014: "ASF Threshing Active",
|
||||||
|
1015: "ASF Grain Release From Hopper",
|
||||||
|
1016: "ASF Grain Tank Is 100% Full",
|
||||||
|
1017: "ASF Grain Tank Is 70% Full",
|
||||||
|
1018: "ASF Grain Tank Is Opened",
|
||||||
|
1019: "ASF Unloader Drive",
|
||||||
|
1020: "ASF Cleaning Fan Control Turned Off",
|
||||||
|
1021: "ASF Threshing Drum Control Turned Off",
|
||||||
|
1022: "ASF Straw Walker Is Clogged",
|
||||||
|
1023: "ASF Excessive Clearance Under The Threshing Drum",
|
||||||
|
1024: "ASF Low Temperature Of Drive System Hydraulics Less Than 5 Grades",
|
||||||
|
1025: "ASF High Temperature Of Drive System Hydraulics Greater Than 86 Grades",
|
||||||
|
1026: "ASF Ear Auger Speed Below The Norm",
|
||||||
|
1027: "ASF Grain Auger Speed Below The Norm",
|
||||||
|
1028: "ASF Straw Chooper Speed Below The Norm",
|
||||||
|
1029: "ASF Straw Shaker Speed Below The Norm",
|
||||||
|
1030: "ASF Feeder Speed Below The Norm",
|
||||||
|
1031: "ASF Straw Chopper Switched On",
|
||||||
|
1032: "ASF Corn Header Connected",
|
||||||
|
1033: "ASF Grain Header Connected",
|
||||||
|
1034: "ASF Feeder Reverse Switched On",
|
||||||
|
1035: "ASF The Pressure Filter Of The Hydraulic Pump Is Clogged",
|
||||||
|
1036: "USF Spreading",
|
||||||
|
1037: "USF Pouring Chemicals",
|
||||||
|
1038: "USF Conveyor Belt",
|
||||||
|
1039: "USF Salt Spreader's Drive Wheel",
|
||||||
|
1040: "USF Brushes",
|
||||||
|
1041: "USF Vacuum Cleaner",
|
||||||
|
1042: "USF Water Supply",
|
||||||
|
1043: "USF Spreading",
|
||||||
|
1044: "USF Liquid pump",
|
||||||
|
1045: "USF Unloading From The Hopper",
|
||||||
|
1046: "USF Low Salt (Sand) Level In Container Indicator",
|
||||||
|
1047: "USF Low Water Level in Container Indicator",
|
||||||
|
1048: "USF Chemicals",
|
||||||
|
1049: "USF Compressor",
|
||||||
|
1050: "USF Water Valve Is Opened",
|
||||||
|
1051: "USF Cabin Moved Up Status Active",
|
||||||
|
1052: "USF Cabin Moved Down Status Active",
|
||||||
|
1053: "CiSF Section 1 Presence Of Fluid In The Downpipe",
|
||||||
|
1054: "CiSF Section 1 Filled",
|
||||||
|
1055: "CiSF Section 1 Overfilled",
|
||||||
|
1056: "CiSF Section 2 Presence Of Fluid In The Downpipe",
|
||||||
|
1057: "CiSF Section 2 Filled",
|
||||||
|
1058: "CiSF Section 2 Overfilled",
|
||||||
|
1059: "CiSF Section 3 Presence Of Fluid In The Downpipe",
|
||||||
|
1060: "CiSF Section 3 Filled",
|
||||||
|
1061: "CiSF Section 3 Overfilled",
|
||||||
|
1062: "CiSF Section 4 Presence Of Fluid In The Downpipe",
|
||||||
|
1063: "CiSF Section 4 Filled",
|
||||||
|
1064: "CiSF Section 4 Overfilled",
|
||||||
|
1065: "CiSF Section 5 Presence Of Fluid In The Downpipe",
|
||||||
|
1066: "CiSF Section 5 Filled",
|
||||||
|
1067: "CiSF Section 5 Overfilled",
|
||||||
|
1068: "CiSF Section 6 Presence Of Fluid In The Downpipe",
|
||||||
|
1069: "CiSF Section 6 Filled",
|
||||||
|
1070: "CiSF Section 6 Overfilled",
|
||||||
|
1071: "CiSF Section 7 Presence Of Fluid In The Downpipe",
|
||||||
|
1072: "CiSF Section 7 Filled",
|
||||||
|
1073: "CiSF Section 7 Overfilled",
|
||||||
|
1074: "CiSF Section 8 Presence Of Fluid In The Downpipe",
|
||||||
|
1075: "CiSF Section 8 Filled",
|
||||||
|
1076: "CiSF Section 8 Overfilled",
|
||||||
|
1079: "Total Bale Count",
|
||||||
|
1080: "Bale Count",
|
||||||
|
1081: "Cut Bale Count",
|
||||||
|
1082: "Bale Slices",
|
||||||
|
1083: "SSF Engine Working On Dual Fuel",
|
||||||
|
1084: "SSF Engine Working On LPG",
|
||||||
|
1085: "CSF Trailer Connected",
|
||||||
|
1086: "CSF Start Stop System Inactive",
|
||||||
|
1087: "ASF Adapter Pressure Filter Sensor",
|
||||||
|
1088: "ASF Service 2 Required Indicator",
|
||||||
|
1089: "ASF Drain Filter Clogged Indicator",
|
||||||
|
1090: "ASF Section 1 Spraying",
|
||||||
|
1091: "ASF Section 2 Spraying",
|
||||||
|
1092: "ASF Section 3 Spraying",
|
||||||
|
1093: "ASF Section 4 Spraying",
|
||||||
|
1094: "ASF Section 5 Spraying",
|
||||||
|
1095: "ASF Section 6 Spraying",
|
||||||
|
1096: "ASF Section 7 Spraying",
|
||||||
|
1097: "ASF Section 8 Spraying",
|
||||||
|
1098: "ASF Section 9 Spraying",
|
||||||
|
1099: "USF Hydraulics Work Not Permitted",
|
||||||
|
1100: "Total LPG Used",
|
||||||
|
1101: "Total LPG Used Counted",
|
||||||
|
1102: "LPG Level Proc",
|
||||||
|
1103: "LPG Level Liters",
|
||||||
|
1116: "LVCAN MaxRoadSpeed",
|
||||||
|
1117: "LVCAN ExceededRoadSpeed",
|
||||||
|
1151: "OEM Battery State Of Health",
|
||||||
|
1152: "OEM Battery Temperature",
|
||||||
|
1205: "LVCAN RSF SpeedLimitSign",
|
||||||
|
1206: "LVCAN RSF EndOfSpeedLimitSign",
|
||||||
|
1207: "LVCAN RSF SpeedExceeded",
|
||||||
|
1208: "LVCAN RSF TimeSpeedLimitSign",
|
||||||
|
1209: "LVCAN RSF WthrSpeedLimitSign",
|
||||||
|
1412: "Motorcycle Fall Detection",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = LibHelper;
|
module.exports = LibHelper
|
||||||
|
|||||||
@ -35,7 +35,7 @@
|
|||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"mysql2": "^3.15.1",
|
"mysql2": "^3.15.3",
|
||||||
"nanoid": "^3.3.1",
|
"nanoid": "^3.3.1",
|
||||||
"node-cron": "^4.2.1",
|
"node-cron": "^4.2.1",
|
||||||
"nodemailer": "^6.7.2",
|
"nodemailer": "^6.7.2",
|
||||||
|
|||||||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@ -72,8 +72,8 @@ importers:
|
|||||||
specifier: ^2.18.1
|
specifier: ^2.18.1
|
||||||
version: 2.18.1
|
version: 2.18.1
|
||||||
mysql2:
|
mysql2:
|
||||||
specifier: ^3.15.1
|
specifier: ^3.15.3
|
||||||
version: 3.15.1
|
version: 3.15.3
|
||||||
nanoid:
|
nanoid:
|
||||||
specifier: ^3.3.1
|
specifier: ^3.3.1
|
||||||
version: 3.3.11
|
version: 3.3.11
|
||||||
@ -1332,8 +1332,8 @@ packages:
|
|||||||
msgpackr@1.11.5:
|
msgpackr@1.11.5:
|
||||||
resolution: {integrity: sha512-UjkUHN0yqp9RWKy0Lplhh+wlpdt9oQBYgULZOiFhV3VclSF1JnSQWZ5r9gORQlNYaUKQoR8itv7g7z1xDDuACA==}
|
resolution: {integrity: sha512-UjkUHN0yqp9RWKy0Lplhh+wlpdt9oQBYgULZOiFhV3VclSF1JnSQWZ5r9gORQlNYaUKQoR8itv7g7z1xDDuACA==}
|
||||||
|
|
||||||
mysql2@3.15.1:
|
mysql2@3.15.3:
|
||||||
resolution: {integrity: sha512-WZMIRZstT2MFfouEaDz/AGFnGi1A2GwaDe7XvKTdRJEYiAHbOrh4S3d8KFmQeh11U85G+BFjIvS1Di5alusZsw==}
|
resolution: {integrity: sha512-FBrGau0IXmuqg4haEZRBfHNWB5mUARw6hNwPDXXGg0XzVJ50mr/9hb267lvpVMnhZ1FON3qNd4Xfcez1rbFwSg==}
|
||||||
engines: {node: '>= 8.0'}
|
engines: {node: '>= 8.0'}
|
||||||
|
|
||||||
mysql@2.18.1:
|
mysql@2.18.1:
|
||||||
@ -3501,7 +3501,7 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
msgpackr-extract: 3.0.3
|
msgpackr-extract: 3.0.3
|
||||||
|
|
||||||
mysql2@3.15.1:
|
mysql2@3.15.3:
|
||||||
dependencies:
|
dependencies:
|
||||||
aws-ssl-profiles: 1.1.2
|
aws-ssl-profiles: 1.1.2
|
||||||
denque: 2.1.0
|
denque: 2.1.0
|
||||||
|
|||||||
8
routes/listen.js
Normal file
8
routes/listen.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
const ListenController = require("../controllers/ListenController")
|
||||||
|
const { PATH_URL } = process.env
|
||||||
|
|
||||||
|
exports.use = function (app) {
|
||||||
|
// LISTEN
|
||||||
|
app.post(PATH_URL + "/listen/gps", ListenController.gps)
|
||||||
|
app.post(PATH_URL + "/listen/teltonika", ListenController.teltonika)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user