queclink-parser 1.9.12 → 1.9.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/example.js +110 -106
- package/package.json +1 -1
- package/src/gv310lau.js +173 -241
- package/src/gv57cg.js +4 -4
- package/src/gv58lau.js +837 -1231
- package/src/index.js +11 -2
- package/src/messages/es.json +11 -10
- package/src/utils.js +274 -24
package/src/index.js
CHANGED
|
@@ -250,8 +250,10 @@ const parseCommand = data => {
|
|
|
250
250
|
const do5 = `${outputs[4]},${prevDurations['5']},${prevToggles['5']}`
|
|
251
251
|
const longOperation = data.longOperation || false ? '1' : '0'
|
|
252
252
|
const dosReport = data.dosReport || false ? '1' : '0'
|
|
253
|
-
if (data.device_serie === 'GV' &&
|
|
253
|
+
if (data.device_serie === 'GV' && password === 'gv57cg') {
|
|
254
254
|
command = `AT+GTDOS=${password},,,1,${do1},,,${dosReport},0,5,,,,${serialId}$`
|
|
255
|
+
} else if (data.device_serie === 'GV' && password === 'gv58lau') {
|
|
256
|
+
command = `AT+GTDOS=${password},0,3,1,${do1},0,,2,${do2},0,,3,${do3},0,,0,,,0${dosReport},,,FFFF$`
|
|
255
257
|
} else if (data.device_serie === 'GV') {
|
|
256
258
|
command = `AT+GTOUT=${password},${do1},${do2},${do3},${do4},${longOperation},${dosReport},,,${serialId}$`
|
|
257
259
|
} else if (data.device_serie === 'GMT') {
|
|
@@ -307,9 +309,16 @@ const parseCommand = data => {
|
|
|
307
309
|
mode = /on(E)?/.test(state) ? 3 : 0
|
|
308
310
|
const alarmId = data.alarmId || 0
|
|
309
311
|
const sensorId = data.sensorId || '0000000000000000'
|
|
312
|
+
const index = data.sensor_index || 2
|
|
313
|
+
const sensorType = utils.bleTempHumSensors[data.sensor_type]
|
|
310
314
|
const minTemp = data.minTemp || 0
|
|
311
315
|
const maxTemp = data.maxTemp || 0
|
|
312
|
-
|
|
316
|
+
if (sensorType === '0') {
|
|
317
|
+
command = `AT+GTTMP=${password},${alarmId},${mode},${sensorId},,,${minTemp},${maxTemp},,,2,10,,,0,0,0,0,,,,,${serialId}$`
|
|
318
|
+
} else {
|
|
319
|
+
command = `AT+GTBAS=${password},${index},6,${sensorType},,${sensorId},83F,,2400,,${mode},${minTemp},${maxTemp},2,,,,,,,,0,0,0,0,,,${serialId}$`
|
|
320
|
+
}
|
|
321
|
+
|
|
313
322
|
} else if (/^copiloto_temp_alarm_(on|off)(E)?$/.test(data.instruction)) {
|
|
314
323
|
// AT+GTDAT=gv300w,2,,>CMD3005,60,18,0,5,-3<,0,,,,FFFF$
|
|
315
324
|
// Temperature Alarm
|
package/src/messages/es.json
CHANGED
|
@@ -230,23 +230,23 @@
|
|
|
230
230
|
"GTBDS": "Accesorio bluetooth desconectado",
|
|
231
231
|
"GTBAA": {
|
|
232
232
|
"00": "Accesorio con batería baja",
|
|
233
|
-
"01": "Temperatura
|
|
234
|
-
"02": "Temperatura
|
|
235
|
-
"03": "
|
|
233
|
+
"01": "Temperatura bajo el rango definido ()",
|
|
234
|
+
"02": "Temperatura sobre el rango definido ()",
|
|
235
|
+
"03": "Regreso a temperatura dentro de rango ()",
|
|
236
236
|
"04": "Botón presionado",
|
|
237
|
-
"07": "Bajo nivel de humedad",
|
|
238
|
-
"08": "Alto nivel de humedad",
|
|
239
|
-
"09": "
|
|
237
|
+
"07": "Bajo nivel de humedad ()",
|
|
238
|
+
"08": "Alto nivel de humedad ()",
|
|
239
|
+
"09": "Regreso a humedad dentro de rango ()",
|
|
240
240
|
"0A": "Evento de ángulo",
|
|
241
241
|
"0C": "Evento de magneto",
|
|
242
|
-
"0E": "
|
|
243
|
-
"0F": "
|
|
244
|
-
"10": "
|
|
242
|
+
"0E": "Neumático con presión baja ()",
|
|
243
|
+
"0F": "Neumático con presión alta ()",
|
|
244
|
+
"10": "Regreso a presión de neumáticos dentro de rango ()",
|
|
245
245
|
"11": "No se ha detectado accesorio bluetooth",
|
|
246
246
|
"12": "Se ha detectado un accesorio bluetooth",
|
|
247
247
|
"13": "Puerta abierta",
|
|
248
248
|
"14": "Puerta cerrada",
|
|
249
|
-
"15": "
|
|
249
|
+
"15": "Relay bluetooth __"
|
|
250
250
|
},
|
|
251
251
|
"GTBID": "Se ha detectado baliza bluetooth",
|
|
252
252
|
"GTLBA": {
|
|
@@ -283,6 +283,7 @@
|
|
|
283
283
|
"GTJDC": "Config: detección de jamming",
|
|
284
284
|
"GTASC": "Config: autocalibración de acelerómetro",
|
|
285
285
|
"GTOUT": "Config: salidas digitales",
|
|
286
|
+
"GTDOS": "Config: salidas digitales",
|
|
286
287
|
"GTDIS": "Config: entradas digitales",
|
|
287
288
|
"GTGDO": "Config: salidas digitales graduales",
|
|
288
289
|
"GTROS": "Config: restricción de salidas",
|
package/src/utils.js
CHANGED
|
@@ -218,6 +218,17 @@ const bluetoothModels = {
|
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
/*
|
|
222
|
+
BLE Temp & Hum sensors
|
|
223
|
+
*/
|
|
224
|
+
const bleTempHumSensors = {
|
|
225
|
+
'AC100': '0',
|
|
226
|
+
'WTH300': '2',
|
|
227
|
+
'RHT ELA': '3',
|
|
228
|
+
'WMS301': '4',
|
|
229
|
+
'WTH301': '5'
|
|
230
|
+
}
|
|
231
|
+
|
|
221
232
|
/*
|
|
222
233
|
Possible Beacon ID Models
|
|
223
234
|
*/
|
|
@@ -234,7 +245,19 @@ const beaconModels = {
|
|
|
234
245
|
const beaconTypes = {
|
|
235
246
|
'0': 'ID',
|
|
236
247
|
'1': 'iBeacon',
|
|
237
|
-
'2': 'Eddystone'
|
|
248
|
+
'2': 'Eddystone',
|
|
249
|
+
'3': 'Queclink'
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/*
|
|
253
|
+
Possible Relay BLE config results
|
|
254
|
+
*/
|
|
255
|
+
const relayBLEResults = {
|
|
256
|
+
0: 'Success',
|
|
257
|
+
1: 'Error connecting',
|
|
258
|
+
2: 'Incorrect BLE password',
|
|
259
|
+
3: 'Error updating BLE password',
|
|
260
|
+
4: 'Error'
|
|
238
261
|
}
|
|
239
262
|
|
|
240
263
|
/*
|
|
@@ -293,9 +316,11 @@ const latamMcc = {
|
|
|
293
316
|
736: 'Bolivia',
|
|
294
317
|
740: 'Ecuador',
|
|
295
318
|
744: 'Paraguay',
|
|
296
|
-
748: 'Uruguay'
|
|
319
|
+
748: 'Uruguay',
|
|
320
|
+
default: 'Desconocido'
|
|
297
321
|
}
|
|
298
322
|
|
|
323
|
+
|
|
299
324
|
/*
|
|
300
325
|
Gets the Queclink Device Type
|
|
301
326
|
*/
|
|
@@ -363,7 +388,7 @@ const checkGps = (lng, lat) => {
|
|
|
363
388
|
included in the report
|
|
364
389
|
*/
|
|
365
390
|
const includeSatellites = positionAppendMask => {
|
|
366
|
-
return
|
|
391
|
+
return nHexDigit(hex2bin(positionAppendMask), 4)[3] == '1'
|
|
367
392
|
}
|
|
368
393
|
|
|
369
394
|
/*
|
|
@@ -371,19 +396,23 @@ const includeSatellites = positionAppendMask => {
|
|
|
371
396
|
included in the report
|
|
372
397
|
*/
|
|
373
398
|
const includeGnssTrigger = positionAppendMask => {
|
|
374
|
-
return
|
|
399
|
+
return nHexDigit(hex2bin(positionAppendMask), 4)[2] == '1'
|
|
375
400
|
}
|
|
376
401
|
|
|
377
402
|
/*
|
|
378
|
-
Returns if
|
|
379
|
-
|
|
403
|
+
Returns if the Status is
|
|
404
|
+
included in the report
|
|
380
405
|
*/
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
let statusInfo = parseInt(positionAppendMask) > 3
|
|
406
|
+
const includeStatus = positionAppendMask => {
|
|
407
|
+
return nHexDigit(hex2bin(positionAppendMask), 4)[1] == '1'
|
|
408
|
+
}
|
|
385
409
|
|
|
386
|
-
|
|
410
|
+
/*
|
|
411
|
+
Returns if the GNNS Accuracy is
|
|
412
|
+
included in the report
|
|
413
|
+
*/
|
|
414
|
+
const includeGnnsAccuracy = positionAppendMask => {
|
|
415
|
+
return nHexDigit(hex2bin(positionAppendMask), 4)[0] == '1'
|
|
387
416
|
}
|
|
388
417
|
|
|
389
418
|
/*
|
|
@@ -581,7 +610,7 @@ const getMNC = (countryData, opData) => {
|
|
|
581
610
|
operator = 'Desconocido'
|
|
582
611
|
}
|
|
583
612
|
return {
|
|
584
|
-
country: latamMcc[mcc], mnc: mnc, operator: operator
|
|
613
|
+
country: latamMcc[mcc] || latamMcc.default, mnc: mnc, operator: operator
|
|
585
614
|
}
|
|
586
615
|
}
|
|
587
616
|
|
|
@@ -601,7 +630,7 @@ const parseCanData = (data, key) => {
|
|
|
601
630
|
case 'ignitionKey':
|
|
602
631
|
return (data === '0' ? 'ignition_off' : data === '1' ? 'ignition_on' : data === '2' ? 'engine_on' : null)
|
|
603
632
|
case 'totalDistance':
|
|
604
|
-
if (data.slice(0,1) === 'H') {
|
|
633
|
+
if (data.slice(0, 1) === 'H') {
|
|
605
634
|
return hToKm(data)
|
|
606
635
|
} else {
|
|
607
636
|
return data
|
|
@@ -619,7 +648,7 @@ const parseCanData = (data, key) => {
|
|
|
619
648
|
case 'tachographDrivingDirection':
|
|
620
649
|
return data === '0' ? 'forward' : 'backward'
|
|
621
650
|
case 'adBlueLevel':
|
|
622
|
-
if(['P','L'].includes(data.slice(0,1))) {
|
|
651
|
+
if (['P', 'L'].includes(data.slice(0, 1))) {
|
|
623
652
|
return parseFloat(parseFloat(data.slice(1)).toFixed(2))
|
|
624
653
|
} else {
|
|
625
654
|
return parseFloat(parseFloat(data).toFixed(2))
|
|
@@ -672,7 +701,7 @@ const getCanData = (parsedData, ix) => {
|
|
|
672
701
|
vin: parsedData[ix + 2] ? parsedData[ix + 2] : null,
|
|
673
702
|
ignitionKey: parsedData[ix + 3] ? parseCanData(parsedData[ix + 3], 'ignitionKey') : null,
|
|
674
703
|
totalDistance: parsedData[ix + 4] ? parseCanData(parsedData[ix + 4], 'totalDistance') : null,
|
|
675
|
-
totalDistanceUnit: parsedData[ix + 4] ? parsedData[ix + 4].slice(0,1) === 'H' ? 'km' : 'I' : null,
|
|
704
|
+
totalDistanceUnit: parsedData[ix + 4] ? parsedData[ix + 4].slice(0, 1) === 'H' ? 'km' : 'I' : null,
|
|
676
705
|
fuelUsed: parsedData[ix + 5] ? parseFloat(parsedData[ix + 5]) : null, // float
|
|
677
706
|
rpm: parsedData[ix + 6] ? parseInt(parsedData[ix + 6], 10) : null, // int
|
|
678
707
|
speed: parsedData[ix + 7] ? parseFloat(parsedData[ix + 7]) : null,
|
|
@@ -680,7 +709,7 @@ const getCanData = (parsedData, ix) => {
|
|
|
680
709
|
parsedData[ix + 8] ? parseInt(parsedData[ix + 8], 10) : null,
|
|
681
710
|
fuelConsumption: parsedData[ix + 9] ? parseCanData(parsedData[ix + 9], 'fuelConsumption') : null,
|
|
682
711
|
fuelLevel: parsedData[ix + 10] ? parseFloat(parsedData[ix + 10].slice(1)) : null,
|
|
683
|
-
fuelLevelUnit: parsedData[ix + 10] ? parsedData[ix + 10].slice(0,1) === 'P' ? '%' : 'L' : null,
|
|
712
|
+
fuelLevelUnit: parsedData[ix + 10] ? parsedData[ix + 10].slice(0, 1) === 'P' ? '%' : 'L' : null,
|
|
684
713
|
range: parsedData[ix + 11] ? parseCanData(parsedData[ix + 11], 'range') : null,
|
|
685
714
|
acceleratorPressure:
|
|
686
715
|
parsedData[ix + 12] ? parseFloat(parsedData[ix + 12]) : null,
|
|
@@ -804,7 +833,7 @@ const getCanData = (parsedData, ix) => {
|
|
|
804
833
|
},
|
|
805
834
|
adBlueLevel:
|
|
806
835
|
parsedData[ix + 25] ? parseCanData(parsedData[ix + 25], 'adBlueLevel') : null,
|
|
807
|
-
adBlueLevelUnit: parsedData[ix + 25] ? parsedData[ix + 25].slice(0,1) === 'P' ? '%' : 'L' ? 'L': '
|
|
836
|
+
adBlueLevelUnit: parsedData[ix + 25] ? parsedData[ix + 25].slice(0, 1) === 'P' ? '%' : 'L' ? 'L' : '%' : null,
|
|
808
837
|
axleWeight1: parsedData[ix + 26] ? parseInt(parsedData[ix + 26]) : null,
|
|
809
838
|
axleWeight3: parsedData[ix + 27] ? parseInt(parsedData[ix + 27]) : null,
|
|
810
839
|
axleWeight4: parsedData[ix + 28] ? parseInt(parsedData[ix + 28]) : null,
|
|
@@ -845,14 +874,14 @@ const getCanData = (parsedData, ix) => {
|
|
|
845
874
|
? expansionBin[2] === '1'
|
|
846
875
|
: null,
|
|
847
876
|
batteryIndicator: expansionBin ? expansionBin[3] === '1' : null,
|
|
848
|
-
|
|
877
|
+
brakeSystemFailureIndicator: expansionBin
|
|
849
878
|
? expansionBin[4] === '1'
|
|
850
879
|
: null,
|
|
851
880
|
oilPressureIndicator: expansionBin ? expansionBin[5] === '1' : null,
|
|
852
881
|
engineHotIndicator: expansionBin ? expansionBin[6] === '1' : null,
|
|
853
882
|
ABSFailureIndicator: expansionBin ? expansionBin[7] === '1' : null,
|
|
854
883
|
checkEngineIndicator: expansionBin ? expansionBin[9] === '1' : null,
|
|
855
|
-
|
|
884
|
+
airbagsIndicator: expansionBin ? expansionBin[10] === '1' : null,
|
|
856
885
|
serviceCallIndicator: expansionBin
|
|
857
886
|
? expansionBin[11] === '1'
|
|
858
887
|
: null,
|
|
@@ -865,6 +894,166 @@ const getCanData = (parsedData, ix) => {
|
|
|
865
894
|
}
|
|
866
895
|
}
|
|
867
896
|
|
|
897
|
+
|
|
898
|
+
/*
|
|
899
|
+
Get Bluetooth data
|
|
900
|
+
*/
|
|
901
|
+
const getBleData = (parsedData, btIndex) => {
|
|
902
|
+
let btDevices = []
|
|
903
|
+
let cnt = btIndex + 1
|
|
904
|
+
let btNum = parsedData[btIndex] !== '' ? parseInt(parsedData[btIndex]) : 1
|
|
905
|
+
|
|
906
|
+
for (let c = 0; c < btNum; c++) {
|
|
907
|
+
if (!['FE', 'FF'].includes(parsedData[cnt])) {
|
|
908
|
+
let appendMask = nHexDigit(hex2bin(parsedData[cnt + 4]), 16)
|
|
909
|
+
let aNameIx = cnt + 4 + parseInt(appendMask[15])
|
|
910
|
+
let aMacIx = aNameIx + parseInt(appendMask[14])
|
|
911
|
+
let aStatIx = aMacIx + parseInt(appendMask[13])
|
|
912
|
+
let aBatIx = aStatIx + parseInt(appendMask[12])
|
|
913
|
+
let aTmpIx = aBatIx + parseInt(appendMask[11])
|
|
914
|
+
let aHumIx = aTmpIx + parseInt(appendMask[10])
|
|
915
|
+
let ioIx = aHumIx + parseInt(appendMask[8])
|
|
916
|
+
let aEvIx = appendMask[8] === '1' && appendMask[7] === '1'
|
|
917
|
+
? ioIx + 3 : ioIx + parseInt(appendMask[7])
|
|
918
|
+
let pressIx = appendMask[7] === '1' && appendMask[6] === '1'
|
|
919
|
+
? aEvIx + 2 : aEvIx + parseInt(appendMask[6])
|
|
920
|
+
let timeIx = pressIx + parseInt(appendMask[5])
|
|
921
|
+
let eTmpIx = timeIx + parseInt(appendMask[4])
|
|
922
|
+
let magIx = eTmpIx + parseInt(appendMask[3])
|
|
923
|
+
let aBatpIx = appendMask[3] === '1' && appendMask[2] === '1'
|
|
924
|
+
? magIx + 3 : magIx + parseInt(appendMask[2])
|
|
925
|
+
let relIx = aBatpIx + parseInt(appendMask[1])
|
|
926
|
+
|
|
927
|
+
btDevices.push({
|
|
928
|
+
index: parsedData[cnt],
|
|
929
|
+
type: bluetoothAccessories[parsedData[cnt + 1]],
|
|
930
|
+
model:
|
|
931
|
+
parsedData[cnt + 2] !== ''
|
|
932
|
+
? bluetoothModels[parsedData[cnt + 1]][parsedData[cnt + 2]]
|
|
933
|
+
: null,
|
|
934
|
+
appendMask: parsedData[cnt + 4],
|
|
935
|
+
name:
|
|
936
|
+
parsedData[aNameIx] !== '' && appendMask[15] === '1'
|
|
937
|
+
? parsedData[aNameIx]
|
|
938
|
+
: null,
|
|
939
|
+
mac:
|
|
940
|
+
parsedData[aMacIx] !== '' && appendMask[14] === '1'
|
|
941
|
+
? parsedData[aMacIx]
|
|
942
|
+
: null,
|
|
943
|
+
status:
|
|
944
|
+
parsedData[aStatIx] !== '' && appendMask[13] === '1'
|
|
945
|
+
? parseInt(parsedData[aStatIx])
|
|
946
|
+
: null,
|
|
947
|
+
batteryLevel:
|
|
948
|
+
parsedData[aBatIx] !== '' && appendMask[12] === '1'
|
|
949
|
+
? parseInt(parsedData[aBatIx])
|
|
950
|
+
: null,
|
|
951
|
+
batteryPercentage:
|
|
952
|
+
parsedData[aBatpIx] !== '' && appendMask[2] === '1'
|
|
953
|
+
? parseFloat(parsedData[aBatpIx])
|
|
954
|
+
: null,
|
|
955
|
+
accessoryData: {
|
|
956
|
+
rawData: parsedData[cnt + 3] !== '' ? parsedData[cnt + 3] : null,
|
|
957
|
+
temperature:
|
|
958
|
+
parsedData[aTmpIx] !== '' && appendMask[11] === '1'
|
|
959
|
+
? parseInt(parsedData[aTmpIx])
|
|
960
|
+
: null,
|
|
961
|
+
humidity:
|
|
962
|
+
parsedData[aHumIx] !== '' && appendMask[10] === '1'
|
|
963
|
+
? parseInt(parsedData[aHumIx])
|
|
964
|
+
: null,
|
|
965
|
+
outputStatus:
|
|
966
|
+
parsedData[ioIx] !== '' && appendMask[8] === '1'
|
|
967
|
+
? parsedData[ioIx]
|
|
968
|
+
: null,
|
|
969
|
+
inputStatus:
|
|
970
|
+
parsedData[ioIx + 1] !== '' && appendMask[8] === '1'
|
|
971
|
+
? parsedData[ioIx + 1]
|
|
972
|
+
: null,
|
|
973
|
+
analogInputStatus:
|
|
974
|
+
parsedData[ioIx + 2] !== '' && appendMask[8] === '1'
|
|
975
|
+
? parsedData[ioIx + 2]
|
|
976
|
+
: null,
|
|
977
|
+
event:
|
|
978
|
+
parsedData[aEvIx] !== '' && appendMask[7] === '1'
|
|
979
|
+
? parseInt(parsedData[aEvIx])
|
|
980
|
+
: null,
|
|
981
|
+
tirePresure:
|
|
982
|
+
parsedData[pressIx] !== '' && appendMask[6] === '1'
|
|
983
|
+
? parseInt(parsedData[pressIx])
|
|
984
|
+
: null,
|
|
985
|
+
timestamp:
|
|
986
|
+
parsedData[timeIx] !== '' && appendMask[5] === '1'
|
|
987
|
+
? parseDate(parsedData[timeIx])
|
|
988
|
+
: null,
|
|
989
|
+
enhancedTemperature:
|
|
990
|
+
parsedData[eTmpIx] !== '' && appendMask[4] === '1'
|
|
991
|
+
? parseFloat(parsedData[eTmpIx])
|
|
992
|
+
: null,
|
|
993
|
+
magDevice: {
|
|
994
|
+
id:
|
|
995
|
+
parsedData[magIx] !== '' && appendMask[3] === '1'
|
|
996
|
+
? parsedData[magIx]
|
|
997
|
+
: null,
|
|
998
|
+
eventCounter:
|
|
999
|
+
parsedData[magIx + 1] !== '' && appendMask[3] === '1'
|
|
1000
|
+
? parseInt(parsedData[magIx + 1])
|
|
1001
|
+
: null,
|
|
1002
|
+
magnetState:
|
|
1003
|
+
parsedData[magIx + 2] !== '' && appendMask[3] === '1'
|
|
1004
|
+
? parseInt(parsedData[magIx + 2])
|
|
1005
|
+
: null
|
|
1006
|
+
},
|
|
1007
|
+
relay: {
|
|
1008
|
+
state:
|
|
1009
|
+
parsedData[relIx] !== '' && appendMask[1] === '1'
|
|
1010
|
+
? parseInt(parsedData[relIx])
|
|
1011
|
+
: null
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
})
|
|
1015
|
+
cnt = relIx + 1
|
|
1016
|
+
} else {
|
|
1017
|
+
let appendMask = nHexDigit(hex2bin(parsedData[cnt + 3]), 8)
|
|
1018
|
+
let aMacIx = cnt + 3 + parseInt(appendMask[6])
|
|
1019
|
+
let aBatIx = aMacIx + parseInt(appendMask[4])
|
|
1020
|
+
let aSigIx = aBatIx + parseInt(appendMask[1])
|
|
1021
|
+
let bTypeIx = aSigIx + parseInt(appendMask[0])
|
|
1022
|
+
|
|
1023
|
+
btDevices.push({
|
|
1024
|
+
index: parsedData[cnt],
|
|
1025
|
+
type: beaconTypes[parsedData[cnt + 1]],
|
|
1026
|
+
model: parsedData[cnt + 2] !== ''
|
|
1027
|
+
? beaconModels[parsedData[cnt + 2]]
|
|
1028
|
+
: null,
|
|
1029
|
+
appendMask: parsedData[cnt + 3],
|
|
1030
|
+
mac:
|
|
1031
|
+
parsedData[aMacIx] !== '' && appendMask[6] === '1'
|
|
1032
|
+
? parsedData[aMacIx]
|
|
1033
|
+
: null,
|
|
1034
|
+
batteryLevel:
|
|
1035
|
+
parsedData[aBatIx] !== '' && appendMask[4] === '1'
|
|
1036
|
+
? parseInt(parsedData[aBatIx])
|
|
1037
|
+
: null,
|
|
1038
|
+
SignalStrength:
|
|
1039
|
+
parsedData[aSigIx] !== '' && appendMask[1] === '1'
|
|
1040
|
+
? parseInt(parsedData[aSigIx])
|
|
1041
|
+
: null,
|
|
1042
|
+
beaconType:
|
|
1043
|
+
parsedData[bTypeIx] !== '' && appendMask[0] === '1'
|
|
1044
|
+
? parseInt(parsedData[bTypeIx])
|
|
1045
|
+
: null,
|
|
1046
|
+
beaconData:
|
|
1047
|
+
parsedData[bTypeIx + 1] !== '' && appendMask[0] === '1'
|
|
1048
|
+
? parseInt(parsedData[bTypeIx + 1])
|
|
1049
|
+
: null,
|
|
1050
|
+
})
|
|
1051
|
+
cnt = bTypeIx + 1 + parseInt(appendMask[1])
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
return btDevices
|
|
1055
|
+
}
|
|
1056
|
+
|
|
868
1057
|
/*
|
|
869
1058
|
Gets the alarm type
|
|
870
1059
|
*/
|
|
@@ -1264,7 +1453,7 @@ const getAlarm = (command, report, extra = false) => {
|
|
|
1264
1453
|
magnitude: Number(
|
|
1265
1454
|
Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2)).toFixed(2)
|
|
1266
1455
|
).toString(),
|
|
1267
|
-
xyz: {x: x, y: y, z: z},
|
|
1456
|
+
xyz: { x: x, y: y, z: z },
|
|
1268
1457
|
message: messages[command][report[1]]
|
|
1269
1458
|
}
|
|
1270
1459
|
} else if (command === 'GTCRA') {
|
|
@@ -1369,10 +1558,67 @@ const getAlarm = (command, report, extra = false) => {
|
|
|
1369
1558
|
} else if (command === 'GTBDS') {
|
|
1370
1559
|
return { type: 'Bluetooth_Disonnected', message: messages[command] }
|
|
1371
1560
|
} else if (command === 'GTBAA') {
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1561
|
+
if (['01', '02', '03'].includes(report)) {
|
|
1562
|
+
const number = parseInt(extra[0])
|
|
1563
|
+
const mac = extra[1]
|
|
1564
|
+
const temperature = extra[2].enhancedTemperature ? extra[2].enhancedTemperature : extra[2].temperature
|
|
1565
|
+
const status = report !== '03' // 01 & 02 means outside range, 03 means inside range
|
|
1566
|
+
return {
|
|
1567
|
+
type: 'Outside_Temperature',
|
|
1568
|
+
number: number,
|
|
1569
|
+
deviceID: mac,
|
|
1570
|
+
status: status,
|
|
1571
|
+
temperature: temperature,
|
|
1572
|
+
message: messages[command][report].replace('()', `(${temperature}°C)`)
|
|
1573
|
+
}
|
|
1574
|
+
} else if (['07', '08', '09'].includes(report)) {
|
|
1575
|
+
const number = parseInt(extra[0])
|
|
1576
|
+
const mac = extra[1]
|
|
1577
|
+
const humidity = extra[2].humidity ? extra[2].humidity : null
|
|
1578
|
+
const status = report !== '09' // 07 & 08 means outside range, 09 means inside range
|
|
1579
|
+
return {
|
|
1580
|
+
type: 'Outside_Humidity',
|
|
1581
|
+
number: number,
|
|
1582
|
+
deviceID: mac,
|
|
1583
|
+
status: status,
|
|
1584
|
+
humidity: humidity,
|
|
1585
|
+
message: messages[command][report].replace('()', `(${humidity}%)`)
|
|
1586
|
+
}
|
|
1587
|
+
} else if (['0E', '0F', '10'].includes(report)) {
|
|
1588
|
+
const number = parseInt(extra[0])
|
|
1589
|
+
const mac = extra[1]
|
|
1590
|
+
const pressure = extra[2].tirePresure ? extra[2].tirePresure : null
|
|
1591
|
+
const status = report !== '10' // 0E & 0F means outside range, 10 means inside range
|
|
1592
|
+
return {
|
|
1593
|
+
type: 'Outside_Tire_Pressure',
|
|
1594
|
+
number: number,
|
|
1595
|
+
deviceID: mac,
|
|
1596
|
+
status: status,
|
|
1597
|
+
pressure: pressure,
|
|
1598
|
+
message: messages[command][report].replace('()', `(${pressure}kPa)`)
|
|
1599
|
+
}
|
|
1600
|
+
} else if (report === '15') {
|
|
1601
|
+
const number = parseInt(extra[0])
|
|
1602
|
+
const mac = extra[1]
|
|
1603
|
+
const status = extra[2].relay.state === 1
|
|
1604
|
+
const humanStatus = status ? 'activado' : 'desactivado'
|
|
1605
|
+
const configResult = extra[2].relay.configResult ? extra[2].relay.configResult : null
|
|
1606
|
+
return {
|
|
1607
|
+
type: 'Relay_BLE',
|
|
1608
|
+
number: number,
|
|
1609
|
+
deviceID: mac,
|
|
1610
|
+
status: status,
|
|
1611
|
+
configResult: configResult,
|
|
1612
|
+
message: messages[command][report].replace('__', `${humanStatus}`)
|
|
1613
|
+
}
|
|
1614
|
+
} else {
|
|
1615
|
+
return {
|
|
1616
|
+
type: 'Bluetooth_Alarm',
|
|
1617
|
+
message: messages[command][report]
|
|
1618
|
+
}
|
|
1375
1619
|
}
|
|
1620
|
+
|
|
1621
|
+
|
|
1376
1622
|
} else {
|
|
1377
1623
|
return {
|
|
1378
1624
|
type: command,
|
|
@@ -1499,8 +1745,10 @@ module.exports = {
|
|
|
1499
1745
|
disconnectionReasons: disconnectionReasons,
|
|
1500
1746
|
bluetoothAccessories: bluetoothAccessories,
|
|
1501
1747
|
bluetoothModels: bluetoothModels,
|
|
1748
|
+
bleTempHumSensors: bleTempHumSensors,
|
|
1502
1749
|
beaconModels: beaconModels,
|
|
1503
1750
|
beaconTypes: beaconTypes,
|
|
1751
|
+
relayBLEResults: relayBLEResults,
|
|
1504
1752
|
dTimeStates: dTimeStates,
|
|
1505
1753
|
dWorkingStates: dWorkingStates,
|
|
1506
1754
|
gnssTriggerTypes: gnssTriggerTypes,
|
|
@@ -1510,7 +1758,8 @@ module.exports = {
|
|
|
1510
1758
|
checkGps: checkGps,
|
|
1511
1759
|
includeSatellites: includeSatellites,
|
|
1512
1760
|
includeGnssTrigger: includeGnssTrigger,
|
|
1513
|
-
|
|
1761
|
+
includeStatus: includeStatus,
|
|
1762
|
+
includeGnnsAccuracy: includeGnnsAccuracy,
|
|
1514
1763
|
getAccelerationMagnitude: getAccelerationMagnitude,
|
|
1515
1764
|
getTempInCelciousDegrees: getTempInCelciousDegrees,
|
|
1516
1765
|
getBtTempHumData: getBtTempHumData,
|
|
@@ -1519,6 +1768,7 @@ module.exports = {
|
|
|
1519
1768
|
getSignalStrength: getSignalStrength,
|
|
1520
1769
|
getSignalPercentage: getSignalPercentage,
|
|
1521
1770
|
getCanData: getCanData,
|
|
1771
|
+
getBleData: getBleData,
|
|
1522
1772
|
getAlarm: getAlarm,
|
|
1523
1773
|
bin2dec: bin2dec,
|
|
1524
1774
|
bin2hex: bin2hex,
|