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/gv58lau.js CHANGED
@@ -23,7 +23,7 @@ const parse = raw => {
23
23
  imei: parsedData[2],
24
24
  protocolVersion: utils.getProtocolVersion(parsedData[1]),
25
25
  temperature: null,
26
- history: history,
26
+ history,
27
27
  sentTime: utils.parseDate(parsedData[parsedData.length - 2]),
28
28
  serialId: parseInt(parsedData[parsedData.length - 1], 16)
29
29
  }
@@ -31,11 +31,11 @@ const parse = raw => {
31
31
  // Gps
32
32
  if (command[1] === 'GTFRI') {
33
33
  try {
34
- let number = parsedData[6] !== '' ? parseInt(parsedData[6], 10) : 1
35
- let satelliteInfo = utils.includeSatellites(parsedData[18])
36
- let gnnsTriggerType = utils.includeGnssTrigger(parsedData[18])
37
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[18]) ? 3 : 0
38
- let index =
34
+ const number = parsedData[6] !== '' ? parseInt(parsedData[6], 10) : 1
35
+ const satelliteInfo = utils.includeSatellites(parsedData[18])
36
+ const gnnsTriggerType = utils.includeGnssTrigger(parsedData[18])
37
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[18]) ? 3 : 0
38
+ const index =
39
39
  6 + (12 + satelliteInfo + gnnsTriggerType + accuracyInfo) * number
40
40
 
41
41
  data = Object.assign(data, {
@@ -54,29 +54,29 @@ const parse = raw => {
54
54
  raw: parsedData[index + 7],
55
55
  sos: false,
56
56
  input: {
57
- '2':
57
+ 2:
58
58
  utils.nHexDigit(
59
59
  utils.hex2bin(parsedData[index + 7].substring(2, 4)),
60
60
  8
61
61
  )[6] === '1',
62
- '1':
62
+ 1:
63
63
  utils.nHexDigit(
64
64
  utils.hex2bin(parsedData[index + 7].substring(2, 4)),
65
65
  8
66
66
  )[7] === '1'
67
67
  },
68
68
  output: {
69
- '3':
69
+ 3:
70
70
  utils.nHexDigit(
71
71
  utils.hex2bin(parsedData[index + 7].substring(4, 6)),
72
72
  8
73
73
  )[5] === '1',
74
- '2':
74
+ 2:
75
75
  utils.nHexDigit(
76
76
  utils.hex2bin(parsedData[index + 7].substring(4, 6)),
77
77
  8
78
78
  )[6] === '1',
79
- '1':
79
+ 1:
80
80
  utils.nHexDigit(
81
81
  utils.hex2bin(parsedData[index + 7].substring(4, 6)),
82
82
  8
@@ -114,18 +114,18 @@ const parse = raw => {
114
114
  index - (satelliteInfo + gnnsTriggerType + accuracyInfo) + 1
115
115
  ] !== ''
116
116
  ? parseInt(
117
- parsedData[
118
- index - (satelliteInfo + gnnsTriggerType + accuracyInfo) + 1
119
- ],
120
- 10
121
- )
117
+ parsedData[
118
+ index - (satelliteInfo + gnnsTriggerType + accuracyInfo) + 1
119
+ ],
120
+ 10
121
+ )
122
122
  : null,
123
123
  gnssTrigger:
124
124
  gnnsTriggerType &&
125
125
  parsedData[index - (gnnsTriggerType + accuracyInfo) + 1] !== ''
126
126
  ? utils.gnssTriggerTypes[
127
- parsedData[index - (gnnsTriggerType + accuracyInfo) + 1]
128
- ]
127
+ parsedData[index - (gnnsTriggerType + accuracyInfo) + 1]
128
+ ]
129
129
  : null,
130
130
  Hdop:
131
131
  accuracyInfo && parsedData[index - accuracyInfo + 1] !== ''
@@ -151,9 +151,9 @@ const parse = raw => {
151
151
 
152
152
  // More than 1 GNSS report in data
153
153
  if (number > 1) {
154
- let moreData = []
154
+ const moreData = []
155
155
  for (let i = 1; i < number; i++) {
156
- let gnssIx =
156
+ const gnssIx =
157
157
  7 + (12 + gnnsTriggerType + satelliteInfo + accuracyInfo) * i
158
158
 
159
159
  moreData.push({
@@ -209,18 +209,18 @@ const parse = raw => {
209
209
  gnssIx - (satelliteInfo + gnnsTriggerType + accuracyInfo)
210
210
  ] !== ''
211
211
  ? parseInt(
212
- parsedData[
213
- gnssIx - (satelliteInfo + gnnsTriggerType + accuracyInfo)
214
- ],
215
- 10
216
- )
212
+ parsedData[
213
+ gnssIx - (satelliteInfo + gnnsTriggerType + accuracyInfo)
214
+ ],
215
+ 10
216
+ )
217
217
  : null,
218
218
  gnssTrigger:
219
219
  gnnsTriggerType &&
220
220
  parsedData[gnssIx - (gnnsTriggerType + accuracyInfo)] !== ''
221
221
  ? utils.gnssTriggerTypes[
222
- parsedData[gnssIx - (gnnsTriggerType + accuracyInfo)]
223
- ]
222
+ parsedData[gnssIx - (gnnsTriggerType + accuracyInfo)]
223
+ ]
224
224
  : null,
225
225
  Hdop:
226
226
  accuracyInfo && parsedData[gnssIx - accuracyInfo] !== ''
@@ -237,17 +237,17 @@ const parse = raw => {
237
237
  })
238
238
  }
239
239
 
240
- data = Object.assign(data, { moreData: moreData })
240
+ data = Object.assign(data, { moreData })
241
241
  }
242
242
  } catch (err) {
243
243
  return { type: 'UNKNOWN', raw: data.raw.toString() }
244
244
  }
245
245
  } else if (command[1] === 'GTERI') {
246
246
  // GPS with AC100 and/or Bluetoth Devices Connected
247
- let number = parsedData[7] !== '' ? parseInt(parsedData[7], 10) : 1
248
- let satelliteInfo = utils.includeSatellites(parsedData[19])
249
- let gnnsTriggerType = utils.includeGnssTrigger(parsedData[19])
250
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[19]) ? 3 : 0
247
+ const number = parsedData[7] !== '' ? parseInt(parsedData[7], 10) : 1
248
+ const satelliteInfo = utils.includeSatellites(parsedData[19])
249
+ const gnnsTriggerType = utils.includeGnssTrigger(parsedData[19])
250
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[19]) ? 3 : 0
251
251
  let index =
252
252
  7 + (12 + satelliteInfo + gnnsTriggerType + accuracyInfo) * number
253
253
 
@@ -267,29 +267,29 @@ const parse = raw => {
267
267
  raw: parsedData[index + 7],
268
268
  sos: false,
269
269
  input: {
270
- '2':
270
+ 2:
271
271
  utils.nHexDigit(
272
272
  utils.hex2bin(parsedData[index + 7].substring(2, 4)),
273
273
  8
274
274
  )[6] === '1',
275
- '1':
275
+ 1:
276
276
  utils.nHexDigit(
277
277
  utils.hex2bin(parsedData[index + 7].substring(2, 4)),
278
278
  8
279
279
  )[7] === '1'
280
280
  },
281
281
  output: {
282
- '3':
282
+ 3:
283
283
  utils.nHexDigit(
284
284
  utils.hex2bin(parsedData[index + 7].substring(4, 6)),
285
285
  8
286
286
  )[5] === '1',
287
- '2':
287
+ 2:
288
288
  utils.nHexDigit(
289
289
  utils.hex2bin(parsedData[index + 7].substring(4, 6)),
290
290
  8
291
291
  )[6] === '1',
292
- '1':
292
+ 1:
293
293
  utils.nHexDigit(
294
294
  utils.hex2bin(parsedData[index + 7].substring(4, 6)),
295
295
  8
@@ -325,18 +325,18 @@ const parse = raw => {
325
325
  index - (satelliteInfo + gnnsTriggerType + accuracyInfo) + 1
326
326
  ] !== ''
327
327
  ? parseInt(
328
- parsedData[
329
- index - (satelliteInfo + gnnsTriggerType + accuracyInfo) + 1
330
- ],
331
- 10
332
- )
328
+ parsedData[
329
+ index - (satelliteInfo + gnnsTriggerType + accuracyInfo) + 1
330
+ ],
331
+ 10
332
+ )
333
333
  : null,
334
334
  gnssTrigger:
335
335
  gnnsTriggerType &&
336
336
  parsedData[index - (gnnsTriggerType + accuracyInfo) + 1] !== ''
337
337
  ? utils.gnssTriggerTypes[
338
- parsedData[index - (gnnsTriggerType + accuracyInfo) + 1]
339
- ]
338
+ parsedData[index - (gnnsTriggerType + accuracyInfo) + 1]
339
+ ]
340
340
  : null,
341
341
  Hdop:
342
342
  accuracyInfo && parsedData[index - accuracyInfo + 1] !== ''
@@ -365,16 +365,20 @@ const parse = raw => {
365
365
  let externalData = {
366
366
  eriMask: {
367
367
  raw: parsedData[4],
368
- canData: canData,
369
- bluetoothAccessory: bluetoothAccessory
368
+ canData,
369
+ bluetoothAccessory
370
370
  }
371
371
  }
372
372
 
373
373
  // CANBUS data
374
374
  if (canData) {
375
- let eriNewIndex = index + 9
376
- let parsedCanData = utils.getCanData(parsedData, eriNewIndex, command[1])
377
- let canInfo = parsedCanData[3]
375
+ const eriNewIndex = index + 9
376
+ const parsedCanData = utils.getCanData(
377
+ parsedData,
378
+ eriNewIndex,
379
+ command[1]
380
+ )
381
+ const canInfo = parsedCanData[3]
378
382
  index = parsedCanData[0]
379
383
  if (Object.keys(canInfo).length > 0) {
380
384
  data = Object.assign(data, { can: canInfo })
@@ -399,22 +403,22 @@ const parse = raw => {
399
403
 
400
404
  // Bluetooth Accessories
401
405
  if (bluetoothAccessory) {
402
- let btIndex = canData ? index : index + 9
403
- let btDevices = utils.getBleData(parsedData, btIndex)
406
+ const btIndex = canData ? index : index + 9
407
+ const btDevices = utils.getBleData(parsedData, btIndex)
404
408
  externalData = Object.assign(externalData, {
405
- btDevices: btDevices
409
+ btDevices
406
410
  })
407
411
  }
408
412
 
409
413
  data = Object.assign(data, {
410
- externalData: externalData
414
+ externalData
411
415
  })
412
416
 
413
417
  // More than 1 GNSS report in data
414
418
  if (number > 1) {
415
- let moreData = []
419
+ const moreData = []
416
420
  for (let i = 1; i < number; i++) {
417
- let gnssIx =
421
+ const gnssIx =
418
422
  8 + (12 + gnnsTriggerType + satelliteInfo + accuracyInfo) * i
419
423
  moreData.push({
420
424
  index: i,
@@ -469,18 +473,18 @@ const parse = raw => {
469
473
  gnssIx - (satelliteInfo + gnnsTriggerType + accuracyInfo)
470
474
  ] !== ''
471
475
  ? parseInt(
472
- parsedData[
473
- gnssIx - (satelliteInfo + gnnsTriggerType + accuracyInfo)
474
- ],
475
- 10
476
- )
476
+ parsedData[
477
+ gnssIx - (satelliteInfo + gnnsTriggerType + accuracyInfo)
478
+ ],
479
+ 10
480
+ )
477
481
  : null,
478
482
  gnssTrigger:
479
483
  gnnsTriggerType &&
480
484
  parsedData[gnssIx - (gnnsTriggerType + accuracyInfo)] !== ''
481
485
  ? utils.gnssTriggerTypes[
482
- parsedData[gnssIx - (gnnsTriggerType + accuracyInfo)]
483
- ]
486
+ parsedData[gnssIx - (gnnsTriggerType + accuracyInfo)]
487
+ ]
484
488
  : null,
485
489
  Hdop:
486
490
  accuracyInfo && parsedData[gnssIx - accuracyInfo] !== ''
@@ -497,7 +501,7 @@ const parse = raw => {
497
501
  })
498
502
  }
499
503
 
500
- data = Object.assign(data, { moreData: moreData })
504
+ data = Object.assign(data, { moreData })
501
505
  }
502
506
  } else if (command[1] === 'GTHBD') {
503
507
  // Heartbeat. It must response an ACK command
@@ -517,16 +521,16 @@ const parse = raw => {
517
521
  RSSI_quality:
518
522
  parsedData[10] !== ''
519
523
  ? utils.getSignalStrength(
520
- utils.networkTypes[parsedData[10]],
521
- parseInt(parsedData[6], 10)
522
- )
524
+ utils.networkTypes[parsedData[10]],
525
+ parseInt(parsedData[6], 10)
526
+ )
523
527
  : null, // Signal Strength
524
528
  RSSI_percentage:
525
529
  parsedData[10] !== ''
526
530
  ? utils.getSignalPercentage(
527
- utils.networkTypes[parsedData[10]],
528
- parseInt(parsedData[6], 10)
529
- )
531
+ utils.networkTypes[parsedData[10]],
532
+ parseInt(parsedData[6], 10)
533
+ )
530
534
  : null, // Signal Percetange
531
535
  GSM_quality:
532
536
  parsedData[7] !== ''
@@ -543,13 +547,13 @@ const parse = raw => {
543
547
  raw: `${parsedData[21]}${parsedData[22]}`,
544
548
  sos: false,
545
549
  input: {
546
- '2': utils.nHexDigit(utils.hex2bin(parsedData[21]), 8)[6] === '1',
547
- '1': utils.nHexDigit(utils.hex2bin(parsedData[21]), 8)[7] === '1'
550
+ 2: utils.nHexDigit(utils.hex2bin(parsedData[21]), 8)[6] === '1',
551
+ 1: utils.nHexDigit(utils.hex2bin(parsedData[21]), 8)[7] === '1'
548
552
  },
549
553
  output: {
550
- '3': utils.nHexDigit(utils.hex2bin(parsedData[22]), 8)[5] === '1',
551
- '2': utils.nHexDigit(utils.hex2bin(parsedData[22]), 8)[6] === '1',
552
- '1': utils.nHexDigit(utils.hex2bin(parsedData[22]), 8)[7] === '1'
554
+ 3: utils.nHexDigit(utils.hex2bin(parsedData[22]), 8)[5] === '1',
555
+ 2: utils.nHexDigit(utils.hex2bin(parsedData[22]), 8)[6] === '1',
556
+ 1: utils.nHexDigit(utils.hex2bin(parsedData[22]), 8)[7] === '1'
553
557
  },
554
558
  charge: parsedData[12] === '1'
555
559
  },
@@ -578,10 +582,10 @@ const parse = raw => {
578
582
  command[1] === 'GTHBM'
579
583
  ) {
580
584
  // Common Alarms
581
- let number = parsedData[6] !== '' ? parseInt(parsedData[6], 10) : 1
582
- let satelliteInfo = utils.includeSatellites(parsedData[18])
583
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[18]) ? 3 : 0
584
- let index = 6 + (12 + satelliteInfo + accuracyInfo) * number
585
+ const number = parsedData[6] !== '' ? parseInt(parsedData[6], 10) : 1
586
+ const satelliteInfo = utils.includeSatellites(parsedData[18])
587
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[18]) ? 3 : 0
588
+ const index = 6 + (12 + satelliteInfo + accuracyInfo) * number
585
589
 
586
590
  data = Object.assign(data, {
587
591
  alarm: utils.getAlarm(command[1], parsedData[5], 'gv58lau'),
@@ -636,10 +640,10 @@ const parse = raw => {
636
640
  })
637
641
  } else if (command[1] === 'GTEPS' || command[1] === 'GTAIS') {
638
642
  // External low battery and Low voltage for analog input
639
- let number = parsedData[6] !== '' ? parseInt(parsedData[6], 10) : 1
640
- let satelliteInfo = utils.includeSatellites(parsedData[18])
641
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[18]) ? 3 : 0
642
- let index = 6 + (12 + satelliteInfo + accuracyInfo) * number
643
+ const number = parsedData[6] !== '' ? parseInt(parsedData[6], 10) : 1
644
+ const satelliteInfo = utils.includeSatellites(parsedData[18])
645
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[18]) ? 3 : 0
646
+ const index = 6 + (12 + satelliteInfo + accuracyInfo) * number
643
647
 
644
648
  data = Object.assign(data, {
645
649
  alarm: utils.getAlarm(command[1], parsedData[5]),
@@ -731,10 +735,10 @@ const parse = raw => {
731
735
  command[1] === 'GTMPF' ||
732
736
  command[1] === 'GTBTC'
733
737
  ) {
734
- let satelliteInfo = utils.includeSatellites(parsedData[15])
735
- let includeStatus = utils.includeStatus(parsedData[15])
736
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[15]) ? 3 : 0
737
- let index = 15 + (satelliteInfo + includeStatus + accuracyInfo)
738
+ const satelliteInfo = utils.includeSatellites(parsedData[15])
739
+ const includeStatus = utils.includeStatus(parsedData[15])
740
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[15]) ? 3 : 0
741
+ const index = 15 + (satelliteInfo + includeStatus + accuracyInfo)
738
742
 
739
743
  data = Object.assign(data, {
740
744
  alarm: utils.getAlarm(command[1], null),
@@ -772,19 +776,19 @@ const parse = raw => {
772
776
  index - (satelliteInfo + includeStatus + accuracyInfo) + 1
773
777
  ] !== ''
774
778
  ? parseInt(
775
- parsedData[
776
- index - (satelliteInfo + includeStatus + accuracyInfo) + 1
777
- ],
778
- 10
779
- )
779
+ parsedData[
780
+ index - (satelliteInfo + includeStatus + accuracyInfo) + 1
781
+ ],
782
+ 10
783
+ )
780
784
  : null,
781
785
  status:
782
786
  includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
783
787
  ? {
784
- raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
785
- sos: false,
786
- input: {
787
- '2':
788
+ raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
789
+ sos: false,
790
+ input: {
791
+ 2:
788
792
  utils.nHexDigit(
789
793
  utils.hex2bin(
790
794
  parsedData[
@@ -793,7 +797,7 @@ const parse = raw => {
793
797
  ),
794
798
  8
795
799
  )[6] === '1',
796
- '1':
800
+ 1:
797
801
  utils.nHexDigit(
798
802
  utils.hex2bin(
799
803
  parsedData[
@@ -802,9 +806,9 @@ const parse = raw => {
802
806
  ),
803
807
  8
804
808
  )[7] === '1'
805
- },
806
- output: {
807
- '3':
809
+ },
810
+ output: {
811
+ 3:
808
812
  utils.nHexDigit(
809
813
  utils.hex2bin(
810
814
  parsedData[
@@ -813,7 +817,7 @@ const parse = raw => {
813
817
  ),
814
818
  8
815
819
  )[5] === '1',
816
- '2':
820
+ 2:
817
821
  utils.nHexDigit(
818
822
  utils.hex2bin(
819
823
  parsedData[
@@ -822,7 +826,7 @@ const parse = raw => {
822
826
  ),
823
827
  8
824
828
  )[6] === '1',
825
- '1':
829
+ 1:
826
830
  utils.nHexDigit(
827
831
  utils.hex2bin(
828
832
  parsedData[
@@ -831,15 +835,15 @@ const parse = raw => {
831
835
  ),
832
836
  8
833
837
  )[7] === '1'
834
- },
835
- charge: null,
836
- state:
838
+ },
839
+ charge: null,
840
+ state:
837
841
  utils.states[
838
842
  parsedData[
839
843
  index - (includeStatus + accuracyInfo) + 1
840
844
  ].substring(0, 2)
841
845
  ]
842
- }
846
+ }
843
847
  : null,
844
848
  Hdop:
845
849
  accuracyInfo && parsedData[index - accuracyInfo + 1] !== ''
@@ -864,10 +868,10 @@ const parse = raw => {
864
868
  command[1] === 'GTBPL' ||
865
869
  command[1] === 'GTSTT'
866
870
  ) {
867
- let satelliteInfo = utils.includeSatellites(parsedData[16])
868
- let includeStatus = utils.includeStatus(parsedData[16])
869
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[16]) ? 3 : 0
870
- let index = 16 + (satelliteInfo + includeStatus + accuracyInfo)
871
+ const satelliteInfo = utils.includeSatellites(parsedData[16])
872
+ const includeStatus = utils.includeStatus(parsedData[16])
873
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[16]) ? 3 : 0
874
+ const index = 16 + (satelliteInfo + includeStatus + accuracyInfo)
871
875
 
872
876
  data = Object.assign(data, {
873
877
  alarm: utils.getAlarm(command[1], parsedData[4]),
@@ -904,19 +908,19 @@ const parse = raw => {
904
908
  index - (satelliteInfo + includeStatus + accuracyInfo) + 1
905
909
  ] !== ''
906
910
  ? parseInt(
907
- parsedData[
908
- index - (satelliteInfo + includeStatus + accuracyInfo) + 1
909
- ],
910
- 10
911
- )
911
+ parsedData[
912
+ index - (satelliteInfo + includeStatus + accuracyInfo) + 1
913
+ ],
914
+ 10
915
+ )
912
916
  : null,
913
917
  status:
914
918
  includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
915
919
  ? {
916
- raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
917
- sos: false,
918
- input: {
919
- '2':
920
+ raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
921
+ sos: false,
922
+ input: {
923
+ 2:
920
924
  utils.nHexDigit(
921
925
  utils.hex2bin(
922
926
  parsedData[
@@ -925,7 +929,7 @@ const parse = raw => {
925
929
  ),
926
930
  8
927
931
  )[6] === '1',
928
- '1':
932
+ 1:
929
933
  utils.nHexDigit(
930
934
  utils.hex2bin(
931
935
  parsedData[
@@ -934,9 +938,9 @@ const parse = raw => {
934
938
  ),
935
939
  8
936
940
  )[7] === '1'
937
- },
938
- output: {
939
- '3':
941
+ },
942
+ output: {
943
+ 3:
940
944
  utils.nHexDigit(
941
945
  utils.hex2bin(
942
946
  parsedData[
@@ -945,7 +949,7 @@ const parse = raw => {
945
949
  ),
946
950
  8
947
951
  )[5] === '1',
948
- '2':
952
+ 2:
949
953
  utils.nHexDigit(
950
954
  utils.hex2bin(
951
955
  parsedData[
@@ -954,7 +958,7 @@ const parse = raw => {
954
958
  ),
955
959
  8
956
960
  )[6] === '1',
957
- '1':
961
+ 1:
958
962
  utils.nHexDigit(
959
963
  utils.hex2bin(
960
964
  parsedData[
@@ -963,15 +967,15 @@ const parse = raw => {
963
967
  ),
964
968
  8
965
969
  )[7] === '1'
966
- },
967
- charge: null,
968
- state:
970
+ },
971
+ charge: null,
972
+ state:
969
973
  utils.states[
970
974
  parsedData[
971
975
  index - (includeStatus + accuracyInfo) + 1
972
976
  ].substring(0, 2)
973
977
  ]
974
- }
978
+ }
975
979
  : null,
976
980
  Hdop:
977
981
  accuracyInfo && parsedData[index - accuracyInfo + 1] !== ''
@@ -989,7 +993,7 @@ const parse = raw => {
989
993
  hourmeter: null
990
994
  })
991
995
  } else if (command[1] === 'GTCRG') {
992
- let number = parsedData[5] !== '' ? parseInt(parsedData[5]) : 1
996
+ const number = parsedData[5] !== '' ? parseInt(parsedData[5]) : 1
993
997
  let start = 6
994
998
 
995
999
  data = Object.assign(data, {
@@ -1000,7 +1004,7 @@ const parse = raw => {
1000
1004
  }
1001
1005
  })
1002
1006
 
1003
- let more = []
1007
+ const more = []
1004
1008
  for (let i = 1; i <= number; i++) {
1005
1009
  more.push({
1006
1010
  id: parsedData[start] !== '' ? parseInt(parsedData[start]) : null,
@@ -1043,10 +1047,10 @@ const parse = raw => {
1043
1047
  gnssData: more
1044
1048
  })
1045
1049
  } else if (command[1] === 'GTJDS') {
1046
- let satelliteInfo = utils.includeSatellites(parsedData[17])
1047
- let includeStatus = utils.includeStatus(parsedData[17])
1048
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[17]) ? 3 : 0
1049
- let index = 17 + (satelliteInfo + includeStatus + accuracyInfo)
1050
+ const satelliteInfo = utils.includeSatellites(parsedData[17])
1051
+ const includeStatus = utils.includeStatus(parsedData[17])
1052
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[17]) ? 3 : 0
1053
+ const index = 17 + (satelliteInfo + includeStatus + accuracyInfo)
1050
1054
 
1051
1055
  data = Object.assign(data, {
1052
1056
  alarm: utils.getAlarm(command[1], parsedData[4], parsedData[5]),
@@ -1084,19 +1088,19 @@ const parse = raw => {
1084
1088
  index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1085
1089
  ] !== ''
1086
1090
  ? parseInt(
1087
- parsedData[
1088
- index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1089
- ],
1090
- 10
1091
- )
1091
+ parsedData[
1092
+ index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1093
+ ],
1094
+ 10
1095
+ )
1092
1096
  : null,
1093
1097
  status:
1094
1098
  includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
1095
1099
  ? {
1096
- raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
1097
- sos: false,
1098
- input: {
1099
- '2':
1100
+ raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
1101
+ sos: false,
1102
+ input: {
1103
+ 2:
1100
1104
  utils.nHexDigit(
1101
1105
  utils.hex2bin(
1102
1106
  parsedData[
@@ -1105,7 +1109,7 @@ const parse = raw => {
1105
1109
  ),
1106
1110
  8
1107
1111
  )[6] === '1',
1108
- '1':
1112
+ 1:
1109
1113
  utils.nHexDigit(
1110
1114
  utils.hex2bin(
1111
1115
  parsedData[
@@ -1114,9 +1118,9 @@ const parse = raw => {
1114
1118
  ),
1115
1119
  8
1116
1120
  )[7] === '1'
1117
- },
1118
- output: {
1119
- '3':
1121
+ },
1122
+ output: {
1123
+ 3:
1120
1124
  utils.nHexDigit(
1121
1125
  utils.hex2bin(
1122
1126
  parsedData[
@@ -1125,7 +1129,7 @@ const parse = raw => {
1125
1129
  ),
1126
1130
  8
1127
1131
  )[5] === '1',
1128
- '2':
1132
+ 2:
1129
1133
  utils.nHexDigit(
1130
1134
  utils.hex2bin(
1131
1135
  parsedData[
@@ -1134,7 +1138,7 @@ const parse = raw => {
1134
1138
  ),
1135
1139
  8
1136
1140
  )[6] === '1',
1137
- '1':
1141
+ 1:
1138
1142
  utils.nHexDigit(
1139
1143
  utils.hex2bin(
1140
1144
  parsedData[
@@ -1143,15 +1147,15 @@ const parse = raw => {
1143
1147
  ),
1144
1148
  8
1145
1149
  )[7] === '1'
1146
- },
1147
- charge: null,
1148
- state:
1150
+ },
1151
+ charge: null,
1152
+ state:
1149
1153
  utils.states[
1150
1154
  parsedData[
1151
1155
  index - (includeStatus + accuracyInfo) + 1
1152
1156
  ].substring(0, 2)
1153
1157
  ]
1154
- }
1158
+ }
1155
1159
  : null,
1156
1160
  Hdop:
1157
1161
  accuracyInfo && parsedData[index - accuracyInfo + 1] !== ''
@@ -1169,10 +1173,10 @@ const parse = raw => {
1169
1173
  hourmeter: null
1170
1174
  })
1171
1175
  } else if (command[1] === 'GTIGN' || command[1] === 'GTIGF') {
1172
- let satelliteInfo = utils.includeSatellites(parsedData[16])
1173
- let includeStatus = utils.includeStatus(parsedData[16])
1174
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[16]) ? 3 : 0
1175
- let index = 16 + (satelliteInfo + includeStatus + accuracyInfo)
1176
+ const satelliteInfo = utils.includeSatellites(parsedData[16])
1177
+ const includeStatus = utils.includeStatus(parsedData[16])
1178
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[16]) ? 3 : 0
1179
+ const index = 16 + (satelliteInfo + includeStatus + accuracyInfo)
1176
1180
 
1177
1181
  data = Object.assign(data, {
1178
1182
  alarm: utils.getAlarm(command[1], parsedData[4]),
@@ -1210,19 +1214,19 @@ const parse = raw => {
1210
1214
  index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1211
1215
  ] !== ''
1212
1216
  ? parseInt(
1213
- parsedData[
1214
- index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1215
- ],
1216
- 10
1217
- )
1217
+ parsedData[
1218
+ index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1219
+ ],
1220
+ 10
1221
+ )
1218
1222
  : null,
1219
1223
  status:
1220
1224
  includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
1221
1225
  ? {
1222
- raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
1223
- sos: false,
1224
- input: {
1225
- '2':
1226
+ raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
1227
+ sos: false,
1228
+ input: {
1229
+ 2:
1226
1230
  utils.nHexDigit(
1227
1231
  utils.hex2bin(
1228
1232
  parsedData[
@@ -1231,7 +1235,7 @@ const parse = raw => {
1231
1235
  ),
1232
1236
  8
1233
1237
  )[6] === '1',
1234
- '1':
1238
+ 1:
1235
1239
  utils.nHexDigit(
1236
1240
  utils.hex2bin(
1237
1241
  parsedData[
@@ -1240,9 +1244,9 @@ const parse = raw => {
1240
1244
  ),
1241
1245
  8
1242
1246
  )[7] === '1'
1243
- },
1244
- output: {
1245
- '3':
1247
+ },
1248
+ output: {
1249
+ 3:
1246
1250
  utils.nHexDigit(
1247
1251
  utils.hex2bin(
1248
1252
  parsedData[
@@ -1251,7 +1255,7 @@ const parse = raw => {
1251
1255
  ),
1252
1256
  8
1253
1257
  )[5] === '1',
1254
- '2':
1258
+ 2:
1255
1259
  utils.nHexDigit(
1256
1260
  utils.hex2bin(
1257
1261
  parsedData[
@@ -1260,7 +1264,7 @@ const parse = raw => {
1260
1264
  ),
1261
1265
  8
1262
1266
  )[6] === '1',
1263
- '1':
1267
+ 1:
1264
1268
  utils.nHexDigit(
1265
1269
  utils.hex2bin(
1266
1270
  parsedData[
@@ -1269,15 +1273,15 @@ const parse = raw => {
1269
1273
  ),
1270
1274
  8
1271
1275
  )[7] === '1'
1272
- },
1273
- charge: null,
1274
- state:
1276
+ },
1277
+ charge: null,
1278
+ state:
1275
1279
  utils.states[
1276
1280
  parsedData[
1277
1281
  index - (includeStatus + accuracyInfo) + 1
1278
1282
  ].substring(0, 2)
1279
1283
  ]
1280
- }
1284
+ }
1281
1285
  : null,
1282
1286
  Hdop:
1283
1287
  accuracyInfo && parsedData[index - accuracyInfo + 1] !== ''
@@ -1303,10 +1307,10 @@ const parse = raw => {
1303
1307
  command[1] === 'GTSTP' ||
1304
1308
  command[1] === 'GTLSP'
1305
1309
  ) {
1306
- let satelliteInfo = utils.includeSatellites(parsedData[17])
1307
- let includeStatus = utils.includeStatus(parsedData[17])
1308
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[17]) ? 3 : 0
1309
- let index = 17 + (satelliteInfo + includeStatus + accuracyInfo)
1310
+ const satelliteInfo = utils.includeSatellites(parsedData[17])
1311
+ const includeStatus = utils.includeStatus(parsedData[17])
1312
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[17]) ? 3 : 0
1313
+ const index = 17 + (satelliteInfo + includeStatus + accuracyInfo)
1310
1314
 
1311
1315
  data = Object.assign(data, {
1312
1316
  alarm: utils.getAlarm(command[1], parsedData[5]),
@@ -1344,19 +1348,19 @@ const parse = raw => {
1344
1348
  index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1345
1349
  ] !== ''
1346
1350
  ? parseInt(
1347
- parsedData[
1348
- index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1349
- ],
1350
- 10
1351
- )
1351
+ parsedData[
1352
+ index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1353
+ ],
1354
+ 10
1355
+ )
1352
1356
  : null,
1353
1357
  status:
1354
1358
  includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
1355
1359
  ? {
1356
- raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
1357
- sos: false,
1358
- input: {
1359
- '2':
1360
+ raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
1361
+ sos: false,
1362
+ input: {
1363
+ 2:
1360
1364
  utils.nHexDigit(
1361
1365
  utils.hex2bin(
1362
1366
  parsedData[
@@ -1365,7 +1369,7 @@ const parse = raw => {
1365
1369
  ),
1366
1370
  8
1367
1371
  )[6] === '1',
1368
- '1':
1372
+ 1:
1369
1373
  utils.nHexDigit(
1370
1374
  utils.hex2bin(
1371
1375
  parsedData[
@@ -1374,9 +1378,9 @@ const parse = raw => {
1374
1378
  ),
1375
1379
  8
1376
1380
  )[7] === '1'
1377
- },
1378
- output: {
1379
- '3':
1381
+ },
1382
+ output: {
1383
+ 3:
1380
1384
  utils.nHexDigit(
1381
1385
  utils.hex2bin(
1382
1386
  parsedData[
@@ -1385,7 +1389,7 @@ const parse = raw => {
1385
1389
  ),
1386
1390
  8
1387
1391
  )[5] === '1',
1388
- '2':
1392
+ 2:
1389
1393
  utils.nHexDigit(
1390
1394
  utils.hex2bin(
1391
1395
  parsedData[
@@ -1394,7 +1398,7 @@ const parse = raw => {
1394
1398
  ),
1395
1399
  8
1396
1400
  )[6] === '1',
1397
- '1':
1401
+ 1:
1398
1402
  utils.nHexDigit(
1399
1403
  utils.hex2bin(
1400
1404
  parsedData[
@@ -1403,15 +1407,15 @@ const parse = raw => {
1403
1407
  ),
1404
1408
  8
1405
1409
  )[7] === '1'
1406
- },
1407
- charge: null,
1408
- state:
1410
+ },
1411
+ charge: null,
1412
+ state:
1409
1413
  utils.states[
1410
1414
  parsedData[
1411
1415
  index - (includeStatus + accuracyInfo) + 1
1412
1416
  ].substring(0, 2)
1413
1417
  ]
1414
- }
1418
+ }
1415
1419
  : null,
1416
1420
  Hdop:
1417
1421
  accuracyInfo && parsedData[index - accuracyInfo + 1] !== ''
@@ -1430,10 +1434,10 @@ const parse = raw => {
1430
1434
  hourmeter: null
1431
1435
  })
1432
1436
  } else if (command[1] === 'GTGSS') {
1433
- let satelliteInfo = utils.includeSatellites(parsedData[19])
1434
- let includeStatus = utils.includeStatus(parsedData[19])
1435
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[19]) ? 3 : 0
1436
- let index = 19 + (satelliteInfo + includeStatus + accuracyInfo)
1437
+ const satelliteInfo = utils.includeSatellites(parsedData[19])
1438
+ const includeStatus = utils.includeStatus(parsedData[19])
1439
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[19]) ? 3 : 0
1440
+ const index = 19 + (satelliteInfo + includeStatus + accuracyInfo)
1437
1441
 
1438
1442
  data = Object.assign(data, {
1439
1443
  alarm: utils.getAlarm(command[1], parsedData[4]),
@@ -1472,19 +1476,19 @@ const parse = raw => {
1472
1476
  index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1473
1477
  ] !== ''
1474
1478
  ? parseInt(
1475
- parsedData[
1476
- index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1477
- ],
1478
- 10
1479
- )
1479
+ parsedData[
1480
+ index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1481
+ ],
1482
+ 10
1483
+ )
1480
1484
  : null,
1481
1485
  status:
1482
1486
  includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
1483
1487
  ? {
1484
- raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
1485
- sos: false,
1486
- input: {
1487
- '2':
1488
+ raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
1489
+ sos: false,
1490
+ input: {
1491
+ 2:
1488
1492
  utils.nHexDigit(
1489
1493
  utils.hex2bin(
1490
1494
  parsedData[
@@ -1493,7 +1497,7 @@ const parse = raw => {
1493
1497
  ),
1494
1498
  8
1495
1499
  )[6] === '1',
1496
- '1':
1500
+ 1:
1497
1501
  utils.nHexDigit(
1498
1502
  utils.hex2bin(
1499
1503
  parsedData[
@@ -1502,9 +1506,9 @@ const parse = raw => {
1502
1506
  ),
1503
1507
  8
1504
1508
  )[7] === '1'
1505
- },
1506
- output: {
1507
- '3':
1509
+ },
1510
+ output: {
1511
+ 3:
1508
1512
  utils.nHexDigit(
1509
1513
  utils.hex2bin(
1510
1514
  parsedData[
@@ -1513,7 +1517,7 @@ const parse = raw => {
1513
1517
  ),
1514
1518
  8
1515
1519
  )[5] === '1',
1516
- '2':
1520
+ 2:
1517
1521
  utils.nHexDigit(
1518
1522
  utils.hex2bin(
1519
1523
  parsedData[
@@ -1522,7 +1526,7 @@ const parse = raw => {
1522
1526
  ),
1523
1527
  8
1524
1528
  )[6] === '1',
1525
- '1':
1529
+ 1:
1526
1530
  utils.nHexDigit(
1527
1531
  utils.hex2bin(
1528
1532
  parsedData[
@@ -1531,15 +1535,15 @@ const parse = raw => {
1531
1535
  ),
1532
1536
  8
1533
1537
  )[7] === '1'
1534
- },
1535
- charge: null,
1536
- state:
1538
+ },
1539
+ charge: null,
1540
+ state:
1537
1541
  utils.states[
1538
1542
  parsedData[
1539
1543
  index - (includeStatus + accuracyInfo) + 1
1540
1544
  ].substring(0, 2)
1541
1545
  ]
1542
- }
1546
+ }
1543
1547
  : null,
1544
1548
  Hdop:
1545
1549
  accuracyInfo && parsedData[index - accuracyInfo + 1] !== ''
@@ -1557,10 +1561,10 @@ const parse = raw => {
1557
1561
  hourmeter: null
1558
1562
  })
1559
1563
  } else if (command[1] === 'GTIDA') {
1560
- let number = parsedData[7] !== '' ? parseInt(parsedData[7]) : 1
1561
- let satelliteInfo = utils.includeSatellites(parsedData[19])
1562
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[19]) ? 3 : 0
1563
- let index = 7 + (12 + satelliteInfo + accuracyInfo) * number
1564
+ const number = parsedData[7] !== '' ? parseInt(parsedData[7]) : 1
1565
+ const satelliteInfo = utils.includeSatellites(parsedData[19])
1566
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[19]) ? 3 : 0
1567
+ const index = 7 + (12 + satelliteInfo + accuracyInfo) * number
1564
1568
 
1565
1569
  data = Object.assign(data, {
1566
1570
  alarm: utils.getAlarm(command[1], `${parsedData[5]},${parsedData[6]}`),
@@ -1615,10 +1619,10 @@ const parse = raw => {
1615
1619
  hourmeter: null
1616
1620
  })
1617
1621
  } else if (command[1] === 'GTCAN') {
1618
- let canData = utils.getCanData(parsedData, 5, command[1])
1622
+ const canData = utils.getCanData(parsedData, 5, command[1])
1619
1623
  let index = canData[0] // position append mask
1620
- let satelliteInfo = utils.includeSatellites(parsedData[index])
1621
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[index]) ? 3 : 0
1624
+ const satelliteInfo = utils.includeSatellites(parsedData[index])
1625
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[index]) ? 3 : 0
1622
1626
  index = index + (satelliteInfo + accuracyInfo)
1623
1627
 
1624
1628
  data = Object.assign(data, {
@@ -1677,9 +1681,9 @@ const parse = raw => {
1677
1681
  })
1678
1682
  } else {
1679
1683
  dataIndex = 7
1680
- let satelliteInfo = utils.includeSatellites(parsedData[19])
1681
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[19]) ? 3 : 0
1682
- let index = 19 + (satelliteInfo + accuracyInfo)
1684
+ const satelliteInfo = utils.includeSatellites(parsedData[19])
1685
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[19]) ? 3 : 0
1686
+ const index = 19 + (satelliteInfo + accuracyInfo)
1683
1687
 
1684
1688
  data = Object.assign(data, {
1685
1689
  loc: {
@@ -1719,9 +1723,9 @@ const parse = raw => {
1719
1723
  satelliteInfo &&
1720
1724
  parsedData[index - (satelliteInfo + accuracyInfo) + 1] !== ''
1721
1725
  ? parseInt(
1722
- parsedData[index - (satelliteInfo + accuracyInfo) + 1],
1723
- 10
1724
- )
1726
+ parsedData[index - (satelliteInfo + accuracyInfo) + 1],
1727
+ 10
1728
+ )
1725
1729
  : null,
1726
1730
  Hdop:
1727
1731
  accuracyInfo && parsedData[index - accuracyInfo + 1] !== ''
@@ -1744,10 +1748,10 @@ const parse = raw => {
1744
1748
  alarm: utils.getAlarm(command[1], parsedData[dataIndex])
1745
1749
  })
1746
1750
  } else if (command[1] === 'GTDOS') {
1747
- let satelliteInfo = utils.includeSatellites(parsedData[17])
1748
- let includeStatus = utils.includeStatus(parsedData[17])
1749
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[17]) ? 3 : 0
1750
- let index = 17 + (satelliteInfo + includeStatus + accuracyInfo)
1751
+ const satelliteInfo = utils.includeSatellites(parsedData[17])
1752
+ const includeStatus = utils.includeStatus(parsedData[17])
1753
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[17]) ? 3 : 0
1754
+ const index = 17 + (satelliteInfo + includeStatus + accuracyInfo)
1751
1755
 
1752
1756
  data = Object.assign(data, {
1753
1757
  alarm: utils.getAlarm(command[1], `${parsedData[4]},${parsedData[5]}`),
@@ -1785,19 +1789,19 @@ const parse = raw => {
1785
1789
  index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1786
1790
  ] !== ''
1787
1791
  ? parseInt(
1788
- parsedData[
1789
- index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1790
- ],
1791
- 10
1792
- )
1792
+ parsedData[
1793
+ index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1794
+ ],
1795
+ 10
1796
+ )
1793
1797
  : null,
1794
1798
  status:
1795
1799
  includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
1796
1800
  ? {
1797
- raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
1798
- sos: false,
1799
- input: {
1800
- '2':
1801
+ raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
1802
+ sos: false,
1803
+ input: {
1804
+ 2:
1801
1805
  utils.nHexDigit(
1802
1806
  utils.hex2bin(
1803
1807
  parsedData[
@@ -1806,7 +1810,7 @@ const parse = raw => {
1806
1810
  ),
1807
1811
  8
1808
1812
  )[6] === '1',
1809
- '1':
1813
+ 1:
1810
1814
  utils.nHexDigit(
1811
1815
  utils.hex2bin(
1812
1816
  parsedData[
@@ -1815,9 +1819,9 @@ const parse = raw => {
1815
1819
  ),
1816
1820
  8
1817
1821
  )[7] === '1'
1818
- },
1819
- output: {
1820
- '3':
1822
+ },
1823
+ output: {
1824
+ 3:
1821
1825
  utils.nHexDigit(
1822
1826
  utils.hex2bin(
1823
1827
  parsedData[
@@ -1826,7 +1830,7 @@ const parse = raw => {
1826
1830
  ),
1827
1831
  8
1828
1832
  )[5] === '1',
1829
- '2':
1833
+ 2:
1830
1834
  utils.nHexDigit(
1831
1835
  utils.hex2bin(
1832
1836
  parsedData[
@@ -1835,7 +1839,7 @@ const parse = raw => {
1835
1839
  ),
1836
1840
  8
1837
1841
  )[6] === '1',
1838
- '1':
1842
+ 1:
1839
1843
  utils.nHexDigit(
1840
1844
  utils.hex2bin(
1841
1845
  parsedData[
@@ -1844,15 +1848,15 @@ const parse = raw => {
1844
1848
  ),
1845
1849
  8
1846
1850
  )[7] === '1'
1847
- },
1848
- charge: null,
1849
- state:
1851
+ },
1852
+ charge: null,
1853
+ state:
1850
1854
  utils.states[
1851
1855
  parsedData[
1852
1856
  index - (includeStatus + accuracyInfo) + 1
1853
1857
  ].substring(0, 2)
1854
1858
  ]
1855
- }
1859
+ }
1856
1860
  : null,
1857
1861
  Hdop:
1858
1862
  accuracyInfo && parsedData[index - accuracyInfo + 1] !== ''
@@ -1871,10 +1875,10 @@ const parse = raw => {
1871
1875
  })
1872
1876
  } else if (command[1] === 'GTDOM') {
1873
1877
  // Waveform beeing monitored
1874
- let satelliteInfo = utils.includeSatellites(parsedData[18])
1875
- let includeStatus = utils.includeStatus(parsedData[18])
1876
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[18]) ? 3 : 0
1877
- let index = 18 + (satelliteInfo + includeStatus + accuracyInfo)
1878
+ const satelliteInfo = utils.includeSatellites(parsedData[18])
1879
+ const includeStatus = utils.includeStatus(parsedData[18])
1880
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[18]) ? 3 : 0
1881
+ const index = 18 + (satelliteInfo + includeStatus + accuracyInfo)
1878
1882
 
1879
1883
  data = Object.assign(data, {
1880
1884
  alarm: utils.getAlarm(command[1], [parsedData[4], parsedData[5]]),
@@ -1912,19 +1916,19 @@ const parse = raw => {
1912
1916
  index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1913
1917
  ] !== ''
1914
1918
  ? parseInt(
1915
- parsedData[
1916
- index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1917
- ],
1918
- 10
1919
- )
1919
+ parsedData[
1920
+ index - (satelliteInfo + includeStatus + accuracyInfo) + 1
1921
+ ],
1922
+ 10
1923
+ )
1920
1924
  : null,
1921
1925
  status:
1922
1926
  includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
1923
1927
  ? {
1924
- raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
1925
- sos: false,
1926
- input: {
1927
- '2':
1928
+ raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
1929
+ sos: false,
1930
+ input: {
1931
+ 2:
1928
1932
  utils.nHexDigit(
1929
1933
  utils.hex2bin(
1930
1934
  parsedData[
@@ -1933,7 +1937,7 @@ const parse = raw => {
1933
1937
  ),
1934
1938
  8
1935
1939
  )[6] === '1',
1936
- '1':
1940
+ 1:
1937
1941
  utils.nHexDigit(
1938
1942
  utils.hex2bin(
1939
1943
  parsedData[
@@ -1942,9 +1946,9 @@ const parse = raw => {
1942
1946
  ),
1943
1947
  8
1944
1948
  )[7] === '1'
1945
- },
1946
- output: {
1947
- '3':
1949
+ },
1950
+ output: {
1951
+ 3:
1948
1952
  utils.nHexDigit(
1949
1953
  utils.hex2bin(
1950
1954
  parsedData[
@@ -1953,7 +1957,7 @@ const parse = raw => {
1953
1957
  ),
1954
1958
  8
1955
1959
  )[5] === '1',
1956
- '2':
1960
+ 2:
1957
1961
  utils.nHexDigit(
1958
1962
  utils.hex2bin(
1959
1963
  parsedData[
@@ -1962,7 +1966,7 @@ const parse = raw => {
1962
1966
  ),
1963
1967
  8
1964
1968
  )[6] === '1',
1965
- '1':
1969
+ 1:
1966
1970
  utils.nHexDigit(
1967
1971
  utils.hex2bin(
1968
1972
  parsedData[
@@ -1971,15 +1975,15 @@ const parse = raw => {
1971
1975
  ),
1972
1976
  8
1973
1977
  )[7] === '1'
1974
- },
1975
- charge: null,
1976
- state:
1978
+ },
1979
+ charge: null,
1980
+ state:
1977
1981
  utils.states[
1978
1982
  parsedData[
1979
1983
  index - (includeStatus + accuracyInfo) + 1
1980
1984
  ].substring(0, 2)
1981
1985
  ]
1982
- }
1986
+ }
1983
1987
  : null,
1984
1988
  Hdop:
1985
1989
  accuracyInfo && parsedData[index - accuracyInfo + 1] !== ''
@@ -2006,10 +2010,10 @@ const parse = raw => {
2006
2010
  })
2007
2011
  } else if (command[1] === 'GTBCS' || command[1] === 'GTBDS') {
2008
2012
  // Bluetooth connection/desconnection
2009
- let satelliteInfo = utils.includeSatellites(parsedData[16])
2010
- let includeStatus = utils.includeStatus(parsedData[16])
2011
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[16]) ? 3 : 0
2012
- let index = 16 + (satelliteInfo + includeStatus + accuracyInfo)
2013
+ const satelliteInfo = utils.includeSatellites(parsedData[16])
2014
+ const includeStatus = utils.includeStatus(parsedData[16])
2015
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[16]) ? 3 : 0
2016
+ const index = 16 + (satelliteInfo + includeStatus + accuracyInfo)
2013
2017
 
2014
2018
  data = Object.assign(data, {
2015
2019
  alarm: utils.getAlarm(command[1], null, 'gv58lau'),
@@ -2047,19 +2051,19 @@ const parse = raw => {
2047
2051
  index - (satelliteInfo + includeStatus + accuracyInfo) + 1
2048
2052
  ] !== ''
2049
2053
  ? parseInt(
2050
- parsedData[
2051
- index - (satelliteInfo + includeStatus + accuracyInfo) + 1
2052
- ],
2053
- 10
2054
- )
2054
+ parsedData[
2055
+ index - (satelliteInfo + includeStatus + accuracyInfo) + 1
2056
+ ],
2057
+ 10
2058
+ )
2055
2059
  : null,
2056
2060
  status:
2057
2061
  includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
2058
2062
  ? {
2059
- raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
2060
- sos: false,
2061
- input: {
2062
- '2':
2063
+ raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
2064
+ sos: false,
2065
+ input: {
2066
+ 2:
2063
2067
  utils.nHexDigit(
2064
2068
  utils.hex2bin(
2065
2069
  parsedData[
@@ -2068,7 +2072,7 @@ const parse = raw => {
2068
2072
  ),
2069
2073
  8
2070
2074
  )[6] === '1',
2071
- '1':
2075
+ 1:
2072
2076
  utils.nHexDigit(
2073
2077
  utils.hex2bin(
2074
2078
  parsedData[
@@ -2077,9 +2081,9 @@ const parse = raw => {
2077
2081
  ),
2078
2082
  8
2079
2083
  )[7] === '1'
2080
- },
2081
- output: {
2082
- '3':
2084
+ },
2085
+ output: {
2086
+ 3:
2083
2087
  utils.nHexDigit(
2084
2088
  utils.hex2bin(
2085
2089
  parsedData[
@@ -2088,7 +2092,7 @@ const parse = raw => {
2088
2092
  ),
2089
2093
  8
2090
2094
  )[5] === '1',
2091
- '2':
2095
+ 2:
2092
2096
  utils.nHexDigit(
2093
2097
  utils.hex2bin(
2094
2098
  parsedData[
@@ -2097,7 +2101,7 @@ const parse = raw => {
2097
2101
  ),
2098
2102
  8
2099
2103
  )[6] === '1',
2100
- '1':
2104
+ 1:
2101
2105
  utils.nHexDigit(
2102
2106
  utils.hex2bin(
2103
2107
  parsedData[
@@ -2106,15 +2110,15 @@ const parse = raw => {
2106
2110
  ),
2107
2111
  8
2108
2112
  )[7] === '1'
2109
- },
2110
- charge: null,
2111
- state:
2113
+ },
2114
+ charge: null,
2115
+ state:
2112
2116
  utils.states[
2113
2117
  parsedData[
2114
2118
  index - (includeStatus + accuracyInfo) + 1
2115
2119
  ].substring(0, 2)
2116
2120
  ]
2117
- }
2121
+ }
2118
2122
  : null,
2119
2123
  Hdop:
2120
2124
  accuracyInfo && parsedData[index - accuracyInfo + 1] !== ''
@@ -2193,43 +2197,43 @@ const parse = raw => {
2193
2197
  })
2194
2198
  } else if (command[1] === 'GTBAA') {
2195
2199
  // Bluetooth alarms
2196
- let appendIx = 8
2197
- let appendMask = utils.nHexDigit(utils.hex2bin(parsedData[appendIx]), 16)
2198
- let btAccessory = parsedData[5]
2199
- let aNameIx = appendIx + parseInt(appendMask[15])
2200
- let aMacIx = aNameIx + parseInt(appendMask[14])
2201
- let aStatIx = aMacIx + parseInt(appendMask[13])
2202
- let aBatIx = aStatIx + parseInt(appendMask[12])
2203
- let aTmpIx = aBatIx + parseInt(appendMask[11])
2204
- let aHumIx = aTmpIx + parseInt(appendMask[10])
2205
- let ioIx = aHumIx + parseInt(appendMask[8])
2206
- let aEvIx =
2200
+ const appendIx = 8
2201
+ const appendMask = utils.nHexDigit(utils.hex2bin(parsedData[appendIx]), 16)
2202
+ const btAccessory = parsedData[5]
2203
+ const aNameIx = appendIx + parseInt(appendMask[15])
2204
+ const aMacIx = aNameIx + parseInt(appendMask[14])
2205
+ const aStatIx = aMacIx + parseInt(appendMask[13])
2206
+ const aBatIx = aStatIx + parseInt(appendMask[12])
2207
+ const aTmpIx = aBatIx + parseInt(appendMask[11])
2208
+ const aHumIx = aTmpIx + parseInt(appendMask[10])
2209
+ const ioIx = aHumIx + parseInt(appendMask[8])
2210
+ const aEvIx =
2207
2211
  appendMask[8] === '1' && appendMask[7] === '1'
2208
2212
  ? ioIx + 3
2209
2213
  : ioIx + parseInt(appendMask[7])
2210
- let pressIx =
2214
+ const pressIx =
2211
2215
  appendMask[7] === '1' && appendMask[6] === '1'
2212
2216
  ? aEvIx + 2
2213
2217
  : aEvIx + parseInt(appendMask[6])
2214
- let timeIx = pressIx + parseInt(appendMask[5])
2215
- let eTmpIx = timeIx + parseInt(appendMask[4])
2216
- let magIx = eTmpIx + parseInt(appendMask[3])
2217
- let aBatpIx =
2218
+ const timeIx = pressIx + parseInt(appendMask[5])
2219
+ const eTmpIx = timeIx + parseInt(appendMask[4])
2220
+ const magIx = eTmpIx + parseInt(appendMask[3])
2221
+ const aBatpIx =
2218
2222
  appendMask[3] === '1' && appendMask[2] === '1'
2219
2223
  ? magIx + 3
2220
2224
  : magIx + parseInt(appendMask[2])
2221
- let relIx = aBatpIx + parseInt(appendMask[1])
2225
+ const relIx = aBatpIx + parseInt(appendMask[1])
2222
2226
 
2223
- let newIndex = relIx + 1 + parseInt(appendMask[1])
2227
+ const newIndex = relIx + 1 + parseInt(appendMask[1])
2224
2228
 
2225
- let satelliteInfo = utils.includeSatellites(parsedData[newIndex + 11])
2226
- let includeStatus = utils.includeStatus(parsedData[newIndex + 11])
2227
- let accuracyInfo = utils.includeGnnsAccuracy(parsedData[newIndex + 11])
2229
+ const satelliteInfo = utils.includeSatellites(parsedData[newIndex + 11])
2230
+ const includeStatus = utils.includeStatus(parsedData[newIndex + 11])
2231
+ const accuracyInfo = utils.includeGnnsAccuracy(parsedData[newIndex + 11])
2228
2232
  ? 3
2229
2233
  : 0
2230
- let index = newIndex + 11 + (satelliteInfo + includeStatus + accuracyInfo)
2234
+ const index = newIndex + 11 + (satelliteInfo + includeStatus + accuracyInfo)
2231
2235
 
2232
- let bleInfo = {
2236
+ const bleInfo = {
2233
2237
  accesory:
2234
2238
  btAccessory !== '' ? utils.bluetoothAccessories[btAccessory] : null,
2235
2239
  model: parsedData[6] !== '' ? parseInt(parsedData[6]) : null,
@@ -2257,7 +2261,7 @@ const parse = raw => {
2257
2261
  : null
2258
2262
  }
2259
2263
 
2260
- let bleData = {
2264
+ const bleData = {
2261
2265
  temperature:
2262
2266
  parsedData[aTmpIx] !== '' && appendMask[11] === '1'
2263
2267
  ? parseInt(parsedData[aTmpIx])
@@ -2369,19 +2373,19 @@ const parse = raw => {
2369
2373
  index - (satelliteInfo + includeStatus + accuracyInfo) + 1
2370
2374
  ] !== ''
2371
2375
  ? parseInt(
2372
- parsedData[
2373
- index - (satelliteInfo + includeStatus + accuracyInfo) + 1
2374
- ],
2375
- 10
2376
- )
2376
+ parsedData[
2377
+ index - (satelliteInfo + includeStatus + accuracyInfo) + 1
2378
+ ],
2379
+ 10
2380
+ )
2377
2381
  : null,
2378
2382
  status:
2379
2383
  includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
2380
2384
  ? {
2381
- raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
2382
- sos: false,
2383
- input: {
2384
- '2':
2385
+ raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
2386
+ sos: false,
2387
+ input: {
2388
+ 2:
2385
2389
  utils.nHexDigit(
2386
2390
  utils.hex2bin(
2387
2391
  parsedData[
@@ -2390,7 +2394,7 @@ const parse = raw => {
2390
2394
  ),
2391
2395
  8
2392
2396
  )[6] === '1',
2393
- '1':
2397
+ 1:
2394
2398
  utils.nHexDigit(
2395
2399
  utils.hex2bin(
2396
2400
  parsedData[
@@ -2399,9 +2403,9 @@ const parse = raw => {
2399
2403
  ),
2400
2404
  8
2401
2405
  )[7] === '1'
2402
- },
2403
- output: {
2404
- '3':
2406
+ },
2407
+ output: {
2408
+ 3:
2405
2409
  utils.nHexDigit(
2406
2410
  utils.hex2bin(
2407
2411
  parsedData[
@@ -2410,7 +2414,7 @@ const parse = raw => {
2410
2414
  ),
2411
2415
  8
2412
2416
  )[5] === '1',
2413
- '2':
2417
+ 2:
2414
2418
  utils.nHexDigit(
2415
2419
  utils.hex2bin(
2416
2420
  parsedData[
@@ -2419,7 +2423,7 @@ const parse = raw => {
2419
2423
  ),
2420
2424
  8
2421
2425
  )[6] === '1',
2422
- '1':
2426
+ 1:
2423
2427
  utils.nHexDigit(
2424
2428
  utils.hex2bin(
2425
2429
  parsedData[
@@ -2428,15 +2432,15 @@ const parse = raw => {
2428
2432
  ),
2429
2433
  8
2430
2434
  )[7] === '1'
2431
- },
2432
- charge: null,
2433
- state:
2435
+ },
2436
+ charge: null,
2437
+ state:
2434
2438
  utils.states[
2435
2439
  parsedData[
2436
2440
  index - (includeStatus + accuracyInfo) + 1
2437
2441
  ].substring(0, 2)
2438
2442
  ]
2439
- }
2443
+ }
2440
2444
  : null,
2441
2445
  Hdop:
2442
2446
  accuracyInfo && parsedData[index - accuracyInfo + 1] !== ''
@@ -2471,11 +2475,14 @@ const parse = raw => {
2471
2475
  })
2472
2476
  } else if (command[1] === 'GTBID') {
2473
2477
  // Bluetooth beacon detection
2474
- let number = parsedData[4] !== '' ? parseInt(parsedData[4]) : 1
2478
+ const number = parsedData[4] !== '' ? parseInt(parsedData[4]) : 1
2475
2479
  let index = 4
2476
2480
 
2477
- let binAppendMask = utils.nHexDigit(utils.hex2bin(parsedData[index + 2]), 8)
2478
- let appendMask = {
2481
+ const binAppendMask = utils.nHexDigit(
2482
+ utils.hex2bin(parsedData[index + 2]),
2483
+ 8
2484
+ )
2485
+ const appendMask = {
2479
2486
  accessoryMac: binAppendMask[6] === '1',
2480
2487
  batteryLevel: binAppendMask[4] === '1',
2481
2488
  signalStrength: binAppendMask[1] === '1',
@@ -2490,7 +2497,9 @@ const parse = raw => {
2490
2497
  ? 1
2491
2498
  : parsedData[index + 5] === '1'
2492
2499
  ? 3
2493
- : parsedData[index + 5] === '2' ? 2 : 0
2500
+ : parsedData[index + 5] === '2'
2501
+ ? 2
2502
+ : 0
2494
2503
  : 0
2495
2504
  index += 2 + appMk + extra
2496
2505
  }
@@ -2558,17 +2567,17 @@ const parse = raw => {
2558
2567
  hourmeter: null
2559
2568
  })
2560
2569
 
2561
- let btDevices = []
2570
+ const btDevices = []
2562
2571
  let btIndex = 5
2563
2572
  for (let i = 1; i <= number; i++) {
2564
- let appendMask = utils.nHexDigit(
2573
+ const appendMask = utils.nHexDigit(
2565
2574
  utils.hex2bin(parsedData[btIndex + 1]),
2566
2575
  8
2567
2576
  )
2568
- let macIx = btIndex + 1 + parseInt(appendMask[6])
2569
- let batIx = macIx + parseInt(appendMask[4])
2570
- let sigIx = batIx + parseInt(appendMask[1])
2571
- let typeIx = sigIx + parseInt(appendMask[0])
2577
+ const macIx = btIndex + 1 + parseInt(appendMask[6])
2578
+ const batIx = macIx + parseInt(appendMask[4])
2579
+ const sigIx = batIx + parseInt(appendMask[1])
2580
+ const typeIx = sigIx + parseInt(appendMask[0])
2572
2581
  btDevices.push({
2573
2582
  model:
2574
2583
  parsedData[btIndex] !== ''
@@ -2595,52 +2604,56 @@ const parse = raw => {
2595
2604
  data:
2596
2605
  appendMask[0] === '1' && parsedData[typeIx + 1] !== ''
2597
2606
  ? {
2598
- idMfrData:
2607
+ idMfrData:
2599
2608
  parsedData[typeIx] === '0' && parsedData[typeIx + 1] !== ''
2600
2609
  ? parsedData[typeIx + 1]
2601
2610
  : null,
2602
- uuid:
2611
+ uuid:
2603
2612
  parsedData[typeIx] === '1' && parsedData[typeIx + 1] !== ''
2604
2613
  ? parsedData[typeIx + 1]
2605
2614
  : null,
2606
- major:
2615
+ major:
2607
2616
  parsedData[typeIx] === '1' && parsedData[typeIx + 2] !== ''
2608
2617
  ? parsedData[typeIx + 2]
2609
2618
  : null,
2610
- minor:
2619
+ minor:
2611
2620
  parsedData[typeIx] === '1' && parsedData[typeIx + 3] !== ''
2612
2621
  ? parsedData[typeIx + 3]
2613
2622
  : null,
2614
- nid:
2623
+ nid:
2615
2624
  parsedData[typeIx] === '2' && parsedData[typeIx + 1] !== ''
2616
2625
  ? parsedData[typeIx + 1]
2617
2626
  : null,
2618
- bid:
2627
+ bid:
2619
2628
  parsedData[typeIx] === '2' && parsedData[typeIx + 2] !== ''
2620
2629
  ? parsedData[typeIx + 2]
2621
2630
  : null
2622
- }
2631
+ }
2623
2632
  : null
2624
2633
  })
2625
- let extra =
2634
+ const extra =
2626
2635
  parsedData[typeIx] === '0'
2627
2636
  ? 1
2628
- : parsedData[typeIx] === '1' ? 3 : parsedData[typeIx] === '2' ? 2 : 0
2637
+ : parsedData[typeIx] === '1'
2638
+ ? 3
2639
+ : parsedData[typeIx] === '2'
2640
+ ? 2
2641
+ : 0
2629
2642
  btIndex = typeIx + 1 + extra
2630
2643
  }
2631
- let bluetoothData = {
2644
+ const bluetoothData = {
2632
2645
  connectedDevices: number,
2633
- btDevices: btDevices
2646
+ btDevices
2634
2647
  }
2635
2648
 
2636
2649
  data = Object.assign(data, {
2637
- bluetoothData: bluetoothData
2650
+ bluetoothData
2638
2651
  })
2639
2652
  } else if (command[1] === 'GTVGN' || command[1] === 'GTVGF') {
2640
2653
  // Virtual ignition
2641
2654
  let index = 18 // possition append mask
2642
2655
  let satelliteInfo = false
2643
- let includeStatus =
2656
+ const includeStatus =
2644
2657
  parsedData[index] !== '' ? parseInt(parsedData[index]) > 3 : null
2645
2658
 
2646
2659
  // If get satellites is configured
@@ -2685,40 +2698,40 @@ const parse = raw => {
2685
2698
  : null,
2686
2699
  status: includeStatus
2687
2700
  ? {
2688
- raw: parsedData[index + 1],
2689
- sos: false,
2690
- input: {
2691
- '2':
2701
+ raw: parsedData[index + 1],
2702
+ sos: false,
2703
+ input: {
2704
+ 2:
2692
2705
  utils.nHexDigit(
2693
2706
  utils.hex2bin(parsedData[index + 1].substring(2, 4)),
2694
2707
  8
2695
2708
  )[6] === '1',
2696
- '1':
2709
+ 1:
2697
2710
  utils.nHexDigit(
2698
2711
  utils.hex2bin(parsedData[index + 1].substring(2, 4)),
2699
2712
  8
2700
2713
  )[7] === '1'
2701
- },
2702
- output: {
2703
- '3':
2714
+ },
2715
+ output: {
2716
+ 3:
2704
2717
  utils.nHexDigit(
2705
2718
  utils.hex2bin(parsedData[index + 1].substring(4, 6)),
2706
2719
  8
2707
2720
  )[5] === '1',
2708
- '2':
2721
+ 2:
2709
2722
  utils.nHexDigit(
2710
2723
  utils.hex2bin(parsedData[index + 1].substring(4, 6)),
2711
2724
  8
2712
2725
  )[6] === '1',
2713
- '1':
2726
+ 1:
2714
2727
  utils.nHexDigit(
2715
2728
  utils.hex2bin(parsedData[index + 1].substring(4, 6)),
2716
2729
  8
2717
2730
  )[7] === '1'
2718
- },
2719
- charge: null,
2720
- state: utils.states[parsedData[index + 1].substring(0, 2)]
2721
- }
2731
+ },
2732
+ charge: null,
2733
+ state: utils.states[parsedData[index + 1].substring(0, 2)]
2734
+ }
2722
2735
  : null,
2723
2736
  odometer: includeStatus
2724
2737
  ? parsedData[index + 3] !== ''
@@ -2740,7 +2753,7 @@ const parse = raw => {
2740
2753
  alarm: utils.getAlarm(command[1], null),
2741
2754
  fixType: parsedData[3] !== '' ? parsedData[3] : null
2742
2755
  })
2743
- let antData = []
2756
+ const antData = []
2744
2757
  let index = 4
2745
2758
  for (let i = 0; i < 6; i++) {
2746
2759
  antData.push({
@@ -2762,16 +2775,16 @@ const parse = raw => {
2762
2775
  rxLevel:
2763
2776
  parsedData[index + 4] !== ''
2764
2777
  ? utils.getSignalStrength(
2765
- 'GSM',
2766
- parseInt(parsedData[index + 4], 10)
2767
- )
2778
+ 'GSM',
2779
+ parseInt(parsedData[index + 4], 10)
2780
+ )
2768
2781
  : null,
2769
2782
  rxSignalPercentage:
2770
2783
  parsedData[index + 4] !== ''
2771
2784
  ? utils.getSignalPercentage(
2772
- 'GSM',
2773
- parseInt(parsedData[index + 4], 10)
2774
- )
2785
+ 'GSM',
2786
+ parseInt(parsedData[index + 4], 10)
2787
+ )
2775
2788
  : null
2776
2789
  })
2777
2790
  index += 6
@@ -2800,9 +2813,9 @@ const parse = raw => {
2800
2813
  rxSignalPercentage:
2801
2814
  parsedData[index + 4] !== ''
2802
2815
  ? utils.getSignalPercentage(
2803
- 'GSM',
2804
- parseInt(parsedData[index + 4], 10)
2805
- )
2816
+ 'GSM',
2817
+ parseInt(parsedData[index + 4], 10)
2818
+ )
2806
2819
  : null
2807
2820
  })
2808
2821
  } else if (command[1] === 'GTCLT') {
@@ -2810,7 +2823,7 @@ const parse = raw => {
2810
2823
  let index = 71 // position append mask
2811
2824
  let satelliteInfo = false
2812
2825
 
2813
- let includeStatus =
2826
+ const includeStatus =
2814
2827
  parsedData[index] !== '' ? parseInt(parsedData[index]) > 3 : null
2815
2828
 
2816
2829
  // If get satellites is configured
@@ -2819,65 +2832,65 @@ const parse = raw => {
2819
2832
  satelliteInfo = true
2820
2833
  }
2821
2834
 
2822
- let alarmMask1 =
2835
+ const alarmMask1 =
2823
2836
  parsedData[5] !== ''
2824
2837
  ? utils
2825
- .nHexDigit(utils.hex2bin(parsedData[5]), 32)
2826
- .split('')
2827
- .reverse()
2828
- .join('')
2838
+ .nHexDigit(utils.hex2bin(parsedData[5]), 32)
2839
+ .split('')
2840
+ .reverse()
2841
+ .join('')
2829
2842
  : null
2830
- let alarmMask2 =
2843
+ const alarmMask2 =
2831
2844
  parsedData[6] !== ''
2832
2845
  ? utils
2833
- .nHexDigit(utils.hex2bin(parsedData[6]), 32)
2834
- .split('')
2835
- .reverse()
2836
- .join('')
2846
+ .nHexDigit(utils.hex2bin(parsedData[6]), 32)
2847
+ .split('')
2848
+ .reverse()
2849
+ .join('')
2837
2850
  : null
2838
- let alarmMask3 =
2851
+ const alarmMask3 =
2839
2852
  parsedData[7] !== ''
2840
2853
  ? utils
2841
- .nHexDigit(utils.hex2bin(parsedData[7]), 32)
2842
- .split('')
2843
- .reverse()
2844
- .join('')
2854
+ .nHexDigit(utils.hex2bin(parsedData[7]), 32)
2855
+ .split('')
2856
+ .reverse()
2857
+ .join('')
2845
2858
  : null
2846
- let inicatorsBin =
2859
+ const inicatorsBin =
2847
2860
  parsedData[28] !== ''
2848
2861
  ? utils.nHexDigit(utils.hex2bin(parsedData[28]), 16)
2849
2862
  : null
2850
- let lights =
2863
+ const lights =
2851
2864
  parsedData[29] !== ''
2852
2865
  ? utils.nHexDigit(utils.hex2bin(parsedData[29]), 8)
2853
2866
  : null
2854
- let doors =
2867
+ const doors =
2855
2868
  parsedData[30] !== ''
2856
2869
  ? utils.nHexDigit(utils.hex2bin(parsedData[30]), 8)
2857
2870
  : null
2858
- let canExpansionMask =
2871
+ const canExpansionMask =
2859
2872
  parsedData[33] !== ''
2860
2873
  ? utils
2861
- .nHexDigit(utils.hex2bin(parsedData[33]), 32)
2862
- .split('')
2863
- .reverse()
2864
- .join('')
2874
+ .nHexDigit(utils.hex2bin(parsedData[33]), 32)
2875
+ .split('')
2876
+ .reverse()
2877
+ .join('')
2865
2878
  : null
2866
- let expansionBin =
2879
+ const expansionBin =
2867
2880
  parsedData[54] !== ''
2868
2881
  ? utils
2869
- .nHexDigit(utils.hex2bin(parsedData[54]), 16)
2870
- .split('')
2871
- .reverse()
2872
- .join('')
2882
+ .nHexDigit(utils.hex2bin(parsedData[54]), 16)
2883
+ .split('')
2884
+ .reverse()
2885
+ .join('')
2873
2886
  : null
2874
- let tachographBin =
2887
+ const tachographBin =
2875
2888
  parsedData[27] !== ''
2876
2889
  ? utils
2877
- .nHexDigit(utils.hex2bin(parsedData[27]), 8)
2878
- .split('')
2879
- .reverse()
2880
- .join('')
2890
+ .nHexDigit(utils.hex2bin(parsedData[27]), 8)
2891
+ .split('')
2892
+ .reverse()
2893
+ .join('')
2881
2894
  : null
2882
2895
  data = Object.assign(data, {
2883
2896
  alarm: utils.getAlarm(command[1], parsedData[6]),
@@ -2912,40 +2925,40 @@ const parse = raw => {
2912
2925
  : null,
2913
2926
  status: includeStatus
2914
2927
  ? {
2915
- raw: parsedData[index + 1],
2916
- sos: false,
2917
- input: {
2918
- '2':
2928
+ raw: parsedData[index + 1],
2929
+ sos: false,
2930
+ input: {
2931
+ 2:
2919
2932
  utils.nHexDigit(
2920
2933
  utils.hex2bin(parsedData[index + 1].substring(2, 4)),
2921
2934
  8
2922
2935
  )[6] === '1',
2923
- '1':
2936
+ 1:
2924
2937
  utils.nHexDigit(
2925
2938
  utils.hex2bin(parsedData[index + 1].substring(2, 4)),
2926
2939
  8
2927
2940
  )[7] === '1'
2928
- },
2929
- output: {
2930
- '3':
2941
+ },
2942
+ output: {
2943
+ 3:
2931
2944
  utils.nHexDigit(
2932
2945
  utils.hex2bin(parsedData[index + 1].substring(4, 6)),
2933
2946
  8
2934
2947
  )[5] === '1',
2935
- '2':
2948
+ 2:
2936
2949
  utils.nHexDigit(
2937
2950
  utils.hex2bin(parsedData[index + 1].substring(4, 6)),
2938
2951
  8
2939
2952
  )[6] === '1',
2940
- '1':
2953
+ 1:
2941
2954
  utils.nHexDigit(
2942
2955
  utils.hex2bin(parsedData[index + 1].substring(4, 6)),
2943
2956
  8
2944
2957
  )[7] === '1'
2945
- },
2946
- charge: null,
2947
- state: utils.states[parsedData[index + 1].substring(0, 2)]
2948
- }
2958
+ },
2959
+ charge: null,
2960
+ state: utils.states[parsedData[index + 1].substring(0, 2)]
2961
+ }
2949
2962
  : null,
2950
2963
  odometer: null,
2951
2964
  hourmeter: null,
@@ -3266,7 +3279,7 @@ const parse = raw => {
3266
3279
  let index = 24 // possition append mask
3267
3280
  let satelliteInfo = false
3268
3281
 
3269
- let includeStatus =
3282
+ const includeStatus =
3270
3283
  parsedData[index] !== '' ? parseInt(parsedData[index]) > 3 : null
3271
3284
 
3272
3285
  // If get satellites is configured
@@ -3311,40 +3324,40 @@ const parse = raw => {
3311
3324
  : null,
3312
3325
  status: includeStatus
3313
3326
  ? {
3314
- raw: parsedData[index + 1],
3315
- sos: false,
3316
- input: {
3317
- '2':
3327
+ raw: parsedData[index + 1],
3328
+ sos: false,
3329
+ input: {
3330
+ 2:
3318
3331
  utils.nHexDigit(
3319
3332
  utils.hex2bin(parsedData[index + 1].substring(2, 4)),
3320
3333
  8
3321
3334
  )[6] === '1',
3322
- '1':
3335
+ 1:
3323
3336
  utils.nHexDigit(
3324
3337
  utils.hex2bin(parsedData[index + 1].substring(2, 4)),
3325
3338
  8
3326
3339
  )[7] === '1'
3327
- },
3328
- output: {
3329
- '3':
3340
+ },
3341
+ output: {
3342
+ 3:
3330
3343
  utils.nHexDigit(
3331
3344
  utils.hex2bin(parsedData[index + 1].substring(4, 6)),
3332
3345
  8
3333
3346
  )[5] === '1',
3334
- '2':
3347
+ 2:
3335
3348
  utils.nHexDigit(
3336
3349
  utils.hex2bin(parsedData[index + 1].substring(4, 6)),
3337
3350
  8
3338
3351
  )[6] === '1',
3339
- '1':
3352
+ 1:
3340
3353
  utils.nHexDigit(
3341
3354
  utils.hex2bin(parsedData[index + 1].substring(4, 6)),
3342
3355
  8
3343
3356
  )[7] === '1'
3344
- },
3345
- charge: null,
3346
- state: utils.states[parsedData[index + 1].substring(0, 2)]
3347
- }
3357
+ },
3358
+ charge: null,
3359
+ state: utils.states[parsedData[index + 1].substring(0, 2)]
3360
+ }
3348
3361
  : null,
3349
3362
  calibration: {
3350
3363
  xForward: parsedData[4] !== '' ? parseFloat(parsedData[4]) : null,
@@ -3365,7 +3378,7 @@ const parse = raw => {
3365
3378
  // Only works when GTHBM is in mode 5
3366
3379
  let index = 18 // possition append mask
3367
3380
  let satelliteInfo = false
3368
- let includeStatus =
3381
+ const includeStatus =
3369
3382
  parsedData[index] !== '' ? parseInt(parsedData[index]) > 3 : null
3370
3383
 
3371
3384
  // If get satellites is configured
@@ -3374,20 +3387,28 @@ const parse = raw => {
3374
3387
  satelliteInfo = true
3375
3388
  }
3376
3389
 
3377
- let maxAcc = includeStatus
3378
- ? parsedData[index + 2] !== '' ? parsedData[index + 2] : null
3379
- : parsedData[index + 1] !== '' ? parsedData[index + 1] : null
3380
- let avgAcc = includeStatus
3381
- ? parsedData[index + 3] !== '' ? parsedData[index + 3] : null
3382
- : parsedData[index + 2] !== '' ? parsedData[index + 2] : null
3383
- let duration = includeStatus
3390
+ const maxAcc = includeStatus
3391
+ ? parsedData[index + 2] !== ''
3392
+ ? parsedData[index + 2]
3393
+ : null
3394
+ : parsedData[index + 1] !== ''
3395
+ ? parsedData[index + 1]
3396
+ : null
3397
+ const avgAcc = includeStatus
3398
+ ? parsedData[index + 3] !== ''
3399
+ ? parsedData[index + 3]
3400
+ : null
3401
+ : parsedData[index + 2] !== ''
3402
+ ? parsedData[index + 2]
3403
+ : null
3404
+ const duration = includeStatus
3384
3405
  ? parsedData[index + 4] !== ''
3385
3406
  ? parseFloat(parsedData[index + 4]) / 100
3386
3407
  : null
3387
3408
  : parsedData[index + 3] !== ''
3388
3409
  ? parseFloat(parsedData[index + 3]) / 100
3389
3410
  : null
3390
- let speed = parsedData[8] !== '' ? parseFloat(parsedData[8]) : null
3411
+ const speed = parsedData[8] !== '' ? parseFloat(parsedData[8]) : null
3391
3412
 
3392
3413
  data = Object.assign(data, {
3393
3414
  alarm: utils.getAlarm(
@@ -3399,7 +3420,7 @@ const parse = raw => {
3399
3420
  type: 'Point',
3400
3421
  coordinates: [parseFloat(parsedData[11]), parseFloat(parsedData[12])]
3401
3422
  },
3402
- speed: speed,
3423
+ speed,
3403
3424
  gpsStatus: utils.checkGps(
3404
3425
  parseFloat(parsedData[11]),
3405
3426
  parseFloat(parsedData[12])
@@ -3429,40 +3450,40 @@ const parse = raw => {
3429
3450
  : null,
3430
3451
  status: includeStatus
3431
3452
  ? {
3432
- raw: parsedData[index + 1],
3433
- sos: false,
3434
- input: {
3435
- '2':
3453
+ raw: parsedData[index + 1],
3454
+ sos: false,
3455
+ input: {
3456
+ 2:
3436
3457
  utils.nHexDigit(
3437
3458
  utils.hex2bin(parsedData[index + 1].substring(2, 4)),
3438
3459
  8
3439
3460
  )[6] === '1',
3440
- '1':
3461
+ 1:
3441
3462
  utils.nHexDigit(
3442
3463
  utils.hex2bin(parsedData[index + 1].substring(2, 4)),
3443
3464
  8
3444
3465
  )[7] === '1'
3445
- },
3446
- output: {
3447
- '3':
3466
+ },
3467
+ output: {
3468
+ 3:
3448
3469
  utils.nHexDigit(
3449
3470
  utils.hex2bin(parsedData[index + 1].substring(4, 6)),
3450
3471
  8
3451
3472
  )[5] === '1',
3452
- '2':
3473
+ 2:
3453
3474
  utils.nHexDigit(
3454
3475
  utils.hex2bin(parsedData[index + 1].substring(4, 6)),
3455
3476
  8
3456
3477
  )[6] === '1',
3457
- '1':
3478
+ 1:
3458
3479
  utils.nHexDigit(
3459
3480
  utils.hex2bin(parsedData[index + 1].substring(4, 6)),
3460
3481
  8
3461
3482
  )[7] === '1'
3462
- },
3463
- charge: null,
3464
- state: utils.states[parsedData[index + 1].substring(0, 2)]
3465
- }
3483
+ },
3484
+ charge: null,
3485
+ state: utils.states[parsedData[index + 1].substring(0, 2)]
3486
+ }
3466
3487
  : null,
3467
3488
  maxAcceleration: {
3468
3489
  // Acceleration in m/s2
@@ -3490,7 +3511,7 @@ const parse = raw => {
3490
3511
  ? utils.getAccelerationMagnitude(avgAcc.substring(8, 12), 4)
3491
3512
  : null
3492
3513
  },
3493
- duration: duration,
3514
+ duration,
3494
3515
  odometer: includeStatus
3495
3516
  ? parsedData[index + 5] !== ''
3496
3517
  ? parseFloat(parsedData[index + 5])
@@ -3521,5 +3542,5 @@ const parse = raw => {
3521
3542
  }
3522
3543
 
3523
3544
  module.exports = {
3524
- parse: parse
3545
+ parse
3525
3546
  }