queclink-parser 1.9.28 → 1.9.31

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/src/utils.js CHANGED
@@ -19,44 +19,44 @@ const patterns = {
19
19
  Possible NACK Causes
20
20
  */
21
21
  const nackCauses = {
22
- '0': 'Clave o parámetros incorrectos',
23
- '1': 'Comando no soportado',
24
- '2': 'Comando no permitido en este momento'
22
+ 0: 'Clave o parámetros incorrectos',
23
+ 1: 'Comando no soportado',
24
+ 2: 'Comando no permitido en este momento'
25
25
  }
26
26
 
27
27
  /*
28
28
  Homologued devices
29
29
  */
30
30
  const devices = {
31
- '52': 'GL50',
32
- '55': 'GL50B',
31
+ 52: 'GL50',
32
+ 55: 'GL50B',
33
33
  '02': 'GL200',
34
34
  '04': 'GV200',
35
35
  '06': 'GV300',
36
36
  '08': 'GMT100',
37
37
  '09': 'GV50P', // GV50 Plus
38
38
  '0F': 'GV55',
39
- '50': 'GV55W',
40
- '10': 'GV55 LITE',
41
- '11': 'GL500',
39
+ 50: 'GV55W',
40
+ 10: 'GV55 LITE',
41
+ 11: 'GL500',
42
42
  '1A': 'GL300',
43
43
  '1F': 'GV500',
44
44
  '5E': 'GV500MAP',
45
- '25': 'GV300', // New Version
46
- '35': 'GV200', // New Version
47
- '27': 'GV300W',
45
+ 25: 'GV300', // New Version
46
+ 35: 'GV200', // New Version
47
+ 27: 'GV300W',
48
48
  '2F': 'GV55', // New Version
49
- '30': 'GL300', // New Version
50
- '36': 'GV500', // New Version
49
+ 30: 'GL300', // New Version
50
+ 36: 'GV500', // New Version
51
51
  '2C': 'GL300W', // New version
52
52
  '3F': 'GMT100', // New version
53
53
  F8: 'GV800W',
54
- '41': 'GV75W',
54
+ 41: 'GV75W',
55
55
  FC: 'GV600W',
56
56
  '6E': 'GV310LAU',
57
- '74': 'GV350CEU',
58
- '802004': 'GV58LAU',
59
- '802006': 'GV57CG',
57
+ 74: 'GV350CEU',
58
+ 802004: 'GV58LAU',
59
+ 802006: 'GV57CG',
60
60
  C301: 'GL533CG'
61
61
  }
62
62
 
@@ -64,14 +64,14 @@ const devices = {
64
64
  Possible device's motions states
65
65
  */
66
66
  const states = {
67
- '16': 'Tow',
67
+ 16: 'Tow',
68
68
  '1A': 'Fake Tow',
69
- '11': 'Ignition Off Rest',
70
- '12': 'Ignition Off Moving',
71
- '21': 'Ingition On Rest',
72
- '22': 'Ignition On Moving',
73
- '41': 'Sensor Rest',
74
- '42': 'Sensor Motion',
69
+ 11: 'Ignition Off Rest',
70
+ 12: 'Ignition Off Moving',
71
+ 21: 'Ingition On Rest',
72
+ 22: 'Ignition On Moving',
73
+ 41: 'Sensor Rest',
74
+ 42: 'Sensor Motion',
75
75
  '': 'Unknown'
76
76
  }
77
77
 
@@ -79,16 +79,16 @@ const states = {
79
79
  Possible OBDII Protoccols
80
80
  */
81
81
  const OBDIIProtocols = {
82
- '0': 'Unknown',
83
- '1': 'J1850 PWM',
84
- '2': 'J1850 VPW',
85
- '3': 'ISO 9141-2',
86
- '4': 'ISO 14230',
87
- '5': 'ISO 14230',
88
- '6': 'ISO 15765',
89
- '7': 'ISO 15765',
90
- '8': 'ISO 15765',
91
- '9': 'ISO 15765',
82
+ 0: 'Unknown',
83
+ 1: 'J1850 PWM',
84
+ 2: 'J1850 VPW',
85
+ 3: 'ISO 9141-2',
86
+ 4: 'ISO 14230',
87
+ 5: 'ISO 14230',
88
+ 6: 'ISO 15765',
89
+ 7: 'ISO 15765',
90
+ 8: 'ISO 15765',
91
+ 9: 'ISO 15765',
92
92
  A: 'J1939'
93
93
  }
94
94
 
@@ -96,49 +96,49 @@ const OBDIIProtocols = {
96
96
  Possible Uart Devices
97
97
  */
98
98
  const uartDeviceTypes = {
99
- '0': 'No device',
100
- '1': 'Digit Fuel Sensor',
101
- '2': 'AC100 1 Wire Bus',
102
- '5': 'CANBUS device',
103
- '6': 'AU100 device',
104
- '7': 'RF433 accessory'
99
+ 0: 'No device',
100
+ 1: 'Digit Fuel Sensor',
101
+ 2: 'AC100 1 Wire Bus',
102
+ 5: 'CANBUS device',
103
+ 6: 'AU100 device',
104
+ 7: 'RF433 accessory'
105
105
  }
106
106
 
107
107
  /*
108
108
  Possible Data Types for DTT
109
109
  */
110
110
  const dataTypes = {
111
- '0': 'Binary',
112
- '1': 'Hexadecimal'
111
+ 0: 'Binary',
112
+ 1: 'Hexadecimal'
113
113
  }
114
114
  /*
115
115
  Possible Network Types
116
116
  */
117
117
  const networkTypes = {
118
- '0': '2G',
119
- '1': '3G',
120
- '2': '4G',
121
- '99': 'Unknow'
118
+ 0: '2G',
119
+ 1: '3G',
120
+ 2: '4G',
121
+ 99: 'Unknow'
122
122
  }
123
123
 
124
124
  /*
125
125
  Possible Jammed Network Types
126
126
  */
127
127
  const jammingNetworkTypes = {
128
- '1': '2G',
129
- '2': '4G',
130
- '3': '2G, 3G y 4G',
131
- '4': '3G',
132
- '5': '2G y 3G'
128
+ 1: '2G',
129
+ 2: '4G',
130
+ 3: '2G, 3G y 4G',
131
+ 4: '3G',
132
+ 5: '2G y 3G'
133
133
  }
134
134
 
135
135
  /*
136
136
  Possible GPS Antena Status
137
137
  */
138
138
  const externalGPSAntennaOptions = {
139
- '0': 'Working',
140
- '1': 'Detected in open circuit state',
141
- '3': 'Unknow state',
139
+ 0: 'Working',
140
+ 1: 'Detected in open circuit state',
141
+ 3: 'Unknow state',
142
142
  '': 'Unknow'
143
143
  }
144
144
 
@@ -146,98 +146,98 @@ const externalGPSAntennaOptions = {
146
146
  Possible GPS Signal Strength
147
147
  */
148
148
  const gpsSignalStrength = {
149
- '0': 'Unknown',
150
- '1': 'Great',
151
- '2': 'Good',
152
- '3': 'Normal',
153
- '4': 'Weak'
149
+ 0: 'Unknown',
150
+ 1: 'Great',
151
+ 2: 'Good',
152
+ 3: 'Normal',
153
+ 4: 'Weak'
154
154
  }
155
155
 
156
156
  /*
157
157
  Possible Peer roles in Bluetooth
158
158
  */
159
159
  const peerRoles = {
160
- '0': 'Master',
161
- '1': 'Slave'
160
+ 0: 'Master',
161
+ 1: 'Slave'
162
162
  }
163
163
 
164
164
  /*
165
165
  Possible Peer addesses type for Bluetooth
166
166
  */
167
167
  const peerAddressesTypes = {
168
- '0': 'Public',
169
- '1': 'Random'
168
+ 0: 'Public',
169
+ 1: 'Random'
170
170
  }
171
171
 
172
172
  /*
173
173
  Possible Reasons for bluetooth disconnection
174
174
  */
175
175
  const disconnectionReasons = {
176
- '0': 'Normal',
177
- '4': 'Device pairing fails'
176
+ 0: 'Normal',
177
+ 4: 'Device pairing fails'
178
178
  }
179
179
 
180
180
  /*
181
181
  Possible Accesories Types of Bluetooth
182
182
  */
183
183
  const bluetoothAccessories = {
184
- '0': 'No bluetooth Accessory',
185
- '1': 'Escort sensor',
186
- '2': 'Beacon temperature sensor',
187
- '3': 'Bluetooth beacon accessory',
188
- '4': 'BLE CAN100',
189
- '6': 'Beacon Multi-Functional Sensor',
190
- '7': 'Technoton Accesory',
191
- '8': 'BLE I/O expander',
192
- '10': 'Fuel or angle sensor',
193
- '11': 'Magnet Sensor',
194
- '12': 'BLE TPMS sensor',
195
- '13': 'Relay Sensor'
184
+ 0: 'No bluetooth Accessory',
185
+ 1: 'Escort sensor',
186
+ 2: 'Beacon temperature sensor',
187
+ 3: 'Bluetooth beacon accessory',
188
+ 4: 'BLE CAN100',
189
+ 6: 'Beacon Multi-Functional Sensor',
190
+ 7: 'Technoton Accesory',
191
+ 8: 'BLE I/O expander',
192
+ 10: 'Fuel or angle sensor',
193
+ 11: 'Magnet Sensor',
194
+ 12: 'BLE TPMS sensor',
195
+ 13: 'Relay Sensor'
196
196
  }
197
197
 
198
198
  /*
199
199
  Possible Accesories Models for Bluetooth Accessories
200
200
  */
201
201
  const bluetoothModels = {
202
- '1': {
203
- '0': 'TD_BLE fuel sensor',
204
- '3': 'Angle sensor'
202
+ 1: {
203
+ 0: 'TD_BLE fuel sensor',
204
+ 3: 'Angle sensor'
205
205
  },
206
- '2': {
207
- '0': 'WTS300 (Temperature sensor)',
208
- '1': 'Temperature ELA'
206
+ 2: {
207
+ 0: 'WTS300 (Temperature sensor)',
208
+ 1: 'Temperature ELA'
209
209
  },
210
- '4': {
211
- '0': 'BLE CAN100'
210
+ 4: {
211
+ 0: 'BLE CAN100'
212
212
  },
213
- '6': {
214
- '2': 'WTH300 (Temperature and Humidity Sensor)',
215
- '3': 'RHT ELA (Temperature and Humidity Sensor)',
216
- '4': 'WMS301 (Door Sensor with embedded Temperature and Humidity Sensor)',
217
- '5': 'WTH301 (Temperature and Humidity Sensor)'
213
+ 6: {
214
+ 2: 'WTH300 (Temperature and Humidity Sensor)',
215
+ 3: 'RHT ELA (Temperature and Humidity Sensor)',
216
+ 4: 'WMS301 (Door Sensor with embedded Temperature and Humidity Sensor)',
217
+ 5: 'WTH301 (Temperature and Humidity Sensor)'
218
218
  },
219
- '7': {
220
- '0': 'DUT-E S7',
221
- '1': 'DFM 100S7',
222
- '2': 'DFM 250DS7',
223
- '3': 'GN0M DDE S7',
224
- '4': 'GNOM DP S7'
219
+ 7: {
220
+ 0: 'DUT-E S7',
221
+ 1: 'DFM 100S7',
222
+ 2: 'DFM 250DS7',
223
+ 3: 'GN0M DDE S7',
224
+ 4: 'GNOM DP S7'
225
225
  },
226
- '8': {
227
- '0': 'WBC300'
226
+ 8: {
227
+ 0: 'WBC300'
228
228
  },
229
- '10': {
230
- '0': 'Fuel Sensor',
231
- '1': 'Angle Sensor'
229
+ 10: {
230
+ 0: 'Fuel Sensor',
231
+ 1: 'Angle Sensor'
232
232
  },
233
- '11': {
234
- '0': 'MAG ELA (Door Sensor)'
233
+ 11: {
234
+ 0: 'MAG ELA (Door Sensor)'
235
235
  },
236
- '12': {
237
- '0': 'ATP100/ATP102'
236
+ 12: {
237
+ 0: 'ATP100/ATP102'
238
238
  },
239
- '13': {
240
- '0': 'WRL300 (Bluetooth Relay)'
239
+ 13: {
240
+ 0: 'WRL300 (Bluetooth Relay)'
241
241
  }
242
242
  }
243
243
 
@@ -256,21 +256,21 @@ const bleTempHumSensors = {
256
256
  Possible Beacon ID Models
257
257
  */
258
258
  const beaconModels = {
259
- '0': 'WKF300',
260
- '1': 'iBeacon E6',
261
- '2': 'ID ELA',
262
- '4': 'WID310',
263
- '10': 'WID330'
259
+ 0: 'WKF300',
260
+ 1: 'iBeacon E6',
261
+ 2: 'ID ELA',
262
+ 4: 'WID310',
263
+ 10: 'WID330'
264
264
  }
265
265
 
266
266
  /*
267
267
  Possible Beacon Types
268
268
  */
269
269
  const beaconTypes = {
270
- '0': 'ID',
271
- '1': 'iBeacon',
272
- '2': 'Eddystone',
273
- '3': 'Queclink'
270
+ 0: 'ID',
271
+ 1: 'iBeacon',
272
+ 2: 'Eddystone',
273
+ 3: 'Queclink'
274
274
  }
275
275
 
276
276
  /*
@@ -326,30 +326,30 @@ const dWorkingStatesExpansion = {
326
326
  Possible Jamming Sate Types
327
327
  */
328
328
  const jammingSateTypes = {
329
- '0': 'Unknown',
330
- '1': 'No significan jamming',
331
- '2': 'Potencial for interference',
332
- '3': 'Interference visible and no fix'
329
+ 0: 'Unknown',
330
+ 1: 'No significan jamming',
331
+ 2: 'Potencial for interference',
332
+ 3: 'Interference visible and no fix'
333
333
  }
334
334
 
335
335
  /*
336
336
  Possible port N Types for AU100
337
337
  */
338
338
  const portNTypes = {
339
- '0': 'Deshabilitado',
340
- '1': 'RS232',
341
- '3': '1-wire'
339
+ 0: 'Deshabilitado',
340
+ 1: 'RS232',
341
+ 3: '1-wire'
342
342
  }
343
343
 
344
344
  /*
345
345
  GNSS Trigger Types
346
346
  */
347
347
  const gnssTriggerTypes = {
348
- '0': 'Tiempo',
349
- '1': 'Esquina',
350
- '2': 'Distancia',
351
- '3': 'Kilometraje',
352
- '4': 'Óptimo (tiempo y distancia)'
348
+ 0: 'Tiempo',
349
+ 1: 'Esquina',
350
+ 2: 'Distancia',
351
+ 3: 'Kilometraje',
352
+ 4: 'Óptimo (tiempo y distancia)'
353
353
  }
354
354
 
355
355
  /*
@@ -385,7 +385,7 @@ const getProtocolVersion = protocol => {
385
385
  let deviceType
386
386
  let deviceVersion
387
387
  if (['802004', '802006'].includes(protocol.substring(0, 6))) {
388
- deviceType = devices.hasOwnProperty(protocol.substring(0, 6))
388
+ deviceType = Object.hasOwn(devices, protocol.substring(0, 6))
389
389
  ? devices[protocol.substring(0, 6)]
390
390
  : null
391
391
  deviceVersion = `${parseInt(protocol.substring(6, 8), 16)}.${parseInt(
@@ -393,12 +393,12 @@ const getProtocolVersion = protocol => {
393
393
  16
394
394
  )}`
395
395
  } else if (['C301'].includes(protocol.substring(0, 4))) {
396
- deviceType = devices.hasOwnProperty(protocol.substring(0, 4))
396
+ deviceType = Object.hasOwn(devices, protocol.substring(0, 4))
397
397
  ? devices[protocol.substring(0, 4)]
398
398
  : null
399
399
  deviceVersion = parseInt(protocol.substring(4, 8), 16)
400
400
  } else {
401
- deviceType = devices.hasOwnProperty(protocol.substring(0, 2))
401
+ deviceType = Object.hasOwn(devices, protocol.substring(0, 2))
402
402
  ? devices[protocol.substring(0, 2)]
403
403
  : null
404
404
  deviceVersion = `${parseInt(protocol.substring(2, 4), 16)}.${parseInt(
@@ -408,7 +408,7 @@ const getProtocolVersion = protocol => {
408
408
  }
409
409
  return {
410
410
  raw: protocol,
411
- deviceType: deviceType,
411
+ deviceType,
412
412
  version: deviceVersion
413
413
  }
414
414
  }
@@ -495,15 +495,15 @@ const getTempInCelciousDegrees = hexTemp => {
495
495
  */
496
496
  const getBleTempInCelciousDegrees = (device, hexData) => {
497
497
  if (device === 'WTH300') {
498
- let intTemp = parseInt(hexData.substring(0, 2), 16)
499
- let decTemp = parseInt(hexData.substring(2, 4), 16)
498
+ const intTemp = parseInt(hexData.substring(0, 2), 16)
499
+ const decTemp = parseInt(hexData.substring(2, 4), 16)
500
500
  return intTemp + decTemp / 256
501
501
  } else if (['WTH301', 'WMS301'].includes(device)) {
502
- let intTemp = parseInt(hexData.substring(0, 2), 16)
503
- let decTemp = parseInt(hexData.substring(2, 4), 16)
502
+ const intTemp = parseInt(hexData.substring(0, 2), 16)
503
+ const decTemp = parseInt(hexData.substring(2, 4), 16)
504
504
  return intTemp + decTemp / 100
505
505
  } else if (device === 'ATP100/ATP102') {
506
- let temp = parseInt(hexData.substring(4, 6), 16)
506
+ const temp = parseInt(hexData.substring(4, 6), 16)
507
507
  return temp - 40
508
508
  } else {
509
509
  return null
@@ -514,8 +514,8 @@ const getBleTempInCelciousDegrees = (device, hexData) => {
514
514
  Gets the humidity from BLE devices in rh
515
515
  */
516
516
  const getBleHumidityInRH = (device, hexData) => {
517
- let intHum = parseInt(hexData.substring(4, 6), 16)
518
- let decHum = parseInt(hexData.substring(6, 8), 16)
517
+ const intHum = parseInt(hexData.substring(4, 6), 16)
518
+ const decHum = parseInt(hexData.substring(6, 8), 16)
519
519
  if (device === 'WTH300') {
520
520
  return intHum + decHum / 256
521
521
  } else if (['WTH301', 'WMS301'].includes(device)) {
@@ -529,7 +529,7 @@ const getBleHumidityInRH = (device, hexData) => {
529
529
  Gets the humidity from BLE devices in rh
530
530
  */
531
531
  const getTirePressureInPSI = hexData => {
532
- let tirePress = parseInt(hexData.substring(2, 4), 16) * 2.5 // In kPa
532
+ const tirePress = parseInt(hexData.substring(2, 4), 16) * 2.5 // In kPa
533
533
  return tirePress / 6.895 // In PSI
534
534
  }
535
535
 
@@ -537,15 +537,14 @@ const getTirePressureInPSI = hexData => {
537
537
  Gets the Two's Complement for hex numbers
538
538
  */
539
539
  const getAccelerationMagnitude = (hexNumber, n) => {
540
- let binNumber = nHexDigit(hex2bin(hexNumber), n * 4)
540
+ const binNumber = nHexDigit(hex2bin(hexNumber), n * 4)
541
541
  if (binNumber.substring(0, 5) !== '11111') {
542
- return Number((parseInt(hexNumber, 16) / 82 * 9.80665).toFixed(2))
542
+ return Number(((parseInt(hexNumber, 16) / 82) * 9.80665).toFixed(2))
543
543
  }
544
544
  return Number(
545
545
  (
546
- (parseInt('F'.repeat(n), 16) - parseInt(hexNumber, 16) + 1) *
547
- -1 /
548
- 82 *
546
+ (((parseInt('F'.repeat(n), 16) - parseInt(hexNumber, 16) + 1) * -1) /
547
+ 82) *
549
548
  9.80665
550
549
  ).toFixed(2)
551
550
  )
@@ -598,7 +597,7 @@ const getSignalStrength = (networkType, value, hexValue = false) => {
598
597
  calc = 2 * value - 113
599
598
  dBm = calc < -113 ? 0 : calc > -51 ? 100 : calc
600
599
  } else if (networkType === '4G') {
601
- calc = 96 / 97 * value - 140
600
+ calc = (96 / 97) * value - 140
602
601
  dBm = calc < -140 ? 0 : calc > -44 ? 100 : calc
603
602
  } else if (networkType === 'GSM') {
604
603
  calc = value - 110
@@ -625,11 +624,11 @@ const getSignalPercentage = (networkType, value) => {
625
624
 
626
625
  let perc
627
626
  if (networkType === '2G' || networkType === '3G') {
628
- perc = value / 31 * 100
627
+ perc = (value / 31) * 100
629
628
  } else if (networkType === '4G') {
630
- perc = value / 97 * 100
629
+ perc = (value / 97) * 100
631
630
  } else if (networkType === 'GSM') {
632
- perc = value / 63 * 100
631
+ perc = (value / 63) * 100
633
632
  } else {
634
633
  perc = null
635
634
  }
@@ -642,8 +641,8 @@ const getSignalPercentage = (networkType, value) => {
642
641
  source: https://es.wikipedia.org/wiki/MCC/MNC
643
642
  */
644
643
  const getMNC = (countryData, opData) => {
645
- let mcc = parseInt(countryData, 10)
646
- let mnc = parseInt(opData, 10)
644
+ const mcc = parseInt(countryData, 10)
645
+ const mnc = parseInt(opData, 10)
647
646
  let operator
648
647
  if (mcc === 716) {
649
648
  operator =
@@ -657,7 +656,9 @@ const getMNC = (countryData, opData) => {
657
656
  ? 'Viettel'
658
657
  : mnc === 17
659
658
  ? 'Entel'
660
- : mnc === 20 ? 'Cuy Mobile (Claro)' : 'Desconocido'
659
+ : mnc === 20
660
+ ? 'Cuy Mobile (Claro)'
661
+ : 'Desconocido'
661
662
  } else if (mcc === 722) {
662
663
  operator =
663
664
  mnc === 1
@@ -668,12 +669,16 @@ const getMNC = (countryData, opData) => {
668
669
  ? 'Nextel'
669
670
  : mnc === 34
670
671
  ? 'Telecom Personal'
671
- : [310, 320, 330].includes(mnc) ? 'Claro' : 'Desconocido'
672
+ : [310, 320, 330].includes(mnc)
673
+ ? 'Claro'
674
+ : 'Desconocido'
672
675
  } else if (mcc === 724) {
673
676
  // Incomplete
674
677
  operator = [2, 3, 4].includes(mnc)
675
678
  ? 'TIM'
676
- : [5, 6, 12].includes(mnc) ? 'Claro' : 'Otra'
679
+ : [5, 6, 12].includes(mnc)
680
+ ? 'Claro'
681
+ : 'Otra'
677
682
  } else if (mcc === 730) {
678
683
  operator = [1, 10].includes(mnc)
679
684
  ? 'Entel'
@@ -685,7 +690,9 @@ const getMNC = (countryData, opData) => {
685
690
  ? 'VTR (Claro)'
686
691
  : mnc === 9
687
692
  ? 'WOM'
688
- : [14, 20, 21, 28].includes(mnc) ? 'Otro' : 'Desconocido'
693
+ : [14, 20, 21, 28].includes(mnc)
694
+ ? 'Otro'
695
+ : 'Desconocido'
689
696
  } else if (mcc === 732) {
690
697
  operator =
691
698
  mnc === 1
@@ -698,7 +705,9 @@ const getMNC = (countryData, opData) => {
698
705
  ? 'Colombia Móvil'
699
706
  : [102, 123].includes(mnc)
700
707
  ? 'Movistar'
701
- : mnc === 360 ? 'WOM' : 'Desconocido'
708
+ : mnc === 360
709
+ ? 'WOM'
710
+ : 'Desconocido'
702
711
  } else if (mcc === 736) {
703
712
  operator =
704
713
  mnc === 1
@@ -707,14 +716,20 @@ const getMNC = (countryData, opData) => {
707
716
  ? 'Entel'
708
717
  : mnc === 3
709
718
  ? 'Telecel'
710
- : mnc === 4 ? 'Cotas' : mnc === 5 ? 'Comteco' : 'Desconocido'
719
+ : mnc === 4
720
+ ? 'Cotas'
721
+ : mnc === 5
722
+ ? 'Comteco'
723
+ : 'Desconocido'
711
724
  } else if (mcc === 740) {
712
725
  operator =
713
726
  mnc === 1
714
727
  ? 'Otecel (Movistar)'
715
728
  : mnc === 2
716
729
  ? 'Conecel (Claro)'
717
- : mnc === 0 ? 'Telecsa (CNT' : 'Desconocido'
730
+ : mnc === 0
731
+ ? 'Telecsa (CNT'
732
+ : 'Desconocido'
718
733
  } else if (mcc === 744) {
719
734
  operator =
720
735
  mnc === 1
@@ -725,18 +740,24 @@ const getMNC = (countryData, opData) => {
725
740
  ? 'Comunicaciones Privadas'
726
741
  : mnc === 4
727
742
  ? 'Telefónica Celular del Paraguay'
728
- : mnc === 5 ? 'Núcleo' : 'Desconocido'
743
+ : mnc === 5
744
+ ? 'Núcleo'
745
+ : 'Desconocido'
729
746
  } else if (mcc === 748) {
730
747
  operator = [0, 1].includes(mnc)
731
748
  ? 'Ancel'
732
- : mnc === 7 ? 'Movistar' : mnc === 0 ? 'AMX Wireless' : 'Desconocido'
749
+ : mnc === 7
750
+ ? 'Movistar'
751
+ : mnc === 0
752
+ ? 'AMX Wireless'
753
+ : 'Desconocido'
733
754
  } else {
734
755
  operator = 'Desconocido'
735
756
  }
736
757
  return {
737
758
  country: latamMcc[mcc] || latamMcc.default,
738
- mnc: mnc,
739
- operator: operator
759
+ mnc,
760
+ operator
740
761
  }
741
762
  }
742
763
 
@@ -744,7 +765,7 @@ const getMNC = (countryData, opData) => {
744
765
  Hectometer to Kilometer
745
766
  */
746
767
  const hToKm = data => {
747
- let h = parseFloat(data.slice(1))
768
+ const h = parseFloat(data.slice(1))
748
769
  return parseFloat((h * 0.1).toFixed(2))
749
770
  }
750
771
 
@@ -756,7 +777,11 @@ const parseCanData = (data, key) => {
756
777
  case 'ignitionKey':
757
778
  return data === '0'
758
779
  ? 'ignition_off'
759
- : data === '1' ? 'ignition_on' : data === '2' ? 'engine_on' : null
780
+ : data === '1'
781
+ ? 'ignition_on'
782
+ : data === '2'
783
+ ? 'engine_on'
784
+ : null
760
785
  case 'totalDistance':
761
786
  if (data.slice(0, 1) === 'H') {
762
787
  return hToKm(data)
@@ -788,7 +813,9 @@ const parseCanData = (data, key) => {
788
813
  case 'dpgSootLevelUnit':
789
814
  return data.slice(0, 2) === 'FE'
790
815
  ? 'L'
791
- : data.slice(0, 2) === 'FF' ? 'P' : '-'
816
+ : data.slice(0, 2) === 'FF'
817
+ ? 'P'
818
+ : '-'
792
819
  case 'dtcStatus':
793
820
  switch (data) {
794
821
  case '00':
@@ -824,7 +851,7 @@ const getCanData = (parsedData, ix, type, options) => {
824
851
  options = options || {}
825
852
  const isGV350CEU = options && options.deviceType === 'GV350CEU'
826
853
 
827
- let canAppendMask =
854
+ const canAppendMask =
828
855
  parsedData[ix + 1] !== ''
829
856
  ? nHexDigit(hex2bin(parsedData[ix + 1]), 32)
830
857
  : null
@@ -833,519 +860,509 @@ const getCanData = (parsedData, ix, type, options) => {
833
860
  return {}
834
861
  }
835
862
 
836
- let vinIx = ix + 1 + parseInt(canAppendMask[31])
837
- let ignIx = vinIx + parseInt(canAppendMask[30])
838
- let disIx = ignIx + parseInt(canAppendMask[29])
839
- let fuelIx = disIx + parseInt(canAppendMask[28])
863
+ const vinIx = ix + 1 + parseInt(canAppendMask[31])
864
+ const ignIx = vinIx + parseInt(canAppendMask[30])
865
+ const disIx = ignIx + parseInt(canAppendMask[29])
866
+ const fuelIx = disIx + parseInt(canAppendMask[28])
840
867
  // Inverted speed and rpm because of inconsistence in documentation
841
- let rpmIx = fuelIx + parseInt(canAppendMask[26])
842
- let spdIx = rpmIx + parseInt(canAppendMask[27])
843
- let engcIx = spdIx + parseInt(canAppendMask[25])
844
- let fuelcIx = engcIx + parseInt(canAppendMask[24])
845
- let fuellIx = fuelcIx + parseInt(canAppendMask[23])
846
- let rngIx = fuellIx + parseInt(canAppendMask[22])
847
- let accIx = rngIx + parseInt(canAppendMask[21])
848
- let enghIx = accIx + parseInt(canAppendMask[20])
849
- let drvIx = enghIx + parseInt(canAppendMask[19])
850
- let idltIx = drvIx + parseInt(canAppendMask[18])
851
- let idlfIx = idltIx + parseInt(canAppendMask[17])
852
- let axlwIx = idlfIx + parseInt(canAppendMask[16])
853
- let tacIx = axlwIx + parseInt(canAppendMask[15])
854
- let indIx = tacIx + parseInt(canAppendMask[14])
855
- let ligIx = indIx + parseInt(canAppendMask[13])
856
- let doorIx = ligIx + parseInt(canAppendMask[12])
857
- let osptIx = doorIx + parseInt(canAppendMask[11])
858
- let ospeIx = osptIx + parseInt(canAppendMask[10])
868
+ const rpmIx = fuelIx + parseInt(canAppendMask[26])
869
+ const spdIx = rpmIx + parseInt(canAppendMask[27])
870
+ const engcIx = spdIx + parseInt(canAppendMask[25])
871
+ const fuelcIx = engcIx + parseInt(canAppendMask[24])
872
+ const fuellIx = fuelcIx + parseInt(canAppendMask[23])
873
+ const rngIx = fuellIx + parseInt(canAppendMask[22])
874
+ const accIx = rngIx + parseInt(canAppendMask[21])
875
+ const enghIx = accIx + parseInt(canAppendMask[20])
876
+ const drvIx = enghIx + parseInt(canAppendMask[19])
877
+ const idltIx = drvIx + parseInt(canAppendMask[18])
878
+ const idlfIx = idltIx + parseInt(canAppendMask[17])
879
+ const axlwIx = idlfIx + parseInt(canAppendMask[16])
880
+ const tacIx = axlwIx + parseInt(canAppendMask[15])
881
+ const indIx = tacIx + parseInt(canAppendMask[14])
882
+ const ligIx = indIx + parseInt(canAppendMask[13])
883
+ const doorIx = ligIx + parseInt(canAppendMask[12])
884
+ const osptIx = doorIx + parseInt(canAppendMask[11])
885
+ const ospeIx = osptIx + parseInt(canAppendMask[10])
859
886
  // Value 9 is only for hex report
860
- let ecscdIx = ospeIx + parseInt(canAppendMask[8]) // Engine Cold Starts Count
861
- let eascIx = ecscdIx + parseInt(canAppendMask[7]) // Engine All Starts Count
862
- let esicIx = eascIx + parseInt(canAppendMask[6]) // Engine Starts by Ignition Count
863
- let tecrIx = esicIx + parseInt(canAppendMask[5]) // Total Engine Engine Cold Running Time
864
- let hbraIx = tecrIx + parseInt(canAppendMask[4]) // Handbrake Applications During Ride Count
887
+ const ecscdIx = ospeIx + parseInt(canAppendMask[8]) // Engine Cold Starts Count
888
+ const eascIx = ecscdIx + parseInt(canAppendMask[7]) // Engine All Starts Count
889
+ const esicIx = eascIx + parseInt(canAppendMask[6]) // Engine Starts by Ignition Count
890
+ const tecrIx = esicIx + parseInt(canAppendMask[5]) // Total Engine Engine Cold Running Time
891
+ const hbraIx = tecrIx + parseInt(canAppendMask[4]) // Handbrake Applications During Ride Count
865
892
  let elIx = hbraIx + parseInt(canAppendMask[3]) // Electric Report Mask
866
- let canxIx = isGV350CEU
893
+ const canxIx = isGV350CEU
867
894
  ? hbraIx + parseInt(canAppendMask[2])
868
895
  : elIx + parseInt(canAppendMask[2]) // CAN Expansion Mask
869
896
 
870
897
  // CAN Expansion Mask
871
- let canExpansionMask =
898
+ const canExpansionMask =
872
899
  canAppendMask[2] === '1' && parsedData[canxIx] !== ''
873
- ? nHexDigit(hex2bin(parsedData[canxIx]), 32)
874
- .split('')
875
- .reverse()
876
- .join('')
900
+ ? nHexDigit(hex2bin(parsedData[canxIx]), 32).split('').reverse().join('')
877
901
  : '00000000000000000000000000000000'
878
902
 
879
- let repExpMask =
903
+ const repExpMask =
880
904
  canAppendMask[2] === '1'
881
905
  ? {
882
- raw: parsedData[canxIx] ? parsedData[canxIx] : null,
883
- adBlueLevel: canExpansionMask[0] === '1',
884
- axleWeight1: canExpansionMask[1] === '1',
885
- axleWeight3: canExpansionMask[2] === '1',
886
- axleWeight4: canExpansionMask[3] === '1',
887
- tachographOverspeedSignal: canExpansionMask[4] === '1',
888
- tachographVehicleMotionSignal: canExpansionMask[5] === '1',
889
- tachographDrivingDirection: canExpansionMask[6] === '1',
890
- analogInputValue: canExpansionMask[7] === '1',
891
- engineBrakingFactor: canExpansionMask[8] === '1',
892
- pedalBrakingFactor: canExpansionMask[9] === '1',
893
- totalAcceleratorKickDown: canExpansionMask[10] === '1',
894
- totalEffectiveEngineSpeedTime: canExpansionMask[11] === '1',
895
- totalCruiseControlTime: canExpansionMask[12] === '1',
896
- totalAcceleratorKickDownTime: canExpansionMask[13] === '1',
897
- totalBrakeApplications: canExpansionMask[14] === '1',
898
- tachographDriver1Card: canExpansionMask[15] === '1',
899
- tachographDriver2Card: canExpansionMask[16] === '1',
900
- tachographDriver1Name: canExpansionMask[17] === '1',
901
- tachographDriver2Name: canExpansionMask[18] === '1',
902
- registrationNumber: canExpansionMask[19] === '1',
903
- expansionInformation: canExpansionMask[20] === '1',
904
- rapidBrakings: canExpansionMask[21] === '1',
905
- rapidAccelerations: canExpansionMask[22] === '1',
906
- engineTorque: canExpansionMask[23] === '1',
907
- serviceDistance: canExpansionMask[24] === '1',
908
- ambientTemperature: canExpansionMask[25] === '1',
909
- dtcCodes: canExpansionMask[28] === '1',
910
- gaseousFuelLevel: canExpansionMask[29] === '1',
911
- tachographInfoExpansion: canExpansionMask[30] === '1',
912
- canReportExpansionMask1: canExpansionMask[31] === '1'
913
- }
906
+ raw: parsedData[canxIx] ? parsedData[canxIx] : null,
907
+ adBlueLevel: canExpansionMask[0] === '1',
908
+ axleWeight1: canExpansionMask[1] === '1',
909
+ axleWeight3: canExpansionMask[2] === '1',
910
+ axleWeight4: canExpansionMask[3] === '1',
911
+ tachographOverspeedSignal: canExpansionMask[4] === '1',
912
+ tachographVehicleMotionSignal: canExpansionMask[5] === '1',
913
+ tachographDrivingDirection: canExpansionMask[6] === '1',
914
+ analogInputValue: canExpansionMask[7] === '1',
915
+ engineBrakingFactor: canExpansionMask[8] === '1',
916
+ pedalBrakingFactor: canExpansionMask[9] === '1',
917
+ totalAcceleratorKickDown: canExpansionMask[10] === '1',
918
+ totalEffectiveEngineSpeedTime: canExpansionMask[11] === '1',
919
+ totalCruiseControlTime: canExpansionMask[12] === '1',
920
+ totalAcceleratorKickDownTime: canExpansionMask[13] === '1',
921
+ totalBrakeApplications: canExpansionMask[14] === '1',
922
+ tachographDriver1Card: canExpansionMask[15] === '1',
923
+ tachographDriver2Card: canExpansionMask[16] === '1',
924
+ tachographDriver1Name: canExpansionMask[17] === '1',
925
+ tachographDriver2Name: canExpansionMask[18] === '1',
926
+ registrationNumber: canExpansionMask[19] === '1',
927
+ expansionInformation: canExpansionMask[20] === '1',
928
+ rapidBrakings: canExpansionMask[21] === '1',
929
+ rapidAccelerations: canExpansionMask[22] === '1',
930
+ engineTorque: canExpansionMask[23] === '1',
931
+ serviceDistance: canExpansionMask[24] === '1',
932
+ ambientTemperature: canExpansionMask[25] === '1',
933
+ dtcCodes: canExpansionMask[28] === '1',
934
+ gaseousFuelLevel: canExpansionMask[29] === '1',
935
+ tachographInfoExpansion: canExpansionMask[30] === '1',
936
+ canReportExpansionMask1: canExpansionMask[31] === '1'
937
+ }
914
938
  : null
915
939
 
916
- let adbIx = canxIx + parseInt(canExpansionMask[0])
917
- let ax1Ix = adbIx + parseInt(canExpansionMask[1])
918
- let ax3Ix = ax1Ix + parseInt(canExpansionMask[2])
919
- let ax4Ix = ax3Ix + parseInt(canExpansionMask[3])
920
- let tosIx = ax4Ix + parseInt(canExpansionMask[4])
921
- let tvmIx = tosIx + parseInt(canExpansionMask[5])
922
- let tddIx = tvmIx + parseInt(canExpansionMask[6])
923
- let aivIx = tddIx + parseInt(canExpansionMask[7])
924
- let ebrIx = aivIx + parseInt(canExpansionMask[8])
925
- let pbrIx = ebrIx + parseInt(canExpansionMask[9])
926
- let ackIx = pbrIx + parseInt(canExpansionMask[10])
927
- let eesIx = ackIx + parseInt(canExpansionMask[11])
928
- let crcIx = eesIx + parseInt(canExpansionMask[12])
929
- let acktIx = crcIx + parseInt(canExpansionMask[13])
930
- let braIx = acktIx + parseInt(canExpansionMask[14])
931
- let tdc1Ix = braIx + parseInt(canExpansionMask[15])
932
- let tdc2Ix = tdc1Ix + parseInt(canExpansionMask[16])
933
- let tdn1Ix = tdc2Ix + parseInt(canExpansionMask[17])
934
- let tdn2Ix = tdn1Ix + parseInt(canExpansionMask[18])
935
- let regIx = tdn2Ix + parseInt(canExpansionMask[19])
936
- let expbIx = regIx + parseInt(canExpansionMask[20])
937
- let rbrIx = expbIx + parseInt(canExpansionMask[21])
938
- let racIx = rbrIx + parseInt(canExpansionMask[22])
939
- let etqIx = racIx + parseInt(canExpansionMask[23])
940
- let sdIx = etqIx + parseInt(canExpansionMask[24])
941
- let atIx = sdIx + parseInt(canExpansionMask[25])
942
- let dtcIx =
940
+ const adbIx = canxIx + parseInt(canExpansionMask[0])
941
+ const ax1Ix = adbIx + parseInt(canExpansionMask[1])
942
+ const ax3Ix = ax1Ix + parseInt(canExpansionMask[2])
943
+ const ax4Ix = ax3Ix + parseInt(canExpansionMask[3])
944
+ const tosIx = ax4Ix + parseInt(canExpansionMask[4])
945
+ const tvmIx = tosIx + parseInt(canExpansionMask[5])
946
+ const tddIx = tvmIx + parseInt(canExpansionMask[6])
947
+ const aivIx = tddIx + parseInt(canExpansionMask[7])
948
+ const ebrIx = aivIx + parseInt(canExpansionMask[8])
949
+ const pbrIx = ebrIx + parseInt(canExpansionMask[9])
950
+ const ackIx = pbrIx + parseInt(canExpansionMask[10])
951
+ const eesIx = ackIx + parseInt(canExpansionMask[11])
952
+ const crcIx = eesIx + parseInt(canExpansionMask[12])
953
+ const acktIx = crcIx + parseInt(canExpansionMask[13])
954
+ const braIx = acktIx + parseInt(canExpansionMask[14])
955
+ const tdc1Ix = braIx + parseInt(canExpansionMask[15])
956
+ const tdc2Ix = tdc1Ix + parseInt(canExpansionMask[16])
957
+ const tdn1Ix = tdc2Ix + parseInt(canExpansionMask[17])
958
+ const tdn2Ix = tdn1Ix + parseInt(canExpansionMask[18])
959
+ const regIx = tdn2Ix + parseInt(canExpansionMask[19])
960
+ const expbIx = regIx + parseInt(canExpansionMask[20])
961
+ const rbrIx = expbIx + parseInt(canExpansionMask[21])
962
+ const racIx = rbrIx + parseInt(canExpansionMask[22])
963
+ const etqIx = racIx + parseInt(canExpansionMask[23])
964
+ const sdIx = etqIx + parseInt(canExpansionMask[24])
965
+ const atIx = sdIx + parseInt(canExpansionMask[25])
966
+ const dtcIx =
943
967
  canExpansionMask[28] === '1'
944
968
  ? atIx + 1 + parseCanData(canExpansionMask[28], 'dtcCodeNumber') // Revisar
945
969
  : atIx
946
- let gflIx = dtcIx + parseInt(canExpansionMask[29])
947
- let tieIx = gflIx + parseInt(canExpansionMask[30])
948
- let crm1Ix = tieIx + parseInt(canExpansionMask[31])
970
+ const gflIx = dtcIx + parseInt(canExpansionMask[29])
971
+ const tieIx = gflIx + parseInt(canExpansionMask[30])
972
+ const crm1Ix = tieIx + parseInt(canExpansionMask[31])
949
973
 
950
974
  // DTC Codes
951
- let dtcCodeNumber = parseCanData(parsedData[dtcIx], 'dtcCodeNumber')
952
- let dtcArray = dtcCodeNumber
975
+ const dtcCodeNumber = parseCanData(parsedData[dtcIx], 'dtcCodeNumber')
976
+ const dtcArray = dtcCodeNumber
953
977
  ? Array.from({ length: dtcCodeNumber }, (_, i) => i)
954
978
  : []
955
- let dtcCodes =
979
+ const dtcCodes =
956
980
  dtcArray.length > 0
957
981
  ? dtcArray.map(dtcCode => {
958
- return {
959
- id: dtcCode + 1, // 1-99
960
- code: parsedData[dtcIx + dtcCode + 1]
961
- ? parsedData[dtcIx + dtcCode + 1]
962
- : null
963
- }
964
- })
982
+ return {
983
+ id: dtcCode + 1, // 1-99
984
+ code: parsedData[dtcIx + dtcCode + 1]
985
+ ? parsedData[dtcIx + dtcCode + 1]
986
+ : null
987
+ }
988
+ })
965
989
  : []
966
990
 
967
991
  // Report Expansion Mask 1
968
- let canRepExpMask1 =
992
+ const canRepExpMask1 =
969
993
  canExpansionMask[31] === '1' && parsedData[crm1Ix] !== ''
970
- ? nHexDigit(hex2bin(parsedData[crm1Ix]), 32)
971
- .split('')
972
- .reverse()
973
- .join('')
994
+ ? nHexDigit(hex2bin(parsedData[crm1Ix]), 32).split('').reverse().join('')
974
995
  : '00000000000000000000000000000000'
975
996
 
976
- let retIx = crm1Ix + parseInt(canRepExpMask1[0])
977
- let pwrmIx = retIx + parseInt(canRepExpMask1[1])
997
+ const retIx = crm1Ix + parseInt(canRepExpMask1[0])
998
+ const pwrmIx = retIx + parseInt(canRepExpMask1[1])
978
999
  // bit 2 reserved
979
- let egsIx = pwrmIx + parseInt(canRepExpMask1[3])
1000
+ const egsIx = pwrmIx + parseInt(canRepExpMask1[3])
980
1001
 
981
1002
  // E-GENSET Report Mask
982
- let egsReportMask =
1003
+ const egsReportMask =
983
1004
  canRepExpMask1[3] === '1' && parsedData[egsIx] !== ''
984
- ? nHexDigit(hex2bin(parsedData[egsIx]), 32)
985
- .split('')
986
- .reverse()
987
- .join('')
1005
+ ? nHexDigit(hex2bin(parsedData[egsIx]), 32).split('').reverse().join('')
988
1006
  : '00000000000000000000000000000000'
989
1007
 
990
- let husIx = egsIx + parseInt(egsReportMask[0])
991
- let sshIx = husIx + parseInt(egsReportMask[1])
992
- let simIx = sshIx + parseInt(egsReportMask[2])
993
- let rrIx = simIx + parseInt(egsReportMask[3])
994
- let ebatTmpIx = rrIx + parseInt(egsReportMask[4])
995
- let bmsTmpIx = ebatTmpIx + parseInt(egsReportMask[5])
996
- let ebatVIx = bmsTmpIx + parseInt(egsReportMask[6])
997
- let minCvIx = ebatVIx + parseInt(egsReportMask[7])
998
- let maxCvIx = minCvIx + parseInt(egsReportMask[8])
999
- let maxCtIx = maxCvIx + parseInt(egsReportMask[9])
1000
- let minCtIx = maxCtIx + parseInt(egsReportMask[10])
1001
- let mbpwIx = minCtIx + parseInt(egsReportMask[11])
1002
- let cecuErrIx = mbpwIx + parseInt(egsReportMask[12])
1003
- let cchIx = cecuErrIx + parseInt(egsReportMask[13])
1004
- let iacl1Ix = cchIx + parseInt(egsReportMask[14])
1005
- let iacl2Ix = iacl1Ix + parseInt(egsReportMask[15])
1006
- let iacl3Ix = iacl2Ix + parseInt(egsReportMask[16])
1007
- let iatIx = iacl3Ix + parseInt(egsReportMask[17])
1008
- let iotIx = iatIx + parseInt(egsReportMask[18])
1009
- let iavl1Ix = iotIx + parseInt(egsReportMask[19])
1010
- let iavl2Ix = iavl1Ix + parseInt(egsReportMask[20])
1011
- let iavl3Ix = iavl2Ix + parseInt(egsReportMask[21])
1012
- let isIx = iavl3Ix + parseInt(egsReportMask[22])
1013
- let sdrIx = isIx + parseInt(egsReportMask[23])
1014
- let cutIx = sdrIx + parseInt(egsReportMask[24])
1015
- let citIx = cutIx + parseInt(egsReportMask[25])
1016
-
1017
- let oltmIx = citIx + parseInt(canRepExpMask1[4])
1018
- let ollvIx = oltmIx + parseInt(canRepExpMask1[5])
1019
- let ax5Ix = ollvIx + parseInt(canRepExpMask1[6])
1020
- let ax6Ix = ax5Ix + parseInt(canRepExpMask1[7])
1021
- let ax7Ix = ax6Ix + parseInt(canRepExpMask1[8])
1022
- let grnIx = ax7Ix + parseInt(canRepExpMask1[9])
1023
- let dpflvIx = grnIx + parseInt(canRepExpMask1[10])
1024
- let vintrIx = dpflvIx + parseInt(canRepExpMask1[11])
1025
- let exp2Ix = vintrIx + parseInt(canRepExpMask1[12])
1026
- let flidIx = exp2Ix + parseInt(canRepExpMask1[13])
1027
- let vgrwIx = flidIx + parseInt(canRepExpMask1[14])
1028
- let tireCount =
1008
+ const husIx = egsIx + parseInt(egsReportMask[0])
1009
+ const sshIx = husIx + parseInt(egsReportMask[1])
1010
+ const simIx = sshIx + parseInt(egsReportMask[2])
1011
+ const rrIx = simIx + parseInt(egsReportMask[3])
1012
+ const ebatTmpIx = rrIx + parseInt(egsReportMask[4])
1013
+ const bmsTmpIx = ebatTmpIx + parseInt(egsReportMask[5])
1014
+ const ebatVIx = bmsTmpIx + parseInt(egsReportMask[6])
1015
+ const minCvIx = ebatVIx + parseInt(egsReportMask[7])
1016
+ const maxCvIx = minCvIx + parseInt(egsReportMask[8])
1017
+ const maxCtIx = maxCvIx + parseInt(egsReportMask[9])
1018
+ const minCtIx = maxCtIx + parseInt(egsReportMask[10])
1019
+ const mbpwIx = minCtIx + parseInt(egsReportMask[11])
1020
+ const cecuErrIx = mbpwIx + parseInt(egsReportMask[12])
1021
+ const cchIx = cecuErrIx + parseInt(egsReportMask[13])
1022
+ const iacl1Ix = cchIx + parseInt(egsReportMask[14])
1023
+ const iacl2Ix = iacl1Ix + parseInt(egsReportMask[15])
1024
+ const iacl3Ix = iacl2Ix + parseInt(egsReportMask[16])
1025
+ const iatIx = iacl3Ix + parseInt(egsReportMask[17])
1026
+ const iotIx = iatIx + parseInt(egsReportMask[18])
1027
+ const iavl1Ix = iotIx + parseInt(egsReportMask[19])
1028
+ const iavl2Ix = iavl1Ix + parseInt(egsReportMask[20])
1029
+ const iavl3Ix = iavl2Ix + parseInt(egsReportMask[21])
1030
+ const isIx = iavl3Ix + parseInt(egsReportMask[22])
1031
+ const sdrIx = isIx + parseInt(egsReportMask[23])
1032
+ const cutIx = sdrIx + parseInt(egsReportMask[24])
1033
+ const citIx = cutIx + parseInt(egsReportMask[25])
1034
+
1035
+ const oltmIx = citIx + parseInt(canRepExpMask1[4])
1036
+ const ollvIx = oltmIx + parseInt(canRepExpMask1[5])
1037
+ const ax5Ix = ollvIx + parseInt(canRepExpMask1[6])
1038
+ const ax6Ix = ax5Ix + parseInt(canRepExpMask1[7])
1039
+ const ax7Ix = ax6Ix + parseInt(canRepExpMask1[8])
1040
+ const grnIx = ax7Ix + parseInt(canRepExpMask1[9])
1041
+ const dpflvIx = grnIx + parseInt(canRepExpMask1[10])
1042
+ const vintrIx = dpflvIx + parseInt(canRepExpMask1[11])
1043
+ const exp2Ix = vintrIx + parseInt(canRepExpMask1[12])
1044
+ const flidIx = exp2Ix + parseInt(canRepExpMask1[13])
1045
+ const vgrwIx = flidIx + parseInt(canRepExpMask1[14])
1046
+ const tireCount =
1029
1047
  canRepExpMask1[15] === '1' && parsedData[vgrwIx + 1]
1030
1048
  ? parseInt(parsedData[vgrwIx + 1], 10)
1031
1049
  : 0
1032
- let tprIx = vgrwIx + (canRepExpMask1[15] === '1' ? 1 + tireCount * 4 : 0)
1033
- let rtsIx = tprIx + parseInt(canRepExpMask1[16])
1034
- let tfrrIx = rtsIx + parseInt(canRepExpMask1[17])
1035
- let tgrsIx = tfrrIx + parseInt(canRepExpMask1[18])
1036
- let dtcsIx = tgrsIx + parseInt(canRepExpMask1[19])
1050
+ const tprIx = vgrwIx + (canRepExpMask1[15] === '1' ? 1 + tireCount * 4 : 0)
1051
+ const rtsIx = tprIx + parseInt(canRepExpMask1[16])
1052
+ const tfrrIx = rtsIx + parseInt(canRepExpMask1[17])
1053
+ const tgrsIx = tfrrIx + parseInt(canRepExpMask1[18])
1054
+ const dtcsIx = tgrsIx + parseInt(canRepExpMask1[19])
1037
1055
 
1038
- let tireNumber =
1056
+ const tireNumber =
1039
1057
  canRepExpMask1[15] === '1' && parsedData[tprIx]
1040
1058
  ? parseInt(parsedData[tprIx], 10)
1041
1059
  : null
1042
- let tires = tireNumber ? Array.from({ length: tireNumber }, (_, i) => i) : []
1043
- let tiresData =
1060
+ const tires = tireNumber
1061
+ ? Array.from({ length: tireNumber }, (_, i) => i)
1062
+ : []
1063
+ const tiresData =
1044
1064
  tires.length > 0
1045
1065
  ? tires.map(tire => {
1046
- return {
1047
- id: tire + 1,
1048
- positionOfAnAxle: parsedData[tprIx + (4 * tire + 1)]
1049
- ? parseInt(parsedData[tprIx + (4 * tire + 1)], 10)
1050
- : null,
1051
- pressure: parsedData[tprIx + (4 * tire + 2)]
1052
- ? parseInt(parsedData[tprIx + (4 * tire + 2)], 10)
1053
- : null,
1054
- temperature: parsedData[tprIx + (4 * tire + 3)]
1055
- ? parseInt(parsedData[tprIx + (4 * tire + 3)], 10)
1056
- : null,
1057
- status: parsedData[tprIx + (4 * tire + 4)]
1058
- ? parseInt(parsedData[tprIx + (4 * tire + 4)], 10)
1059
- : null
1060
- }
1061
- })
1066
+ return {
1067
+ id: tire + 1,
1068
+ positionOfAnAxle: parsedData[tprIx + (4 * tire + 1)]
1069
+ ? parseInt(parsedData[tprIx + (4 * tire + 1)], 10)
1070
+ : null,
1071
+ pressure: parsedData[tprIx + (4 * tire + 2)]
1072
+ ? parseInt(parsedData[tprIx + (4 * tire + 2)], 10)
1073
+ : null,
1074
+ temperature: parsedData[tprIx + (4 * tire + 3)]
1075
+ ? parseInt(parsedData[tprIx + (4 * tire + 3)], 10)
1076
+ : null,
1077
+ status: parsedData[tprIx + (4 * tire + 4)]
1078
+ ? parseInt(parsedData[tprIx + (4 * tire + 4)], 10)
1079
+ : null
1080
+ }
1081
+ })
1062
1082
  : []
1063
1083
 
1064
- let repExpMask1 =
1084
+ const repExpMask1 =
1065
1085
  canExpansionMask[31] === '1'
1066
1086
  ? {
1067
- raw: parsedData[crm1Ix] ? parsedData[crm1Ix] : null,
1068
- bin: canRepExpMask1,
1069
- retarderUsage:
1087
+ raw: parsedData[crm1Ix] ? parsedData[crm1Ix] : null,
1088
+ bin: canRepExpMask1,
1089
+ retarderUsage:
1070
1090
  canRepExpMask1[0] === '1' && parsedData[retIx]
1071
1091
  ? parseInt(parsedData[retIx], 10)
1072
1092
  : null, // percentage
1073
- powerMode:
1093
+ powerMode:
1074
1094
  canRepExpMask1[1] === '1' && parsedData[pwrmIx]
1075
1095
  ? parseInt(parsedData[pwrmIx], 10)
1076
1096
  : null,
1077
- // generatorVoltage: parsedData[genIx] ? parseInt(parsedData[genIx], 10) : null,
1078
- oilTemperature:
1097
+ // generatorVoltage: parsedData[genIx] ? parseInt(parsedData[genIx], 10) : null,
1098
+ oilTemperature:
1079
1099
  canRepExpMask1[4] === '1' && parsedData[oltmIx]
1080
1100
  ? parseInt(parsedData[oltmIx], 10)
1081
1101
  : null,
1082
- oilLevel:
1102
+ oilLevel:
1083
1103
  canRepExpMask1[5] === '1' && parsedData[ollvIx]
1084
1104
  ? parseInt(parsedData[ollvIx], 10)
1085
1105
  : null,
1086
- axleWeight5:
1106
+ axleWeight5:
1087
1107
  canRepExpMask1[6] === '1' && parsedData[ax5Ix]
1088
1108
  ? parseInt(parsedData[ax5Ix], 10)
1089
1109
  : null,
1090
- axleWeight6:
1110
+ axleWeight6:
1091
1111
  canRepExpMask1[7] === '1' && parsedData[ax6Ix]
1092
1112
  ? parseInt(parsedData[ax6Ix], 10)
1093
1113
  : null,
1094
- axleWeight7:
1114
+ axleWeight7:
1095
1115
  canRepExpMask1[8] === '1' && parsedData[ax7Ix]
1096
1116
  ? parseInt(parsedData[ax7Ix], 10)
1097
1117
  : null,
1098
- currentGearNumber:
1118
+ currentGearNumber:
1099
1119
  canRepExpMask1[9] === '1' && parsedData[grnIx]
1100
1120
  ? parseInt(parsedData[grnIx], 10)
1101
1121
  : null,
1102
- dpfSootLevel:
1122
+ dpfSootLevel:
1103
1123
  canRepExpMask1[10] === '1' && parsedData[dpflvIx]
1104
1124
  ? parseCanData(parsedData[dpflvIx], 'dpfSootLevel')
1105
1125
  : null,
1106
- dpgSootLevelUnit:
1126
+ dpgSootLevelUnit:
1107
1127
  canRepExpMask1[10] === '1' && parsedData[dpflvIx]
1108
1128
  ? parseCanData(parsedData[dpflvIx], 'dpgSootLevelUnit')
1109
1129
  : null,
1110
- vinOfTrailer:
1130
+ vinOfTrailer:
1111
1131
  canRepExpMask1[11] === '1' && parsedData[vintrIx]
1112
1132
  ? parsedData[vintrIx]
1113
1133
  : null,
1114
- expansionInformation2:
1134
+ expansionInformation2:
1115
1135
  canRepExpMask1[12] === '1' && parsedData[exp2Ix]
1116
1136
  ? { brakeLiningsWornOffIndicator: parsedData[exp2Ix][7] === '1' }
1117
1137
  : null,
1118
- vehicleGrossWeight:
1138
+ vehicleGrossWeight:
1119
1139
  canRepExpMask1[14] === '1' && parsedData[vgrwIx]
1120
1140
  ? parseInt(parsedData[vgrwIx], 10)
1121
1141
  : null,
1122
- tiresNumber:
1142
+ tiresNumber:
1123
1143
  canRepExpMask1[15] === '1' && parsedData[tprIx]
1124
1144
  ? parseInt(parsedData[tprIx], 10)
1125
1145
  : null,
1126
- tiresData: tiresData,
1127
- remaininTimeToMaintenanceService:
1146
+ tiresData,
1147
+ remaininTimeToMaintenanceService:
1128
1148
  canRepExpMask1[16] === '1' && parsedData[rtsIx]
1129
1149
  ? parseInt(parsedData[rtsIx], 10)
1130
1150
  : null, // days
1131
- totalFuelReadFromVehicleComputer:
1151
+ totalFuelReadFromVehicleComputer:
1132
1152
  canRepExpMask1[17] === '1' && parsedData[tfrrIx]
1133
1153
  ? parseFloat(parsedData[tfrrIx])
1134
1154
  : null, // liters
1135
- totalGaseousFuelUsage:
1155
+ totalGaseousFuelUsage:
1136
1156
  canRepExpMask1[18] === '1' && parsedData[tgrsIx]
1137
1157
  ? parseFloat(parsedData[tgrsIx])
1138
1158
  : null, // kg
1139
- dtcStatus:
1159
+ dtcStatus:
1140
1160
  canRepExpMask1[19] === '1' && parsedData[dtcsIx]
1141
1161
  ? parseCanData(parsedData[dtcsIx], 'dtcStatus')
1142
1162
  : null,
1143
- eGensetReport:
1163
+ eGensetReport:
1144
1164
  canRepExpMask1[3] === '1'
1145
1165
  ? {
1146
- raw: parsedData[egsIx] ? parsedData[egsIx] : null,
1147
- binEgsReportMask: egsReportMask,
1148
- hoursUntilService:
1166
+ raw: parsedData[egsIx] ? parsedData[egsIx] : null,
1167
+ binEgsReportMask: egsReportMask,
1168
+ hoursUntilService:
1149
1169
  egsReportMask[0] === '1' &&
1150
1170
  parsedData[husIx] &&
1151
1171
  parsedData[husIx] !== '65535'
1152
1172
  ? parseInt(parsedData[husIx], 10)
1153
1173
  : null,
1154
- systemStatusHealth:
1174
+ systemStatusHealth:
1155
1175
  egsReportMask[1] === '1' &&
1156
1176
  parsedData[sshIx] &&
1157
1177
  parsedData[sshIx] !== 'FFFF'
1158
1178
  ? parseInt(parsedData[sshIx], 16)
1159
1179
  : null,
1160
- statusInverterMode:
1180
+ statusInverterMode:
1161
1181
  egsReportMask[2] === '1' &&
1162
1182
  parsedData[simIx] &&
1163
1183
  parsedData[simIx] !== '255'
1164
1184
  ? parseInt(parsedData[simIx], 10)
1165
1185
  : null,
1166
- remainingRuntime:
1186
+ remainingRuntime:
1167
1187
  egsReportMask[3] === '1' &&
1168
1188
  parsedData[rrIx] &&
1169
1189
  parsedData[rrIx] !== '255'
1170
1190
  ? parseInt(parsedData[rrIx], 10)
1171
1191
  : null,
1172
- batteryTemperature:
1192
+ batteryTemperature:
1173
1193
  egsReportMask[4] === '1' && parsedData[ebatTmpIx]
1174
1194
  ? parseInt(parsedData[ebatTmpIx], 10)
1175
1195
  : null,
1176
- bmsBoardTemperature:
1196
+ bmsBoardTemperature:
1177
1197
  egsReportMask[5] === '1' && parsedData[bmsTmpIx]
1178
1198
  ? parseInt(parsedData[bmsTmpIx], 10)
1179
1199
  : null,
1180
- batteryVoltage:
1200
+ batteryVoltage:
1181
1201
  egsReportMask[6] === '1' && parsedData[ebatVIx]
1182
1202
  ? parseFloat(parsedData[ebatVIx])
1183
1203
  : null,
1184
- minimumCellVoltage:
1204
+ minimumCellVoltage:
1185
1205
  egsReportMask[7] === '1' && parsedData[minCvIx]
1186
1206
  ? parseFloat(parsedData[minCvIx])
1187
1207
  : null,
1188
- maximumCellVoltage:
1208
+ maximumCellVoltage:
1189
1209
  egsReportMask[8] === '1' && parsedData[maxCvIx]
1190
1210
  ? parseFloat(parsedData[maxCvIx])
1191
1211
  : null,
1192
- maximumCellTemperature:
1212
+ maximumCellTemperature:
1193
1213
  egsReportMask[9] === '1' && parsedData[maxCtIx]
1194
1214
  ? parseInt(parsedData[maxCtIx], 10)
1195
1215
  : null,
1196
- minimumCellTemperature:
1216
+ minimumCellTemperature:
1197
1217
  egsReportMask[10] === '1' && parsedData[minCtIx]
1198
1218
  ? parseInt(parsedData[minCtIx], 10)
1199
1219
  : null,
1200
- moduleBatteryPrewarning:
1220
+ moduleBatteryPrewarning:
1201
1221
  egsReportMask[11] === '1' && parsedData[mbpwIx]
1202
1222
  ? parseInt(parsedData[mbpwIx], 10)
1203
1223
  : null,
1204
- cecuError:
1224
+ cecuError:
1205
1225
  egsReportMask[12] === '1' && parsedData[cecuErrIx]
1206
1226
  ? parseInt(parsedData[cecuErrIx], 10)
1207
1227
  : null,
1208
- cumulativeChargingHours:
1228
+ cumulativeChargingHours:
1209
1229
  egsReportMask[13] === '1' && parsedData[cchIx]
1210
1230
  ? parseFloat(parsedData[cchIx])
1211
1231
  : null,
1212
- inverterAcCurrentL1:
1232
+ inverterAcCurrentL1:
1213
1233
  egsReportMask[14] === '1' && parsedData[iacl1Ix]
1214
1234
  ? parseFloat(parsedData[iacl1Ix])
1215
1235
  : null,
1216
- inverterAcCurrentL2:
1236
+ inverterAcCurrentL2:
1217
1237
  egsReportMask[15] === '1' && parsedData[iacl2Ix]
1218
1238
  ? parseFloat(parsedData[iacl2Ix])
1219
1239
  : null,
1220
- inverterAcCurrentL3:
1240
+ inverterAcCurrentL3:
1221
1241
  egsReportMask[16] === '1' && parsedData[iacl3Ix]
1222
1242
  ? parseFloat(parsedData[iacl3Ix])
1223
1243
  : null,
1224
- inverterAmbientTemperature:
1244
+ inverterAmbientTemperature:
1225
1245
  egsReportMask[17] === '1' && parsedData[iatIx]
1226
1246
  ? parseInt(parsedData[iatIx], 10)
1227
1247
  : null,
1228
- inverterObcTemperature:
1248
+ inverterObcTemperature:
1229
1249
  egsReportMask[18] === '1' && parsedData[iotIx]
1230
1250
  ? parseInt(parsedData[iotIx], 10)
1231
1251
  : null,
1232
- inverterAcVoltageL1:
1252
+ inverterAcVoltageL1:
1233
1253
  egsReportMask[19] === '1' && parsedData[iavl1Ix]
1234
1254
  ? parseFloat(parsedData[iavl1Ix])
1235
1255
  : null,
1236
- inverterAcVoltageL2:
1256
+ inverterAcVoltageL2:
1237
1257
  egsReportMask[20] === '1' && parsedData[iavl2Ix]
1238
1258
  ? parseFloat(parsedData[iavl2Ix])
1239
1259
  : null,
1240
- inverterAcVoltageL3:
1260
+ inverterAcVoltageL3:
1241
1261
  egsReportMask[21] === '1' && parsedData[iavl3Ix]
1242
1262
  ? parseFloat(parsedData[iavl3Ix])
1243
1263
  : null,
1244
- inverterState:
1264
+ inverterState:
1245
1265
  egsReportMask[22] === '1' && parsedData[isIx]
1246
1266
  ? parseInt(parsedData[isIx], 10)
1247
1267
  : null,
1248
- shutDownReason:
1268
+ shutDownReason:
1249
1269
  egsReportMask[23] === '1' && parsedData[sdrIx]
1250
1270
  ? parseInt(parsedData[sdrIx], 10)
1251
1271
  : null,
1252
- cumulativeUsageTime:
1272
+ cumulativeUsageTime:
1253
1273
  egsReportMask[24] === '1' && parsedData[cutIx]
1254
1274
  ? parseFloat(parsedData[cutIx])
1255
1275
  : null,
1256
- cumulativeIdleTime:
1276
+ cumulativeIdleTime:
1257
1277
  egsReportMask[25] === '1' && parsedData[citIx]
1258
1278
  ? parseFloat(parsedData[citIx])
1259
1279
  : null
1260
- }
1280
+ }
1261
1281
  : null
1262
- }
1282
+ }
1263
1283
  : null
1264
1284
 
1265
1285
  // Electric Report Mask
1266
1286
  if (isGV350CEU) {
1267
1287
  elIx = dtcsIx + parseInt(canAppendMask[3])
1268
1288
  }
1269
- let evReportMask =
1289
+ const evReportMask =
1270
1290
  canAppendMask[3] === '1' && parsedData[elIx] !== ''
1271
- ? nHexDigit(hex2bin(parsedData[elIx]), 32)
1272
- .split('')
1273
- .reverse()
1274
- .join('')
1291
+ ? nHexDigit(hex2bin(parsedData[elIx]), 32).split('').reverse().join('')
1275
1292
  : '00000000000000000000000000000000'
1276
1293
 
1277
- let batIVIx = elIx + parseInt(evReportMask[0])
1278
- let batCCCx = batIVIx + parseInt(evReportMask[1])
1279
- let totERIx = batCCCx + parseInt(evReportMask[2])
1280
- let batCLIx = totERIx + parseInt(evReportMask[6])
1281
- let batCSIx = batCLIx + parseInt(evReportMask[7])
1282
- let batTempIx = batCSIx + parseInt(evReportMask[8])
1283
- let batCCIx = batTempIx + parseInt(evReportMask[9])
1284
- let batIPIx = batCCIx + parseInt(evReportMask[10])
1285
- let batSOHx = batIPIx + parseInt(evReportMask[11])
1286
- let totEIx = batSOHx + parseInt(evReportMask[12])
1287
- let totEIWIx = totEIx + parseInt(evReportMask[13])
1288
- let totECIx = totEIWIx + parseInt(evReportMask[14])
1289
- let csOIx = totECIx + parseInt(evReportMask[16])
1290
-
1291
- let evReport =
1294
+ const batIVIx = elIx + parseInt(evReportMask[0])
1295
+ const batCCCx = batIVIx + parseInt(evReportMask[1])
1296
+ const totERIx = batCCCx + parseInt(evReportMask[2])
1297
+ const batCLIx = totERIx + parseInt(evReportMask[6])
1298
+ const batCSIx = batCLIx + parseInt(evReportMask[7])
1299
+ const batTempIx = batCSIx + parseInt(evReportMask[8])
1300
+ const batCCIx = batTempIx + parseInt(evReportMask[9])
1301
+ const batIPIx = batCCIx + parseInt(evReportMask[10])
1302
+ const batSOHx = batIPIx + parseInt(evReportMask[11])
1303
+ const totEIx = batSOHx + parseInt(evReportMask[12])
1304
+ const totEIWIx = totEIx + parseInt(evReportMask[13])
1305
+ const totECIx = totEIWIx + parseInt(evReportMask[14])
1306
+ const csOIx = totECIx + parseInt(evReportMask[16])
1307
+
1308
+ const evReport =
1292
1309
  canAppendMask[3] === '1' && parsedData[elIx] !== '' && isGV350CEU
1293
1310
  ? {
1294
- raw: parsedData[elIx] ? parsedData[elIx] : null,
1295
- binEvReportMask: evReportMask,
1296
- batteryInstantaneousVoltage:
1311
+ raw: parsedData[elIx] ? parsedData[elIx] : null,
1312
+ binEvReportMask: evReportMask,
1313
+ batteryInstantaneousVoltage:
1297
1314
  evReportMask[0] === '1' && parsedData[batIVIx]
1298
1315
  ? parseFloat(parsedData[batIVIx])
1299
1316
  : null,
1300
- batteryChargingCyclesCount:
1317
+ batteryChargingCyclesCount:
1301
1318
  evReportMask[1] === '1' && parsedData[batCCCx]
1302
1319
  ? parseInt(parsedData[batCCCx], 10)
1303
1320
  : null,
1304
- totalEnergyRecuperated:
1321
+ totalEnergyRecuperated:
1305
1322
  evReportMask[2] === '1' && parsedData[totERIx]
1306
1323
  ? parseFloat(parsedData[totERIx])
1307
1324
  : null,
1308
- batteryChargeLevel:
1325
+ batteryChargeLevel:
1309
1326
  evReportMask[6] === '1' && parsedData[batCLIx]
1310
1327
  ? parseFloat(parsedData[batCLIx])
1311
1328
  : null,
1312
- chargingState:
1329
+ chargingState:
1313
1330
  evReportMask[7] === '1' && parsedData[batCSIx]
1314
1331
  ? parseInt(parsedData[batCSIx], 10)
1315
1332
  : null,
1316
- baterryTemperature:
1333
+ baterryTemperature:
1317
1334
  evReportMask[8] === '1' && parsedData[batTempIx]
1318
1335
  ? parseFloat(parsedData[batTempIx])
1319
1336
  : null,
1320
- batteryChargingCurrent:
1337
+ batteryChargingCurrent:
1321
1338
  evReportMask[9] === '1' && parsedData[batCCIx]
1322
1339
  ? parseFloat(parsedData[batCCIx])
1323
1340
  : null,
1324
- batteryInstantaneousPower:
1341
+ batteryInstantaneousPower:
1325
1342
  evReportMask[10] === '1' && parsedData[batIPIx]
1326
1343
  ? parseFloat(parsedData[batIPIx])
1327
1344
  : null,
1328
- batteryStateOfHealth:
1345
+ batteryStateOfHealth:
1329
1346
  evReportMask[11] === '1' && parsedData[batSOHx]
1330
1347
  ? parseInt(parsedData[batSOHx], 10)
1331
1348
  : null,
1332
- totalEnergyUsed:
1349
+ totalEnergyUsed:
1333
1350
  evReportMask[12] === '1' && parsedData[totEIx]
1334
1351
  ? parseFloat(parsedData[totEIx])
1335
1352
  : null,
1336
- totalEnergyUsedWhenIdling:
1353
+ totalEnergyUsedWhenIdling:
1337
1354
  evReportMask[13] === '1' && parsedData[totEIWIx]
1338
1355
  ? parseFloat(parsedData[totEIWIx])
1339
1356
  : null,
1340
- totalEnergyCharged:
1357
+ totalEnergyCharged:
1341
1358
  evReportMask[14] === '1' && parsedData[totECIx]
1342
1359
  ? parseFloat(parsedData[totECIx])
1343
1360
  : null,
1344
- chargeStateOptimization:
1361
+ chargeStateOptimization:
1345
1362
  evReportMask[16] === '1' && parsedData[csOIx]
1346
1363
  ? parseInt(parsedData[csOIx], 10)
1347
1364
  : null
1348
- }
1365
+ }
1349
1366
  : null
1350
1367
 
1351
1368
  // Logic for CAN data
@@ -1358,9 +1375,9 @@ const getCanData = (parsedData, ix, type, options) => {
1358
1375
 
1359
1376
  let gnnsIx = -1
1360
1377
  if (isGV350CEU) {
1361
- let startIx = crm1Ix + 1
1378
+ const startIx = crm1Ix + 1
1362
1379
  for (let i = startIx; i < parsedData.length - 6; i++) {
1363
- let d = parsedData[i + 6]
1380
+ const d = parsedData[i + 6]
1364
1381
  if (d && d.length === 14 && /^\d{14}$/.test(d)) {
1365
1382
  if (
1366
1383
  !isNaN(parseFloat(parsedData[i + 1])) &&
@@ -1379,7 +1396,7 @@ const getCanData = (parsedData, ix, type, options) => {
1379
1396
  : crm1Ix + 2 + parseInt(canAppendMask[1])
1380
1397
  }
1381
1398
 
1382
- let gsmIx = canAppendMask[1] === '1' ? gnnsIx + 7 : gnnsIx
1399
+ const gsmIx = canAppendMask[1] === '1' ? gnnsIx + 7 : gnnsIx
1383
1400
 
1384
1401
  let moreIx
1385
1402
  let gnnsData = null
@@ -1389,90 +1406,81 @@ const getCanData = (parsedData, ix, type, options) => {
1389
1406
  gnnsData =
1390
1407
  canAppendMask[1] === '1'
1391
1408
  ? {
1392
- hdop: parsedData[gnnsIx] ? parseFloat(parsedData[gnnsIx]) : null,
1393
- speed: parsedData[gnnsIx + 1]
1394
- ? parseFloat(parsedData[gnnsIx + 1])
1395
- : null,
1396
- azimuth: parsedData[gnnsIx + 2]
1397
- ? parseFloat(parsedData[gnnsIx + 2])
1398
- : null,
1399
- altitude: parsedData[gnnsIx + 3]
1400
- ? parseFloat(parsedData[gnnsIx + 3])
1401
- : null,
1402
- loc: {
1403
- type: 'Point',
1404
- coordinates: [
1409
+ hdop: parsedData[gnnsIx] ? parseFloat(parsedData[gnnsIx]) : null,
1410
+ speed: parsedData[gnnsIx + 1]
1411
+ ? parseFloat(parsedData[gnnsIx + 1])
1412
+ : null,
1413
+ azimuth: parsedData[gnnsIx + 2]
1414
+ ? parseFloat(parsedData[gnnsIx + 2])
1415
+ : null,
1416
+ altitude: parsedData[gnnsIx + 3]
1417
+ ? parseFloat(parsedData[gnnsIx + 3])
1418
+ : null,
1419
+ loc: {
1420
+ type: 'Point',
1421
+ coordinates: [
1422
+ parseFloat(parsedData[gnnsIx + 4]),
1423
+ parseFloat(parsedData[gnnsIx + 5])
1424
+ ]
1425
+ },
1426
+ gpsStatus: checkGps(
1405
1427
  parseFloat(parsedData[gnnsIx + 4]),
1406
1428
  parseFloat(parsedData[gnnsIx + 5])
1407
- ]
1408
- },
1409
- gpsStatus: checkGps(
1410
- parseFloat(parsedData[gnnsIx + 4]),
1411
- parseFloat(parsedData[gnnsIx + 5])
1412
- ),
1413
- datetime: parsedData[gnnsIx + 6]
1414
- ? parseDate(parsedData[gnnsIx + 6])
1415
- : null
1416
- }
1429
+ ),
1430
+ datetime: parsedData[gnnsIx + 6]
1431
+ ? parseDate(parsedData[gnnsIx + 6])
1432
+ : null
1433
+ }
1417
1434
  : null
1418
1435
 
1419
1436
  gsmData =
1420
1437
  canAppendMask[0] === '1'
1421
1438
  ? {
1422
- mcc:
1439
+ mcc:
1423
1440
  parsedData[gsmIx] !== ''
1424
1441
  ? latamMcc[parseInt(parsedData[gsmIx], 10)]
1425
1442
  : null,
1426
- mnc:
1443
+ mnc:
1427
1444
  parsedData[gsmIx + 1] !== ''
1428
1445
  ? getMNC(parsedData[gsmIx], parsedData[gsmIx + 1])
1429
1446
  : null,
1430
- lac:
1447
+ lac:
1431
1448
  parsedData[gsmIx + 2] !== ''
1432
1449
  ? parseInt(parsedData[gsmIx + 2], 16)
1433
1450
  : null,
1434
- cid:
1451
+ cid:
1435
1452
  parsedData[gsmIx + 3] !== ''
1436
1453
  ? parseInt(parsedData[gsmIx + 3], 16)
1437
1454
  : null
1438
- }
1455
+ }
1439
1456
  : null
1440
1457
  } else {
1441
1458
  moreIx = crm1Ix + 1
1442
1459
  }
1443
1460
 
1444
- let inicatorsBin =
1461
+ const inicatorsBin =
1445
1462
  canAppendMask[14] === '1' && parsedData[indIx] !== ''
1446
1463
  ? nHexDigit(hex2bin(parsedData[indIx]), 16)
1447
1464
  : null
1448
- let lights =
1465
+ const lights =
1449
1466
  canAppendMask[13] === '1' && parsedData[ligIx] !== ''
1450
1467
  ? nHexDigit(hex2bin(parsedData[ligIx]), 8)
1451
1468
  : null
1452
- let doors =
1469
+ const doors =
1453
1470
  canAppendMask[12] === '1' && parsedData[doorIx] !== ''
1454
1471
  ? nHexDigit(hex2bin(parsedData[doorIx]), 8)
1455
1472
  : null
1456
- let expansionBin =
1473
+ const expansionBin =
1457
1474
  parsedData[expbIx] !== ''
1458
- ? nHexDigit(hex2bin(parsedData[expbIx]), 16)
1459
- .split('')
1460
- .reverse()
1461
- .join('')
1475
+ ? nHexDigit(hex2bin(parsedData[expbIx]), 16).split('').reverse().join('')
1462
1476
  : '0000000000000000'
1463
- let tachographBin =
1477
+ const tachographBin =
1464
1478
  canAppendMask[15] === '1' && parsedData[tacIx] !== ''
1465
- ? nHexDigit(hex2bin(parsedData[tacIx]), 8)
1466
- .split('')
1467
- .reverse()
1468
- .join('')
1479
+ ? nHexDigit(hex2bin(parsedData[tacIx]), 8).split('').reverse().join('')
1469
1480
  : null
1470
- let tachographExpBin =
1481
+ const tachographExpBin =
1471
1482
  canAppendMask[30] === '1' && parsedData[tieIx] !== ''
1472
- ? nHexDigit(hex2bin(parsedData[tieIx]), 16)
1473
- .split('')
1474
- .reverse()
1475
- .join('')
1483
+ ? nHexDigit(hex2bin(parsedData[tieIx]), 16).split('').reverse().join('')
1476
1484
  : null
1477
1485
 
1478
1486
  return [
@@ -1525,7 +1533,9 @@ const getCanData = (parsedData, ix, type, options) => {
1525
1533
  : null,
1526
1534
  totalDistanceUnit:
1527
1535
  canAppendMask[29] === '1' && parsedData[disIx]
1528
- ? parsedData[disIx].slice(0, 1) === 'H' ? 'km' : 'I'
1536
+ ? parsedData[disIx].slice(0, 1) === 'H'
1537
+ ? 'km'
1538
+ : 'I'
1529
1539
  : null,
1530
1540
  fuelUsed:
1531
1541
  canAppendMask[28] === '1' && parsedData[fuelIx]
@@ -1553,7 +1563,9 @@ const getCanData = (parsedData, ix, type, options) => {
1553
1563
  : null,
1554
1564
  fuelLevelUnit:
1555
1565
  canAppendMask[23] === '1' && parsedData[fuellIx]
1556
- ? parsedData[fuellIx].slice(0, 1) === 'P' ? '%' : 'L'
1566
+ ? parsedData[fuellIx].slice(0, 1) === 'P'
1567
+ ? '%'
1568
+ : 'L'
1557
1569
  : null,
1558
1570
  range:
1559
1571
  canAppendMask[22] === '1' && parsedData[rngIx]
@@ -1586,63 +1598,63 @@ const getCanData = (parsedData, ix, type, options) => {
1586
1598
  tachograph:
1587
1599
  canAppendMask[15] === '1' && parsedData[tacIx]
1588
1600
  ? {
1589
- raw: parsedData[tacIx] ? parsedData[tacIx] : null,
1590
- validDriverData: tachographBin ? tachographBin[7] === '1' : null,
1591
- insertedDriverCard: tachographBin
1592
- ? tachographBin[5] === '1'
1593
- : null,
1594
- driverWorkingState: tachographBin
1595
- ? dWorkingStates[parseInt(tachographBin.substring(3, 5), 2)]
1596
- : null,
1597
- drivingTimeState: tachographBin
1598
- ? dTimeStates[parseInt(tachographBin.substring(5, 8), 2)]
1599
- : null
1600
- }
1601
+ raw: parsedData[tacIx] ? parsedData[tacIx] : null,
1602
+ validDriverData: tachographBin ? tachographBin[7] === '1' : null,
1603
+ insertedDriverCard: tachographBin
1604
+ ? tachographBin[5] === '1'
1605
+ : null,
1606
+ driverWorkingState: tachographBin
1607
+ ? dWorkingStates[parseInt(tachographBin.substring(3, 5), 2)]
1608
+ : null,
1609
+ drivingTimeState: tachographBin
1610
+ ? dTimeStates[parseInt(tachographBin.substring(5, 8), 2)]
1611
+ : null
1612
+ }
1601
1613
  : null,
1602
1614
  indicators:
1603
1615
  canAppendMask[14] === '1' && inicatorsBin
1604
1616
  ? {
1605
- raw: inicatorsBin ? parsedData[indIx] : null,
1606
- lowFuel: inicatorsBin ? inicatorsBin[0] === '1' : null,
1607
- driverSeatbelt: inicatorsBin ? inicatorsBin[1] === '1' : null,
1608
- airConditioning: inicatorsBin ? inicatorsBin[2] === '1' : null,
1609
- cruiseControl: inicatorsBin ? inicatorsBin[3] === '1' : null,
1610
- brakePedal: inicatorsBin ? inicatorsBin[4] === '1' : null,
1611
- clutchPedal: inicatorsBin ? inicatorsBin[5] === '1' : null,
1612
- handbrake: inicatorsBin ? inicatorsBin[6] === '1' : null,
1613
- centralLock: inicatorsBin ? inicatorsBin[7] === '1' : null,
1614
- reverseGear: inicatorsBin ? inicatorsBin[8] === '1' : null,
1615
- runningLights: inicatorsBin ? inicatorsBin[9] === '1' : null,
1616
- lowBeams: inicatorsBin ? inicatorsBin[10] === '1' : null,
1617
- highBeams: inicatorsBin ? inicatorsBin[11] === '1' : null,
1618
- rearFogLights: inicatorsBin ? inicatorsBin[12] === '1' : null,
1619
- frontFogLights: inicatorsBin ? inicatorsBin[13] === '1' : null,
1620
- doors: inicatorsBin ? inicatorsBin[14] === '1' : null,
1621
- trunk: inicatorsBin ? inicatorsBin[15] === '1' : null
1622
- }
1617
+ raw: inicatorsBin ? parsedData[indIx] : null,
1618
+ lowFuel: inicatorsBin ? inicatorsBin[0] === '1' : null,
1619
+ driverSeatbelt: inicatorsBin ? inicatorsBin[1] === '1' : null,
1620
+ airConditioning: inicatorsBin ? inicatorsBin[2] === '1' : null,
1621
+ cruiseControl: inicatorsBin ? inicatorsBin[3] === '1' : null,
1622
+ brakePedal: inicatorsBin ? inicatorsBin[4] === '1' : null,
1623
+ clutchPedal: inicatorsBin ? inicatorsBin[5] === '1' : null,
1624
+ handbrake: inicatorsBin ? inicatorsBin[6] === '1' : null,
1625
+ centralLock: inicatorsBin ? inicatorsBin[7] === '1' : null,
1626
+ reverseGear: inicatorsBin ? inicatorsBin[8] === '1' : null,
1627
+ runningLights: inicatorsBin ? inicatorsBin[9] === '1' : null,
1628
+ lowBeams: inicatorsBin ? inicatorsBin[10] === '1' : null,
1629
+ highBeams: inicatorsBin ? inicatorsBin[11] === '1' : null,
1630
+ rearFogLights: inicatorsBin ? inicatorsBin[12] === '1' : null,
1631
+ frontFogLights: inicatorsBin ? inicatorsBin[13] === '1' : null,
1632
+ doors: inicatorsBin ? inicatorsBin[14] === '1' : null,
1633
+ trunk: inicatorsBin ? inicatorsBin[15] === '1' : null
1634
+ }
1623
1635
  : null,
1624
1636
  lights:
1625
1637
  canAppendMask[13] === '1' && lights
1626
1638
  ? {
1627
- raw: lights ? parsedData[ligIx] : null,
1628
- running: lights ? lights[0] === '1' : null,
1629
- lowBeams: lights ? lights[1] === '1' : null,
1630
- frontFog: lights ? lights[2] === '1' : null,
1631
- rearFog: lights ? lights[3] === '1' : null,
1632
- hazard: lights ? lights[4] === '1' : null
1633
- }
1639
+ raw: lights ? parsedData[ligIx] : null,
1640
+ running: lights ? lights[0] === '1' : null,
1641
+ lowBeams: lights ? lights[1] === '1' : null,
1642
+ frontFog: lights ? lights[2] === '1' : null,
1643
+ rearFog: lights ? lights[3] === '1' : null,
1644
+ hazard: lights ? lights[4] === '1' : null
1645
+ }
1634
1646
  : null,
1635
1647
  doors:
1636
1648
  canAppendMask[12] === '1' && doors
1637
1649
  ? {
1638
- raw: doors ? parsedData[doorIx] : null,
1639
- driver: doors ? doors[0] === '1' : null,
1640
- passenger: doors ? doors[1] === '1' : null,
1641
- rearLeft: doors ? doors[2] === '1' : null,
1642
- rearRight: doors ? doors[3] === '1' : null,
1643
- trunk: doors ? doors[4] === '1' : null,
1644
- hood: doors ? doors[5] === '1' : null
1645
- }
1650
+ raw: doors ? parsedData[doorIx] : null,
1651
+ driver: doors ? doors[0] === '1' : null,
1652
+ passenger: doors ? doors[1] === '1' : null,
1653
+ rearLeft: doors ? doors[2] === '1' : null,
1654
+ rearRight: doors ? doors[3] === '1' : null,
1655
+ trunk: doors ? doors[4] === '1' : null,
1656
+ hood: doors ? doors[5] === '1' : null
1657
+ }
1646
1658
  : null,
1647
1659
  overSpeedTime:
1648
1660
  canAppendMask[11] === '1' && parsedData[osptIx]
@@ -1680,7 +1692,9 @@ const getCanData = (parsedData, ix, type, options) => {
1680
1692
  : null,
1681
1693
  adBlueLevelUnit:
1682
1694
  repExpMask && repExpMask.adBlueLevelUnit && parsedData[adbIx]
1683
- ? parsedData[adbIx].slice(0, 1) === 'P' ? '%' : 'L'
1695
+ ? parsedData[adbIx].slice(0, 1) === 'P'
1696
+ ? '%'
1697
+ : 'L'
1684
1698
  : null,
1685
1699
  axleWeight1:
1686
1700
  repExpMask && repExpMask.axleWeight1 && parsedData[ax1Ix]
@@ -1773,20 +1787,20 @@ const getCanData = (parsedData, ix, type, options) => {
1773
1787
  repExpMask.expansionInformation &&
1774
1788
  expansionBin !== '0000000000000000'
1775
1789
  ? {
1776
- raw: parsedData[expbIx] ? parsedData[expbIx] : null,
1777
- webasto: expansionBin[0] === '1',
1778
- brakeFluidLowIndicator: expansionBin[1] === '1',
1779
- coolantLevelLowIndicator: expansionBin[2] === '1',
1780
- batteryIndicator: expansionBin[3] === '1',
1781
- brakeSystemFailureIndicator: expansionBin[4] === '1',
1782
- oilPressureIndicator: expansionBin[5] === '1',
1783
- engineHotIndicator: expansionBin[6] === '1',
1784
- ABSFailureIndicator: expansionBin[7] === '1',
1785
- checkEngineIndicator: expansionBin[9] === '1',
1786
- airbagsIndicator: expansionBin[10] === '1',
1787
- serviceCallIndicator: expansionBin[11] === '1',
1788
- oilLevelLowIndicator: expansionBin[12] === '1'
1789
- }
1790
+ raw: parsedData[expbIx] ? parsedData[expbIx] : null,
1791
+ webasto: expansionBin[0] === '1',
1792
+ brakeFluidLowIndicator: expansionBin[1] === '1',
1793
+ coolantLevelLowIndicator: expansionBin[2] === '1',
1794
+ batteryIndicator: expansionBin[3] === '1',
1795
+ brakeSystemFailureIndicator: expansionBin[4] === '1',
1796
+ oilPressureIndicator: expansionBin[5] === '1',
1797
+ engineHotIndicator: expansionBin[6] === '1',
1798
+ ABSFailureIndicator: expansionBin[7] === '1',
1799
+ checkEngineIndicator: expansionBin[9] === '1',
1800
+ airbagsIndicator: expansionBin[10] === '1',
1801
+ serviceCallIndicator: expansionBin[11] === '1',
1802
+ oilLevelLowIndicator: expansionBin[12] === '1'
1803
+ }
1790
1804
  : null,
1791
1805
  rapidBrakings:
1792
1806
  repExpMask && repExpMask.rapidBrakings && parsedData[rbrIx]
@@ -1819,45 +1833,45 @@ const getCanData = (parsedData, ix, type, options) => {
1819
1833
  tachographInfoExpansion:
1820
1834
  repExpMask && repExpMask.tachographInfoExpansion
1821
1835
  ? {
1822
- raw: parsedData[tieIx],
1823
- tachographExpBin: tachographExpBin,
1824
- outOfScope:
1836
+ raw: parsedData[tieIx],
1837
+ tachographExpBin,
1838
+ outOfScope:
1825
1839
  tachographExpBin.substring(0, 2) === '00'
1826
1840
  ? 'normal operation'
1827
1841
  : tachographExpBin.substring(15, 2) === '01'
1828
1842
  ? 'out of scope'
1829
1843
  : 'invalid data',
1830
- driverWorkingState1:
1844
+ driverWorkingState1:
1831
1845
  dWorkingStatesExpansion[
1832
1846
  parseInt(tachographExpBin.substring(2, 5), 2)
1833
1847
  ],
1834
- driverWorkingState2:
1848
+ driverWorkingState2:
1835
1849
  dWorkingStatesExpansion[
1836
1850
  parseInt(tachographExpBin.substring(5, 8), 2)
1837
1851
  ],
1838
- insertedDriverCard1:
1852
+ insertedDriverCard1:
1839
1853
  tachographExpBin.substring(10, 12) === '00'
1840
1854
  ? 'no driver card'
1841
1855
  : tachographExpBin.substring(11, 13) === '01'
1842
1856
  ? 'driver card inserted'
1843
1857
  : 'invalid data',
1844
- insertedDriverCard2:
1858
+ insertedDriverCard2:
1845
1859
  tachographExpBin.substring(18, 20) === '00'
1846
1860
  ? 'no driver card'
1847
1861
  : tachographExpBin.substring(13, 15) === '01'
1848
1862
  ? 'driver card inserted'
1849
1863
  : 'invalid data',
1850
- drivingTimeState1:
1864
+ drivingTimeState1:
1851
1865
  dTimeStates[parseInt(tachographExpBin.substring(12, 16), 2)],
1852
- drivingTimeState2:
1866
+ drivingTimeState2:
1853
1867
  dTimeStates[parseInt(tachographExpBin.substring(20, 24), 2)],
1854
- vehicleMotion:
1868
+ vehicleMotion:
1855
1869
  tachographExpBin.substring(26, 28) === '00'
1856
1870
  ? 'not detected'
1857
1871
  : tachographExpBin.substring(24, 26) === '01'
1858
1872
  ? 'detected'
1859
1873
  : 'invalid data',
1860
- drivingDirection:
1874
+ drivingDirection:
1861
1875
  tachographExpBin.substring(28, 30) === '000'
1862
1876
  ? 'forward'
1863
1877
  : tachographExpBin.substring(26, 29) === '001'
@@ -1867,13 +1881,13 @@ const getCanData = (parsedData, ix, type, options) => {
1867
1881
  : tachographExpBin.substring(26, 29) === '011'
1868
1882
  ? 'right'
1869
1883
  : 'invalid data',
1870
- overspeed:
1884
+ overspeed:
1871
1885
  tachographExpBin.substring(30, 32) === '00'
1872
1886
  ? 'not detected'
1873
1887
  : tachographExpBin.substring(29, 31) === '01'
1874
1888
  ? 'detected'
1875
1889
  : 'invalid data'
1876
- }
1890
+ }
1877
1891
  : null,
1878
1892
  canReportExpansionMask1:
1879
1893
  repExpMask && repExpMask.canReportExpansionMask1 && parsedData[crm1Ix]
@@ -1882,22 +1896,22 @@ const getCanData = (parsedData, ix, type, options) => {
1882
1896
  },
1883
1897
  electricVehicles: evReport
1884
1898
  ? {
1885
- raw: evReport.raw,
1886
- binevReportMask: evReport.binevReportMask,
1887
- chargeStateOptimization: evReport.chargeStateOptimization,
1888
- totalEnergyCharged: evReport.totalEnergyCharged
1889
- ? parseFloat(evReport.totalEnergyCharged)
1890
- : null,
1891
- totalEnergyUsedWhenIdling: evReport.totalEnergyUsedWhenIdling
1892
- ? parseFloat(evReport.totalEnergyUsedWhenIdling)
1893
- : null,
1894
- totalEnergyUsed: evReport.totalEnergyUsed
1895
- ? parseFloat(evReport.totalEnergyUsed)
1896
- : null,
1897
- batteryStateOfHealth: evReport.batteryStateOfHealth
1898
- ? parseFloat(evReport.batteryStateOfHealth)
1899
- : null
1900
- }
1899
+ raw: evReport.raw,
1900
+ binevReportMask: evReport.binevReportMask,
1901
+ chargeStateOptimization: evReport.chargeStateOptimization,
1902
+ totalEnergyCharged: evReport.totalEnergyCharged
1903
+ ? parseFloat(evReport.totalEnergyCharged)
1904
+ : null,
1905
+ totalEnergyUsedWhenIdling: evReport.totalEnergyUsedWhenIdling
1906
+ ? parseFloat(evReport.totalEnergyUsedWhenIdling)
1907
+ : null,
1908
+ totalEnergyUsed: evReport.totalEnergyUsed
1909
+ ? parseFloat(evReport.totalEnergyUsed)
1910
+ : null,
1911
+ batteryStateOfHealth: evReport.batteryStateOfHealth
1912
+ ? parseFloat(evReport.batteryStateOfHealth)
1913
+ : null
1914
+ }
1901
1915
  : null
1902
1916
  }
1903
1917
  ]
@@ -1907,43 +1921,43 @@ const getCanData = (parsedData, ix, type, options) => {
1907
1921
  Get Bluetooth data
1908
1922
  */
1909
1923
  const getBleData = (parsedData, btIndex) => {
1910
- let btDevices = []
1924
+ const btDevices = []
1911
1925
  let cnt = btIndex + 1
1912
- let btNum = parsedData[btIndex] !== '' ? parseInt(parsedData[btIndex]) : 1
1926
+ const btNum = parsedData[btIndex] !== '' ? parseInt(parsedData[btIndex]) : 1
1913
1927
 
1914
1928
  for (let c = 0; c < btNum; c++) {
1915
1929
  if (!['FE', 'FF'].includes(parsedData[cnt])) {
1916
- let appendMask = nHexDigit(hex2bin(parsedData[cnt + 4]), 16)
1917
- let aNameIx = cnt + 4 + parseInt(appendMask[15])
1918
- let aMacIx = aNameIx + parseInt(appendMask[14])
1919
- let aStatIx = aMacIx + parseInt(appendMask[13])
1920
- let aBatIx = aStatIx + parseInt(appendMask[12])
1921
- let aTmpIx = aBatIx + parseInt(appendMask[11])
1922
- let aHumIx = aTmpIx + parseInt(appendMask[10])
1923
- let ioIx = aHumIx + parseInt(appendMask[8])
1924
- let aEvIx =
1930
+ const appendMask = nHexDigit(hex2bin(parsedData[cnt + 4]), 16)
1931
+ const aNameIx = cnt + 4 + parseInt(appendMask[15])
1932
+ const aMacIx = aNameIx + parseInt(appendMask[14])
1933
+ const aStatIx = aMacIx + parseInt(appendMask[13])
1934
+ const aBatIx = aStatIx + parseInt(appendMask[12])
1935
+ const aTmpIx = aBatIx + parseInt(appendMask[11])
1936
+ const aHumIx = aTmpIx + parseInt(appendMask[10])
1937
+ const ioIx = aHumIx + parseInt(appendMask[8])
1938
+ const aEvIx =
1925
1939
  appendMask[8] === '1' && appendMask[7] === '1'
1926
1940
  ? ioIx + 3
1927
1941
  : ioIx + parseInt(appendMask[7])
1928
- let pressIx =
1942
+ const pressIx =
1929
1943
  appendMask[7] === '1' && appendMask[6] === '1'
1930
1944
  ? aEvIx + 2
1931
1945
  : aEvIx + parseInt(appendMask[6])
1932
- let timeIx = pressIx + parseInt(appendMask[5])
1933
- let eTmpIx = timeIx + parseInt(appendMask[4])
1934
- let magIx = eTmpIx + parseInt(appendMask[3])
1935
- let aBatpIx =
1946
+ const timeIx = pressIx + parseInt(appendMask[5])
1947
+ const eTmpIx = timeIx + parseInt(appendMask[4])
1948
+ const magIx = eTmpIx + parseInt(appendMask[3])
1949
+ const aBatpIx =
1936
1950
  appendMask[3] === '1' && appendMask[2] === '1'
1937
1951
  ? magIx + 3
1938
1952
  : magIx + parseInt(appendMask[2])
1939
- let relIx = aBatpIx + parseInt(appendMask[1])
1953
+ const relIx = aBatpIx + parseInt(appendMask[1])
1940
1954
 
1941
- let bleType = bluetoothAccessories[parsedData[cnt + 1]]
1942
- let bleModel =
1955
+ const bleType = bluetoothAccessories[parsedData[cnt + 1]]
1956
+ const bleModel =
1943
1957
  parsedData[cnt + 2] !== ''
1944
1958
  ? bluetoothModels[parsedData[cnt + 1]][parsedData[cnt + 2]]
1945
1959
  : null
1946
- let rawAppendMask = parsedData[cnt + 4]
1960
+ const rawAppendMask = parsedData[cnt + 4]
1947
1961
 
1948
1962
  btDevices.push({
1949
1963
  index: parsedData[cnt],
@@ -1974,28 +1988,28 @@ const getBleData = (parsedData, btIndex) => {
1974
1988
  data:
1975
1989
  parsedData[cnt + 3] !== ''
1976
1990
  ? {
1977
- raw: parsedData[cnt + 3],
1978
- temperature: getBleTempInCelciousDegrees(
1979
- bleModel,
1980
- parsedData[cnt + 3]
1981
- ),
1982
- humidity: getBleHumidityInRH(bleModel, parsedData[cnt + 3]),
1983
- relayState:
1991
+ raw: parsedData[cnt + 3],
1992
+ temperature: getBleTempInCelciousDegrees(
1993
+ bleModel,
1994
+ parsedData[cnt + 3]
1995
+ ),
1996
+ humidity: getBleHumidityInRH(bleModel, parsedData[cnt + 3]),
1997
+ relayState:
1984
1998
  bleModel === 'WRL300'
1985
1999
  ? parseInt(parsedData[cnt + 3]) === 1
1986
2000
  ? 'Connected'
1987
2001
  : 'Disconnected'
1988
2002
  : null,
1989
- tirePresure: getTirePressureInPSI(parsedData[cnt + 3]),
1990
- productModel:
2003
+ tirePresure: getTirePressureInPSI(parsedData[cnt + 3]),
2004
+ productModel:
1991
2005
  bleModel === 'ATP100/ATP102'
1992
2006
  ? parsedData[cnt + 3].substring(6, 7)
1993
2007
  : null,
1994
- fwVersion:
2008
+ fwVersion:
1995
2009
  bleModel === 'ATP100/ATP102'
1996
2010
  ? parsedData[cnt + 3].substring(7, 8)
1997
2011
  : null
1998
- }
2012
+ }
1999
2013
  : null,
2000
2014
  temperature:
2001
2015
  parsedData[aTmpIx] !== '' && appendMask[11] === '1'
@@ -2057,11 +2071,11 @@ const getBleData = (parsedData, btIndex) => {
2057
2071
  })
2058
2072
  cnt = relIx + 1
2059
2073
  } else {
2060
- let appendMask = nHexDigit(hex2bin(parsedData[cnt + 3]), 8)
2061
- let aMacIx = cnt + 3 + parseInt(appendMask[6])
2062
- let aBatIx = aMacIx + parseInt(appendMask[4])
2063
- let aSigIx = aBatIx + parseInt(appendMask[1])
2064
- let bTypeIx = aSigIx + parseInt(appendMask[0])
2074
+ const appendMask = nHexDigit(hex2bin(parsedData[cnt + 3]), 8)
2075
+ const aMacIx = cnt + 3 + parseInt(appendMask[6])
2076
+ const aBatIx = aMacIx + parseInt(appendMask[4])
2077
+ const aSigIx = aBatIx + parseInt(appendMask[1])
2078
+ const bTypeIx = aSigIx + parseInt(appendMask[0])
2065
2079
 
2066
2080
  btDevices.push({
2067
2081
  index: parsedData[cnt],
@@ -2100,7 +2114,7 @@ const getBleData = (parsedData, btIndex) => {
2100
2114
  Gets the alarm type
2101
2115
  */
2102
2116
  const getAlarm = (command, report, extra = false) => {
2103
- const messages = langs['es']
2117
+ const messages = langs.es
2104
2118
  if (
2105
2119
  command === 'GTFRI' ||
2106
2120
  command === 'GTERI' ||
@@ -2232,7 +2246,7 @@ const getAlarm = (command, report, extra = false) => {
2232
2246
  type: 'DI',
2233
2247
  number: 1,
2234
2248
  status: true,
2235
- duration: duration,
2249
+ duration,
2236
2250
  message: messages[command]
2237
2251
  }
2238
2252
  } else if (command === 'GTIGF') {
@@ -2241,7 +2255,7 @@ const getAlarm = (command, report, extra = false) => {
2241
2255
  type: 'DI',
2242
2256
  number: 1,
2243
2257
  status: false,
2244
- duration: duration,
2258
+ duration,
2245
2259
  message: messages[command]
2246
2260
  }
2247
2261
  } else if (command === 'GTVGN') {
@@ -2250,7 +2264,7 @@ const getAlarm = (command, report, extra = false) => {
2250
2264
  type: 'DI',
2251
2265
  number: 1,
2252
2266
  status: true,
2253
- duration: duration,
2267
+ duration,
2254
2268
  message: messages[command][report[1]]
2255
2269
  }
2256
2270
  } else if (command === 'GTVGF') {
@@ -2259,7 +2273,7 @@ const getAlarm = (command, report, extra = false) => {
2259
2273
  type: 'DI',
2260
2274
  number: 1,
2261
2275
  status: false,
2262
- duration: duration,
2276
+ duration,
2263
2277
  message: messages[command][report[1]]
2264
2278
  }
2265
2279
  } else if (command === 'GTPNA') {
@@ -2271,6 +2285,7 @@ const getAlarm = (command, report, extra = false) => {
2271
2285
  type: 'Power_Reason',
2272
2286
  status: command === 'GTPNR',
2273
2287
  dailyWakeup: report === '09' || false,
2288
+ reason: report,
2274
2289
  message: messages[command][report]
2275
2290
  }
2276
2291
  } else if (command === 'GTMPN' || command === 'GTEPN') {
@@ -2293,7 +2308,7 @@ const getAlarm = (command, report, extra = false) => {
2293
2308
  return {
2294
2309
  type: 'Idling',
2295
2310
  status: false,
2296
- duration: duration,
2311
+ duration,
2297
2312
  message: messages[command]
2298
2313
  }
2299
2314
  } else if (command === 'GTJDR') {
@@ -2302,7 +2317,7 @@ const getAlarm = (command, report, extra = false) => {
2302
2317
  type: 'Jamming',
2303
2318
  status: true,
2304
2319
  gps: false,
2305
- jammingNetwork: jammingNetwork,
2320
+ jammingNetwork,
2306
2321
  message: jammingNetwork
2307
2322
  ? `${messages[command]}: ${jammingNetworkTypes[report]}`
2308
2323
  : messages[command]
@@ -2394,10 +2409,10 @@ const getAlarm = (command, report, extra = false) => {
2394
2409
  const temperature = extra[1] !== '' ? parseFloat(extra[1]) : null
2395
2410
  return {
2396
2411
  type: 'Outside_Temperature',
2397
- number: number,
2412
+ number,
2398
2413
  deviceID: extra[0],
2399
2414
  status: report[1] === '0', // 0 means outside the range, 1 means inside
2400
- temperature: temperature,
2415
+ temperature,
2401
2416
  message: messages[command][report[1]].replace('()', `(${temperature}°C)`)
2402
2417
  }
2403
2418
  } else if (command === 'GTFLA') {
@@ -2419,7 +2434,7 @@ const getAlarm = (command, report, extra = false) => {
2419
2434
  return {
2420
2435
  type: 'Driver_Identification',
2421
2436
  status: status === 1,
2422
- driverID: driverID,
2437
+ driverID,
2423
2438
  message: messages[command][status]
2424
2439
  }
2425
2440
  } else if (command === 'GTDOS') {
@@ -2492,20 +2507,20 @@ const getAlarm = (command, report, extra = false) => {
2492
2507
  4: acceleration turning
2493
2508
  5: unknown harsh behavior
2494
2509
  */
2495
- let x = getAccelerationMagnitude(extra[0].substring(0, 4), 4)
2496
- let y = getAccelerationMagnitude(extra[0].substring(4, 8), 4)
2497
- let z = getAccelerationMagnitude(extra[0].substring(8, 12), 4)
2498
- let duration = extra[1]
2499
- let magnitude = Number(
2510
+ const x = getAccelerationMagnitude(extra[0].substring(0, 4), 4)
2511
+ const y = getAccelerationMagnitude(extra[0].substring(4, 8), 4)
2512
+ const z = getAccelerationMagnitude(extra[0].substring(8, 12), 4)
2513
+ const duration = extra[1]
2514
+ const magnitude = Number(
2500
2515
  Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2)).toFixed(2)
2501
2516
  ).toString()
2502
2517
  return {
2503
2518
  type: 'Harsh_Behavior',
2504
2519
  status: parseInt(report[1], 10),
2505
2520
  calibration: report[0] === '2',
2506
- duration: duration,
2507
- magnitude: magnitude,
2508
- xyz: { x: x, y: y, z: z },
2521
+ duration,
2522
+ magnitude,
2523
+ xyz: { x, y, z },
2509
2524
  message: messages[command][report[1]]
2510
2525
  .replace('X', magnitude)
2511
2526
  .replace('Z', duration)
@@ -2556,7 +2571,9 @@ const getAlarm = (command, report, extra = false) => {
2556
2571
  const instruction =
2557
2572
  command === 'GTALS'
2558
2573
  ? report.split(',')[4]
2559
- : command === 'GTALM' ? report.split(',')[6] : report.split(',')[7]
2574
+ : command === 'GTALC'
2575
+ ? report.split(',')[6]
2576
+ : report.split(',')[7]
2560
2577
  return {
2561
2578
  type: command,
2562
2579
  status: instruction,
@@ -2578,8 +2595,8 @@ const getAlarm = (command, report, extra = false) => {
2578
2595
  selfCalibration: report.split(',')[4] === '2'
2579
2596
  }
2580
2597
  } else if (command === 'GTLBA') {
2581
- let type = report[0]
2582
- let serial = report[1]
2598
+ const type = report[0]
2599
+ const serial = report[1]
2583
2600
  return {
2584
2601
  type: command,
2585
2602
  status: 'BT_Low_Battery',
@@ -2607,8 +2624,8 @@ const getAlarm = (command, report, extra = false) => {
2607
2624
  message:
2608
2625
  report[0] !== '' && report[1] !== ''
2609
2626
  ? messages[command]
2610
- .replace('data0', getVersion(report[0]))
2611
- .replace('data1', getVersion(report[1]))
2627
+ .replace('data0', getVersion(report[0]))
2628
+ .replace('data1', getVersion(report[1]))
2612
2629
  : 'Datos de versión incompletos'
2613
2630
  }
2614
2631
  } else if (command === 'GTBCS') {
@@ -2625,10 +2642,10 @@ const getAlarm = (command, report, extra = false) => {
2625
2642
  const status = report !== '03' // 01 & 02 means outside range, 03 means inside range
2626
2643
  return {
2627
2644
  type: 'Outside_Temperature',
2628
- number: number,
2645
+ number,
2629
2646
  deviceID: mac,
2630
- status: status,
2631
- temperature: temperature,
2647
+ status,
2648
+ temperature,
2632
2649
  message: messages[command][report].replace('()', `(${temperature}°C)`)
2633
2650
  }
2634
2651
  } else if (report === '20') {
@@ -2637,7 +2654,7 @@ const getAlarm = (command, report, extra = false) => {
2637
2654
  const mac = extra[1]
2638
2655
  return {
2639
2656
  type: 'SOS_Button',
2640
- number: number,
2657
+ number,
2641
2658
  deviceID: mac,
2642
2659
  voltage: extra[2].voltage ? extra[2].voltage : null,
2643
2660
  message: messages[command][report]
@@ -2649,10 +2666,10 @@ const getAlarm = (command, report, extra = false) => {
2649
2666
  const status = report !== '09' // 07 & 08 means outside range, 09 means inside range
2650
2667
  return {
2651
2668
  type: 'Outside_Humidity',
2652
- number: number,
2669
+ number,
2653
2670
  deviceID: mac,
2654
- status: status,
2655
- humidity: humidity,
2671
+ status,
2672
+ humidity,
2656
2673
  message: messages[command][report].replace('()', `(${humidity}%)`)
2657
2674
  }
2658
2675
  } else if (['0E', '0F', '10'].includes(report)) {
@@ -2662,10 +2679,10 @@ const getAlarm = (command, report, extra = false) => {
2662
2679
  const status = report !== '10' // 0E & 0F means outside range, 10 means inside range
2663
2680
  return {
2664
2681
  type: 'Outside_Tire_Pressure',
2665
- number: number,
2682
+ number,
2666
2683
  deviceID: mac,
2667
- status: status,
2668
- pressure: pressure,
2684
+ status,
2685
+ pressure,
2669
2686
  message: messages[command][report].replace('()', `(${pressure}kPa)`)
2670
2687
  }
2671
2688
  } else if (report === '15') {
@@ -2678,10 +2695,10 @@ const getAlarm = (command, report, extra = false) => {
2678
2695
  : null
2679
2696
  return {
2680
2697
  type: 'Relay_BLE',
2681
- number: number,
2698
+ number,
2682
2699
  deviceID: mac,
2683
- status: status,
2684
- configResult: configResult,
2700
+ status,
2701
+ configResult,
2685
2702
  message: messages[command][report].replace('__', `${humanStatus}`)
2686
2703
  }
2687
2704
  } else {
@@ -2736,54 +2753,42 @@ const ConvertBase = num => {
2736
2753
  Converts binary to decimal number
2737
2754
  */
2738
2755
  const bin2dec = num => {
2739
- return ConvertBase(num)
2740
- .from(2)
2741
- .to(10)
2756
+ return ConvertBase(num).from(2).to(10)
2742
2757
  }
2743
2758
 
2744
2759
  /*
2745
2760
  Converts binary to hexadecimal number
2746
2761
  */
2747
2762
  const bin2hex = num => {
2748
- return ConvertBase(num)
2749
- .from(2)
2750
- .to(16)
2763
+ return ConvertBase(num).from(2).to(16)
2751
2764
  }
2752
2765
 
2753
2766
  /*
2754
2767
  Converts decimal to binary number
2755
2768
  */
2756
2769
  const dec2bin = num => {
2757
- return ConvertBase(num)
2758
- .from(10)
2759
- .to(2)
2770
+ return ConvertBase(num).from(10).to(2)
2760
2771
  }
2761
2772
 
2762
2773
  /*
2763
2774
  Converts decimal to hexadecimal number
2764
2775
  */
2765
2776
  const dec2hex = num => {
2766
- return ConvertBase(num)
2767
- .from(10)
2768
- .to(16)
2777
+ return ConvertBase(num).from(10).to(16)
2769
2778
  }
2770
2779
 
2771
2780
  /*
2772
2781
  Converts hexadecimal to binary number
2773
2782
  */
2774
2783
  const hex2bin = num => {
2775
- return ConvertBase(num)
2776
- .from(16)
2777
- .to(2)
2784
+ return ConvertBase(num).from(16).to(2)
2778
2785
  }
2779
2786
 
2780
2787
  /*
2781
2788
  Converts hexadecimal to decimal number
2782
2789
  */
2783
2790
  const hex2dec = num => {
2784
- return ConvertBase(num)
2785
- .from(16)
2786
- .to(10)
2791
+ return ConvertBase(num).from(16).to(10)
2787
2792
  }
2788
2793
 
2789
2794
  /*
@@ -2802,7 +2807,7 @@ const nHexDigit = (num, n) => {
2802
2807
  */
2803
2808
  const sumOnes = num => {
2804
2809
  let sum = 0
2805
- let bin = hex2bin(num)
2810
+ const bin = hex2bin(num)
2806
2811
  for (let i = 0; i < bin.length; i++) {
2807
2812
  sum += parseInt(bin[i])
2808
2813
  }
@@ -2823,55 +2828,55 @@ const parseDate = date => {
2823
2828
  }
2824
2829
 
2825
2830
  module.exports = {
2826
- langs: langs,
2827
- patterns: patterns,
2828
- nackCauses: nackCauses,
2829
- OBDIIProtocols: OBDIIProtocols,
2830
- states: states,
2831
- uartDeviceTypes: uartDeviceTypes,
2832
- networkTypes: networkTypes,
2833
- gpsSignalStrength: gpsSignalStrength,
2834
- externalGPSAntennaOptions: externalGPSAntennaOptions,
2835
- peerRoles: peerRoles,
2836
- peerAddressesTypes: peerAddressesTypes,
2837
- disconnectionReasons: disconnectionReasons,
2838
- bluetoothAccessories: bluetoothAccessories,
2839
- bluetoothModels: bluetoothModels,
2840
- bleTempHumSensors: bleTempHumSensors,
2841
- beaconModels: beaconModels,
2842
- beaconTypes: beaconTypes,
2843
- relayBLEResults: relayBLEResults,
2844
- dTimeStates: dTimeStates,
2845
- dWorkingStates: dWorkingStates,
2846
- gnssTriggerTypes: gnssTriggerTypes,
2847
- jammingSateTypes: jammingSateTypes,
2848
- latamMcc: latamMcc,
2849
- getDevice: getDevice,
2850
- getProtocolVersion: getProtocolVersion,
2851
- checkGps: checkGps,
2852
- includeJammingSate: includeJammingSate,
2853
- includeSatellites: includeSatellites,
2854
- includeGnssTrigger: includeGnssTrigger,
2855
- includeStatus: includeStatus,
2856
- includeGnnsAccuracy: includeGnnsAccuracy,
2857
- getAccelerationMagnitude: getAccelerationMagnitude,
2858
- getTempInCelciousDegrees: getTempInCelciousDegrees,
2859
- getFuelConsumption: getFuelConsumption,
2860
- getHoursForHourmeter: getHoursForHourmeter,
2861
- getSignalStrength: getSignalStrength,
2862
- getSignalPercentage: getSignalPercentage,
2863
- getCanData: getCanData,
2864
- getBleData: getBleData,
2865
- getAlarm: getAlarm,
2866
- createDefaultOut: createDefaultOut,
2867
- bin2dec: bin2dec,
2868
- bin2hex: bin2hex,
2869
- dec2bin: dec2bin,
2870
- dec2hex: dec2hex,
2871
- hex2bin: hex2bin,
2872
- hex2dec: hex2dec,
2873
- nHexDigit: nHexDigit,
2874
- sumOnes: sumOnes,
2875
- parseDate: parseDate,
2876
- getMNC: getMNC
2831
+ langs,
2832
+ patterns,
2833
+ nackCauses,
2834
+ OBDIIProtocols,
2835
+ states,
2836
+ uartDeviceTypes,
2837
+ networkTypes,
2838
+ gpsSignalStrength,
2839
+ externalGPSAntennaOptions,
2840
+ peerRoles,
2841
+ peerAddressesTypes,
2842
+ disconnectionReasons,
2843
+ bluetoothAccessories,
2844
+ bluetoothModels,
2845
+ bleTempHumSensors,
2846
+ beaconModels,
2847
+ beaconTypes,
2848
+ relayBLEResults,
2849
+ dTimeStates,
2850
+ dWorkingStates,
2851
+ gnssTriggerTypes,
2852
+ jammingSateTypes,
2853
+ latamMcc,
2854
+ getDevice,
2855
+ getProtocolVersion,
2856
+ checkGps,
2857
+ includeJammingSate,
2858
+ includeSatellites,
2859
+ includeGnssTrigger,
2860
+ includeStatus,
2861
+ includeGnnsAccuracy,
2862
+ getAccelerationMagnitude,
2863
+ getTempInCelciousDegrees,
2864
+ getFuelConsumption,
2865
+ getHoursForHourmeter,
2866
+ getSignalStrength,
2867
+ getSignalPercentage,
2868
+ getCanData,
2869
+ getBleData,
2870
+ getAlarm,
2871
+ createDefaultOut,
2872
+ bin2dec,
2873
+ bin2hex,
2874
+ dec2bin,
2875
+ dec2hex,
2876
+ hex2bin,
2877
+ hex2dec,
2878
+ nHexDigit,
2879
+ sumOnes,
2880
+ parseDate,
2881
+ getMNC
2877
2882
  }