Dispositivos sempre ficam lotados em alguma companhia específica. Ela fica identificada no arquivo device:
{// documento device gravado com o nome "<imei>" na collection de devices
"imei": "<imei>"
,"deviceOf": "<companyId>"
const isBot = require('./../helpers/isBot.js').isBot | |
const dummyPage = [ | |
'<!doctype html> <html lang="en"> <head>' | |
,'</head> <body>' | |
,'</body> </html>' | |
] | |
const defTitle = 'Chats to follow'; | |
const defLogo = 'https://unnon.com/ogimg.png'; | |
const app_id = "267524633679818" |
function oldFix (newdata, previous_position, imei) { | |
const checkValidDate = function (date) { | |
const parsed = new Date(date); | |
if (!parsed) { return null }; | |
const oneDayInMilliseconds = 24 * 60 * 60 * 1000; | |
const threeMonthsAgo = new Date(Date.now() - 3 * 30 * oneDayInMilliseconds); | |
const oneDayInFuture = new Date(Date.now() + oneDayInMilliseconds); | |
const isFromPast = parsed <= threeMonthsAgo; | |
const isFromFuture = parsed >= oneDayInFuture; |
// Shorten names | |
// types: | |
export const STRING = "STRING"; | |
export const BYTES = "BYTES"; | |
export const INTEGER = "INTEGER"; | |
export const FLOAT = "FLOAT"; | |
export const NUMERIC = "NUMERIC"; | |
export const BOOLEAN = "BOOLEAN"; | |
export const TIMESTAMP = "TIMESTAMP"; | |
export const DATE = "DATE"; |
class PositionsWriter { | |
static MIN_DISTANCE = 0.02; | |
static PARKED_MIN_DURATION = 120; | |
constructor(device, debug = false) { | |
this.device = device; | |
this.debug = debug; | |
this.events = []; | |
this.positions = []; | |
this.position = null; |
const https = require('https'); | |
const http = require('http'); | |
const getJSON = (options, onResult) => { | |
console.log('rest::getJSON'); | |
const port = options.port == 443 ? https : http; | |
let output = ''; | |
const req = port.request(options, (res) => { |
let yamldata = { | |
t: newdata.t | |
,dt: newdata.dt | |
,ft: newdata.ft | |
,spd: newdata.spd | |
,lat: newdata.lat || 0 | |
,lng: newdata.lng || 0 | |
,ang: newdata.ang | |
,stp: newdata.stp | |
,ign: newdata.ign |
/* UTILS AND CONSTANTS*/ | |
const SPEED_MULTIPLIER = 1.852; | |
const DISTANCE_MULTIPLIER = 111.045; | |
const SETTINGS = { | |
"default_object_online_timeout": 5 | |
,"valid_by_avg_speed": false | |
,"min_moving_speed": 6 | |
,"addon.device_tracker_app_login": false |
Dispositivos sempre ficam lotados em alguma companhia específica. Ela fica identificada no arquivo device:
{// documento device gravado com o nome "<imei>" na collection de devices
"imei": "<imei>"
,"deviceOf": "<companyId>"
// [bucket]/<userID>/invoices/invoiceID.json | |
{ | |
"invoiceID": "Number" | |
,"by": "UID" | |
,"createdAt": "Date" | |
,"legacyLogin": "String" | |
,"chargeType": "String[event|recurrent|occasional]" | |
,"userToCharge": { | |
"name": "String" | |
,"CPFCNPJ": "String" |
Pegar todo o cache separado por servidor:
https://us-central1-tracker-net.cloudfunctions.net/updateimeis?servernodes=true
Todos os dispositivos separados por servidor: {"imei":"866551038xxxxxx","t":1694968580764,"prot":"ev02","users":["zecarevenda","zecaurubu","3632400600xxxxxx"]}
t é o tempo epoch da última conexão. prot é o protocolo users usuários em ordem.