queclink-parser 1.9.12 → 1.9.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/example.js +110 -106
- package/package.json +1 -1
- package/src/gv310lau.js +173 -241
- package/src/gv57cg.js +4 -4
- package/src/gv58lau.js +837 -1231
- package/src/index.js +11 -2
- package/src/messages/es.json +11 -10
- package/src/utils.js +274 -24
package/src/gv58lau.js
CHANGED
|
@@ -33,8 +33,9 @@ const parse = raw => {
|
|
|
33
33
|
try {
|
|
34
34
|
let number = parsedData[6] !== '' ? parseInt(parsedData[6], 10) : 1
|
|
35
35
|
let satelliteInfo = utils.includeSatellites(parsedData[18])
|
|
36
|
-
let
|
|
37
|
-
let
|
|
36
|
+
let gnnsTriggerType = utils.includeGnssTrigger(parsedData[18])
|
|
37
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[18]) ? 3 : 0
|
|
38
|
+
let index = 6 + (12 + satelliteInfo + gnnsTriggerType + accuracyInfo) * number
|
|
38
39
|
|
|
39
40
|
data = Object.assign(data, {
|
|
40
41
|
alarm: utils.getAlarm(command[1], null),
|
|
@@ -49,68 +50,80 @@ const parse = raw => {
|
|
|
49
50
|
),
|
|
50
51
|
hdop: parsedData[7] !== '' ? parseFloat(parsedData[7]) : null,
|
|
51
52
|
status: {
|
|
52
|
-
raw: parsedData[index +
|
|
53
|
+
raw: parsedData[index + 7],
|
|
53
54
|
sos: false,
|
|
54
55
|
input: {
|
|
55
56
|
'2':
|
|
56
57
|
utils.nHexDigit(
|
|
57
|
-
utils.hex2bin(parsedData[index +
|
|
58
|
+
utils.hex2bin(parsedData[index + 7].substring(2, 4)),
|
|
58
59
|
8
|
|
59
60
|
)[6] === '1',
|
|
60
61
|
'1':
|
|
61
62
|
utils.nHexDigit(
|
|
62
|
-
utils.hex2bin(parsedData[index +
|
|
63
|
+
utils.hex2bin(parsedData[index + 7].substring(2, 4)),
|
|
63
64
|
8
|
|
64
65
|
)[7] === '1'
|
|
65
66
|
},
|
|
66
67
|
output: {
|
|
67
68
|
'3':
|
|
68
69
|
utils.nHexDigit(
|
|
69
|
-
utils.hex2bin(parsedData[index +
|
|
70
|
+
utils.hex2bin(parsedData[index + 7].substring(4, 6)),
|
|
70
71
|
8
|
|
71
72
|
)[5] === '1',
|
|
72
73
|
'2':
|
|
73
74
|
utils.nHexDigit(
|
|
74
|
-
utils.hex2bin(parsedData[index +
|
|
75
|
+
utils.hex2bin(parsedData[index + 7].substring(4, 6)),
|
|
75
76
|
8
|
|
76
77
|
)[6] === '1',
|
|
77
78
|
'1':
|
|
78
79
|
utils.nHexDigit(
|
|
79
|
-
utils.hex2bin(parsedData[index +
|
|
80
|
+
utils.hex2bin(parsedData[index + 7].substring(4, 6)),
|
|
80
81
|
8
|
|
81
82
|
)[7] === '1'
|
|
82
83
|
},
|
|
83
84
|
charge: parseFloat(parsedData[4]) > 5,
|
|
84
|
-
state: utils.states[parsedData[index +
|
|
85
|
+
state: utils.states[parsedData[index + 7].substring(0, 2)]
|
|
85
86
|
},
|
|
86
87
|
azimuth: parsedData[9] !== '' ? parseFloat(parsedData[9]) : null,
|
|
87
88
|
altitude: parsedData[10] !== '' ? parseFloat(parsedData[10]) : null,
|
|
88
89
|
datetime:
|
|
89
90
|
parsedData[13] !== '' ? utils.parseDate(parsedData[13]) : null,
|
|
90
91
|
voltage: {
|
|
91
|
-
battery: parsedData[index +
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
battery: parsedData[index + 6] !== ''
|
|
93
|
+
? parseFloat(parsedData[index + 6])
|
|
94
|
+
: null,
|
|
94
95
|
inputCharge:
|
|
95
96
|
parsedData[4] !== '' ? parseFloat(parsedData[4]) / 1000 : null
|
|
96
97
|
},
|
|
97
|
-
mcc: parsedData[14] !== '' ? utils.latamMcc[parseInt(parsedData[14], 10)] : null,
|
|
98
|
+
mcc: parsedData[14] !== '' ? utils.latamMcc[parseInt(parsedData[14], 10)] || utils.latamMcc.default : null,
|
|
98
99
|
mnc: parsedData[15] !== '' ? utils.getMNC(parsedData[14], parsedData[15]) : null,
|
|
99
100
|
lac: parsedData[16] !== '' ? parseInt(parsedData[16], 16) : null,
|
|
100
101
|
cid: parsedData[17] !== '' ? parseInt(parsedData[17], 16) : null,
|
|
101
102
|
satellites:
|
|
102
|
-
satelliteInfo && parsedData[index - (satelliteInfo +
|
|
103
|
-
? parseInt(parsedData[index - (satelliteInfo +
|
|
103
|
+
satelliteInfo && parsedData[index - (satelliteInfo + gnnsTriggerType + accuracyInfo) + 1] !== ''
|
|
104
|
+
? parseInt(parsedData[index - (satelliteInfo + gnnsTriggerType + accuracyInfo) + 1], 10)
|
|
104
105
|
: null,
|
|
105
106
|
gnssTrigger:
|
|
106
|
-
|
|
107
|
-
? utils.gnssTriggerTypes[parsedData[index -
|
|
107
|
+
gnnsTriggerType && parsedData[index - (gnnsTriggerType + accuracyInfo) + 1] !== ''
|
|
108
|
+
? utils.gnssTriggerTypes[parsedData[index - (gnnsTriggerType + accuracyInfo) + 1]]
|
|
109
|
+
: null,
|
|
110
|
+
Hdop:
|
|
111
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
112
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1], 10)
|
|
113
|
+
: null,
|
|
114
|
+
Vdop:
|
|
115
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
116
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2], 10)
|
|
117
|
+
: null,
|
|
118
|
+
Ddop:
|
|
119
|
+
accuracyInfo && parsedData[index] !== ''
|
|
120
|
+
? parseFloat(parsedData[index], 10)
|
|
108
121
|
: null,
|
|
109
122
|
odometer:
|
|
110
|
-
parsedData[index] !== '' ? parseFloat(parsedData[index]) : null,
|
|
123
|
+
parsedData[index + 1] !== '' ? parseFloat(parsedData[index + 1]) : null,
|
|
111
124
|
hourmeter:
|
|
112
|
-
parsedData[index +
|
|
113
|
-
? utils.getHoursForHourmeter(parsedData[index +
|
|
125
|
+
parsedData[index + 2] !== ''
|
|
126
|
+
? utils.getHoursForHourmeter(parsedData[index + 2])
|
|
114
127
|
: null
|
|
115
128
|
})
|
|
116
129
|
|
|
@@ -118,7 +131,7 @@ const parse = raw => {
|
|
|
118
131
|
if (number > 1) {
|
|
119
132
|
let moreData = []
|
|
120
133
|
for (let i = 1; i < number; i++) {
|
|
121
|
-
let gnssIx = 7 + (12 +
|
|
134
|
+
let gnssIx = 7 + (12 + gnnsTriggerType + satelliteInfo + accuracyInfo) * i
|
|
122
135
|
|
|
123
136
|
moreData.push({
|
|
124
137
|
index: i,
|
|
@@ -168,15 +181,27 @@ const parse = raw => {
|
|
|
168
181
|
? parseInt(parsedData[gnssIx + 10], 16)
|
|
169
182
|
: null,
|
|
170
183
|
satellites:
|
|
171
|
-
satelliteInfo && parsedData[gnssIx
|
|
172
|
-
? parseInt(parsedData[gnssIx
|
|
184
|
+
satelliteInfo && parsedData[gnssIx - (satelliteInfo + gnnsTriggerType + accuracyInfo)] !== ''
|
|
185
|
+
? parseInt(parsedData[gnssIx - (satelliteInfo + gnnsTriggerType + accuracyInfo)], 10)
|
|
173
186
|
: null,
|
|
174
187
|
gnssTrigger:
|
|
175
|
-
|
|
176
|
-
|
|
188
|
+
gnnsTriggerType &&
|
|
189
|
+
parsedData[gnssIx - (gnnsTriggerType + accuracyInfo)] !== ''
|
|
177
190
|
? utils.gnssTriggerTypes[
|
|
178
|
-
|
|
191
|
+
parsedData[gnssIx - (gnnsTriggerType + accuracyInfo)]
|
|
179
192
|
]
|
|
193
|
+
: null,
|
|
194
|
+
Hdop:
|
|
195
|
+
accuracyInfo && parsedData[gnssIx - (accuracyInfo)] !== ''
|
|
196
|
+
? parseFloat(parsedData[gnssIx - (accuracyInfo)], 10)
|
|
197
|
+
: null,
|
|
198
|
+
Vdop:
|
|
199
|
+
accuracyInfo && parsedData[gnssIx - (accuracyInfo) + 1] !== ''
|
|
200
|
+
? parseFloat(parsedData[gnssIx - (accuracyInfo) + 1], 10)
|
|
201
|
+
: null,
|
|
202
|
+
Ddop:
|
|
203
|
+
accuracyInfo && parsedData[gnssIx - 1] !== ''
|
|
204
|
+
? parseFloat(parsedData[gnssIx - 1], 10)
|
|
180
205
|
: null
|
|
181
206
|
})
|
|
182
207
|
}
|
|
@@ -190,8 +215,9 @@ const parse = raw => {
|
|
|
190
215
|
// GPS with AC100 and/or Bluetoth Devices Connected
|
|
191
216
|
let number = parsedData[7] !== '' ? parseInt(parsedData[7], 10) : 1
|
|
192
217
|
let satelliteInfo = utils.includeSatellites(parsedData[19])
|
|
193
|
-
let
|
|
194
|
-
let
|
|
218
|
+
let gnnsTriggerType = utils.includeGnssTrigger(parsedData[19])
|
|
219
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[19]) ? 3 : 0
|
|
220
|
+
let index = 7 + (12 + satelliteInfo + gnnsTriggerType + accuracyInfo) * number
|
|
195
221
|
|
|
196
222
|
data = Object.assign(data, {
|
|
197
223
|
alarm: utils.getAlarm(command[1], null),
|
|
@@ -206,47 +232,47 @@ const parse = raw => {
|
|
|
206
232
|
),
|
|
207
233
|
hdop: parsedData[8] !== '' ? parseFloat(parsedData[8]) : null,
|
|
208
234
|
status: {
|
|
209
|
-
raw: parsedData[index +
|
|
235
|
+
raw: parsedData[index + 7],
|
|
210
236
|
sos: false,
|
|
211
237
|
input: {
|
|
212
238
|
'2':
|
|
213
239
|
utils.nHexDigit(
|
|
214
|
-
utils.hex2bin(parsedData[index +
|
|
240
|
+
utils.hex2bin(parsedData[index + 7].substring(2, 4)),
|
|
215
241
|
8
|
|
216
|
-
)[
|
|
242
|
+
)[6] === '1',
|
|
217
243
|
'1':
|
|
218
244
|
utils.nHexDigit(
|
|
219
|
-
utils.hex2bin(parsedData[index +
|
|
245
|
+
utils.hex2bin(parsedData[index + 7].substring(2, 4)),
|
|
220
246
|
8
|
|
221
|
-
)[
|
|
247
|
+
)[7] === '1'
|
|
222
248
|
},
|
|
223
249
|
output: {
|
|
224
250
|
'3':
|
|
225
251
|
utils.nHexDigit(
|
|
226
|
-
utils.hex2bin(parsedData[index +
|
|
252
|
+
utils.hex2bin(parsedData[index + 7].substring(4, 6)),
|
|
227
253
|
8
|
|
228
254
|
)[5] === '1',
|
|
229
255
|
'2':
|
|
230
256
|
utils.nHexDigit(
|
|
231
|
-
utils.hex2bin(parsedData[index +
|
|
257
|
+
utils.hex2bin(parsedData[index + 7].substring(4, 6)),
|
|
232
258
|
8
|
|
233
259
|
)[6] === '1',
|
|
234
260
|
'1':
|
|
235
261
|
utils.nHexDigit(
|
|
236
|
-
utils.hex2bin(parsedData[index +
|
|
262
|
+
utils.hex2bin(parsedData[index + 7].substring(4, 6)),
|
|
237
263
|
8
|
|
238
264
|
)[7] === '1'
|
|
239
265
|
},
|
|
240
266
|
charge: parseFloat(parsedData[5]) > 5,
|
|
241
|
-
state: utils.states[parsedData[index +
|
|
267
|
+
state: utils.states[parsedData[index + 7].substring(0, 2)]
|
|
242
268
|
},
|
|
243
269
|
azimuth: parsedData[10] !== '' ? parseFloat(parsedData[10]) : null,
|
|
244
270
|
altitude: parsedData[11] !== '' ? parseFloat(parsedData[11]) : null,
|
|
245
271
|
datetime: parsedData[14] !== '' ? utils.parseDate(parsedData[14]) : null,
|
|
246
272
|
voltage: {
|
|
247
273
|
battery:
|
|
248
|
-
parsedData[index +
|
|
249
|
-
? parseFloat(parsedData[index +
|
|
274
|
+
parsedData[index + 6] !== ''
|
|
275
|
+
? parseFloat(parsedData[index + 6])
|
|
250
276
|
: null, // percentage
|
|
251
277
|
inputCharge:
|
|
252
278
|
parsedData[5] !== '' ? parseFloat(parsedData[5]) / 1000 : null
|
|
@@ -256,17 +282,29 @@ const parse = raw => {
|
|
|
256
282
|
lac: parsedData[17] !== '' ? parseInt(parsedData[17], 16) : null,
|
|
257
283
|
cid: parsedData[18] !== '' ? parseInt(parsedData[18], 16) : null,
|
|
258
284
|
satellites:
|
|
259
|
-
satelliteInfo && parsedData[index - (satelliteInfo +
|
|
260
|
-
? parseInt(parsedData[index - (satelliteInfo +
|
|
285
|
+
satelliteInfo && parsedData[index - (satelliteInfo + gnnsTriggerType + accuracyInfo) + 1] !== ''
|
|
286
|
+
? parseInt(parsedData[index - (satelliteInfo + gnnsTriggerType + accuracyInfo) + 1], 10)
|
|
261
287
|
: null,
|
|
262
288
|
gnssTrigger:
|
|
263
|
-
|
|
264
|
-
? utils.gnssTriggerTypes[parsedData[index -
|
|
289
|
+
gnnsTriggerType && parsedData[index - (gnnsTriggerType + accuracyInfo) + 1] !== ''
|
|
290
|
+
? utils.gnssTriggerTypes[parsedData[index - (gnnsTriggerType + accuracyInfo) + 1]]
|
|
291
|
+
: null,
|
|
292
|
+
Hdop:
|
|
293
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
294
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1], 10)
|
|
265
295
|
: null,
|
|
266
|
-
|
|
296
|
+
Vdop:
|
|
297
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
298
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2], 10)
|
|
299
|
+
: null,
|
|
300
|
+
Ddop:
|
|
301
|
+
accuracyInfo && parsedData[index] !== ''
|
|
302
|
+
? parseFloat(parsedData[index], 10)
|
|
303
|
+
: null,
|
|
304
|
+
odometer: parsedData[index + 1] !== '' ? parseFloat(parsedData[index + 1]) : null,
|
|
267
305
|
hourmeter:
|
|
268
|
-
parsedData[index +
|
|
269
|
-
? utils.getHoursForHourmeter(parsedData[index +
|
|
306
|
+
parsedData[index + 2] !== ''
|
|
307
|
+
? utils.getHoursForHourmeter(parsedData[index + 2])
|
|
270
308
|
: null
|
|
271
309
|
})
|
|
272
310
|
// External Data
|
|
@@ -284,179 +322,16 @@ const parse = raw => {
|
|
|
284
322
|
|
|
285
323
|
// Bluetooth Accessories
|
|
286
324
|
if (bluetoothAccessory) {
|
|
287
|
-
let btDevices = []
|
|
288
325
|
let btIndex
|
|
289
326
|
|
|
290
327
|
if (canData) {
|
|
291
|
-
btIndex = index +
|
|
328
|
+
btIndex = index + 58
|
|
292
329
|
} else {
|
|
293
|
-
btIndex = index +
|
|
330
|
+
btIndex = index + 9
|
|
294
331
|
}
|
|
295
332
|
|
|
296
|
-
let
|
|
297
|
-
let btNum = parsedData[btIndex] !== '' ? parseInt(parsedData[btIndex]) : 1
|
|
298
|
-
|
|
299
|
-
for (let c = 0; c < btNum; c++) {
|
|
300
|
-
let appendMask = utils.nHexDigit(utils.hex2bin(parsedData[cnt + 4]), 16)
|
|
333
|
+
let btDevices = utils.getBleData(parsedData, btIndex)
|
|
301
334
|
|
|
302
|
-
let aNameIx = cnt + 4 + parseInt(appendMask[15])
|
|
303
|
-
let aMacIx = aNameIx + parseInt(appendMask[14])
|
|
304
|
-
let aStatIx = aMacIx + parseInt(appendMask[13])
|
|
305
|
-
let aBatIx = aStatIx + parseInt(appendMask[12])
|
|
306
|
-
let aTmpIx = aBatIx + parseInt(appendMask[11])
|
|
307
|
-
let aHumIx = aTmpIx + parseInt(appendMask[10])
|
|
308
|
-
let ioIx = aHumIx + parseInt(appendMask[8])
|
|
309
|
-
let modeIx =
|
|
310
|
-
appendMask[8] === '1' ? ioIx + 2 + parseInt(appendMask[7]) : ioIx
|
|
311
|
-
let aEvIx = appendMask[7] === '1' ? modeIx + 1 : modeIx
|
|
312
|
-
let pressIx = aEvIx + parseInt(appendMask[6])
|
|
313
|
-
let timeIx = pressIx + parseInt(appendMask[5])
|
|
314
|
-
let eTmpIx = timeIx + parseInt(appendMask[4])
|
|
315
|
-
let magIx = eTmpIx + parseInt(appendMask[3])
|
|
316
|
-
let aBatpIx =
|
|
317
|
-
appendMask[3] === '1' ? magIx + 2 + parseInt(appendMask[2]) : eTmpIx
|
|
318
|
-
let relIx = aBatpIx + parseInt(appendMask[1])
|
|
319
|
-
|
|
320
|
-
btDevices.push({
|
|
321
|
-
index: parsedData[cnt],
|
|
322
|
-
type: utils.bluetoothAccessories[parsedData[cnt + 1]],
|
|
323
|
-
model:
|
|
324
|
-
parsedData[cnt + 2] !== ''
|
|
325
|
-
? utils.bluetoothModels[parsedData[cnt + 1]][parsedData[cnt + 2]]
|
|
326
|
-
: utils.bluetoothAccessories[parsedData[cnt + 1]],
|
|
327
|
-
appendMask: parsedData[cnt + 4],
|
|
328
|
-
rawData:
|
|
329
|
-
parsedData[cnt + 3] !== ''
|
|
330
|
-
? {
|
|
331
|
-
raw: parsedData[cnt + 3],
|
|
332
|
-
fuelLevel:
|
|
333
|
-
`${parsedData[cnt + 1]}${parsedData[cnt + 2]}` === '10'
|
|
334
|
-
? parsedData[cnt + 3]
|
|
335
|
-
: null,
|
|
336
|
-
temperature:
|
|
337
|
-
`${parsedData[cnt + 1]}${parsedData[cnt + 2]}` === '20'
|
|
338
|
-
? utils.getBtTempHumData(
|
|
339
|
-
parsedData[cnt + 3].substring(4, 8)
|
|
340
|
-
)
|
|
341
|
-
: `${parsedData[cnt + 1]}${parsedData[cnt + 2]}` === '21'
|
|
342
|
-
? parsedData[cnt + 3] // Conversion not specified in documentation
|
|
343
|
-
: `${parsedData[cnt + 1]}${parsedData[cnt + 2]}` ===
|
|
344
|
-
'62'
|
|
345
|
-
? utils.getBtTempHumData(
|
|
346
|
-
parsedData[cnt + 3].substring(0, 4)
|
|
347
|
-
)
|
|
348
|
-
: ['64', '65'].includes(
|
|
349
|
-
`${parsedData[cnt + 1]}${parsedData[cnt + 2]}`
|
|
350
|
-
)
|
|
351
|
-
? parseInt(
|
|
352
|
-
parsedData[cnt + 3].substring(4, 8),
|
|
353
|
-
16
|
|
354
|
-
) / 100
|
|
355
|
-
: null,
|
|
356
|
-
humidity:
|
|
357
|
-
`${parsedData[cnt + 1]}${parsedData[cnt + 2]}` === '20'
|
|
358
|
-
? utils.getBtTempHumData(
|
|
359
|
-
parsedData[cnt + 3].substring(4, 8)
|
|
360
|
-
)
|
|
361
|
-
: `${parsedData[cnt + 1]}${parsedData[cnt + 2]}` === '62'
|
|
362
|
-
? utils.getBtTempHumData(
|
|
363
|
-
parsedData[cnt + 3].substring(4, 8)
|
|
364
|
-
)
|
|
365
|
-
: ['64', '65'].includes(
|
|
366
|
-
`${parsedData[cnt + 1]}${parsedData[cnt + 2]}`
|
|
367
|
-
)
|
|
368
|
-
? parseInt(parsedData[cnt + 3].substring(0, 4), 16) /
|
|
369
|
-
100
|
|
370
|
-
: null
|
|
371
|
-
}
|
|
372
|
-
: null,
|
|
373
|
-
name:
|
|
374
|
-
parsedData[aNameIx] !== '' && appendMask[15] === '1'
|
|
375
|
-
? parsedData[aNameIx]
|
|
376
|
-
: null,
|
|
377
|
-
mac:
|
|
378
|
-
parsedData[aMacIx] !== '' && appendMask[14] === '1'
|
|
379
|
-
? parsedData[aMacIx]
|
|
380
|
-
: null,
|
|
381
|
-
status:
|
|
382
|
-
parsedData[aStatIx] !== '' && appendMask[13] === '1'
|
|
383
|
-
? parseInt(parsedData[aStatIx])
|
|
384
|
-
: null,
|
|
385
|
-
batteryLevel:
|
|
386
|
-
parsedData[aBatIx] !== '' && appendMask[12] === '1'
|
|
387
|
-
? parseInt(parsedData[aBatIx])
|
|
388
|
-
: null,
|
|
389
|
-
batteryPercentage:
|
|
390
|
-
parsedData[aBatpIx] !== '' && appendMask[2] === '1'
|
|
391
|
-
? parseFloat(parsedData[aBatpIx])
|
|
392
|
-
: null,
|
|
393
|
-
accessoryData: {
|
|
394
|
-
rawData: parsedData[cnt + 3] !== '' ? parsedData[cnt + 3] : null,
|
|
395
|
-
temperature:
|
|
396
|
-
parsedData[aTmpIx] !== '' && appendMask[11] === '1'
|
|
397
|
-
? parseInt(parsedData[aTmpIx])
|
|
398
|
-
: null,
|
|
399
|
-
humidity:
|
|
400
|
-
parsedData[aHumIx] !== '' && appendMask[10] === '1'
|
|
401
|
-
? parseInt(parsedData[aHumIx])
|
|
402
|
-
: null,
|
|
403
|
-
outputStatus:
|
|
404
|
-
parsedData[ioIx] !== '' && appendMask[8] === '1'
|
|
405
|
-
? parsedData[ioIx]
|
|
406
|
-
: null,
|
|
407
|
-
inputStatus:
|
|
408
|
-
parsedData[ioIx + 1] !== '' && appendMask[8] === '1'
|
|
409
|
-
? parsedData[ioIx + 1]
|
|
410
|
-
: null,
|
|
411
|
-
analogInputStatus:
|
|
412
|
-
parsedData[ioIx + 2] !== '' && appendMask[8] === '1'
|
|
413
|
-
? parsedData[ioIx + 2]
|
|
414
|
-
: null,
|
|
415
|
-
mode:
|
|
416
|
-
parsedData[modeIx] !== '' && appendMask[7] === '1'
|
|
417
|
-
? parseInt(parsedData[modeIx])
|
|
418
|
-
: null,
|
|
419
|
-
event:
|
|
420
|
-
parsedData[aEvIx] !== '' && appendMask[7] === '1'
|
|
421
|
-
? parseInt(parsedData[aEvIx])
|
|
422
|
-
: null,
|
|
423
|
-
tirePresure:
|
|
424
|
-
parsedData[pressIx] !== '' && appendMask[6] === '1'
|
|
425
|
-
? parseInt(parsedData[pressIx])
|
|
426
|
-
: null,
|
|
427
|
-
timestamp:
|
|
428
|
-
parsedData[timeIx] !== '' && appendMask[5] === '1'
|
|
429
|
-
? utils.parseDate(parsedData[timeIx])
|
|
430
|
-
: null,
|
|
431
|
-
enhancedTemperature:
|
|
432
|
-
parsedData[eTmpIx] !== '' && appendMask[4] === '1'
|
|
433
|
-
? parseFloat(parsedData[eTmpIx])
|
|
434
|
-
: null,
|
|
435
|
-
magDevice: {
|
|
436
|
-
id:
|
|
437
|
-
parsedData[magIx] !== '' && appendMask[3] === '1'
|
|
438
|
-
? parsedData[magIx]
|
|
439
|
-
: null,
|
|
440
|
-
eventCounter:
|
|
441
|
-
parsedData[magIx + 1] !== '' && appendMask[3] === '1'
|
|
442
|
-
? parseInt(parsedData[magIx + 1])
|
|
443
|
-
: null,
|
|
444
|
-
magnetState:
|
|
445
|
-
parsedData[magIx + 2] !== '' && appendMask[3] === '1'
|
|
446
|
-
? parseInt(parsedData[magIx + 2])
|
|
447
|
-
: null
|
|
448
|
-
},
|
|
449
|
-
relay: {
|
|
450
|
-
state:
|
|
451
|
-
parsedData[relIx] !== '' && appendMask[1] === '1'
|
|
452
|
-
? parseInt(parsedData[relIx])
|
|
453
|
-
: null
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
})
|
|
457
|
-
cnt = appendMask[1] === '1' ? relIx + 1 : relIx + 2
|
|
458
|
-
cnt = parsedData[cnt + 3] !== '' ? cnt - 1 : cnt
|
|
459
|
-
}
|
|
460
335
|
externalData = Object.assign(externalData, {
|
|
461
336
|
btDevices: btDevices
|
|
462
337
|
})
|
|
@@ -470,7 +345,7 @@ const parse = raw => {
|
|
|
470
345
|
if (number > 1) {
|
|
471
346
|
let moreData = []
|
|
472
347
|
for (let i = 1; i < number; i++) {
|
|
473
|
-
let gnssIx = 8 + (12 +
|
|
348
|
+
let gnssIx = 8 + (12 + gnnsTriggerType + satelliteInfo + accuracyInfo) * i
|
|
474
349
|
moreData.push({
|
|
475
350
|
index: i,
|
|
476
351
|
loc: {
|
|
@@ -519,15 +394,27 @@ const parse = raw => {
|
|
|
519
394
|
? parseInt(parsedData[gnssIx + 10], 16)
|
|
520
395
|
: null,
|
|
521
396
|
satellites:
|
|
522
|
-
satelliteInfo && parsedData[gnssIx
|
|
523
|
-
? parseInt(parsedData[gnssIx
|
|
397
|
+
satelliteInfo && parsedData[gnssIx - (satelliteInfo + gnnsTriggerType + accuracyInfo)] !== ''
|
|
398
|
+
? parseInt(parsedData[gnssIx - (satelliteInfo + gnnsTriggerType + accuracyInfo)], 10)
|
|
524
399
|
: null,
|
|
525
400
|
gnssTrigger:
|
|
526
|
-
|
|
527
|
-
|
|
401
|
+
gnnsTriggerType &&
|
|
402
|
+
parsedData[gnssIx - (gnnsTriggerType + accuracyInfo)] !== ''
|
|
528
403
|
? utils.gnssTriggerTypes[
|
|
529
|
-
|
|
404
|
+
parsedData[gnssIx - (gnnsTriggerType + accuracyInfo)]
|
|
530
405
|
]
|
|
406
|
+
: null,
|
|
407
|
+
Hdop:
|
|
408
|
+
accuracyInfo && parsedData[gnssIx - (accuracyInfo)] !== ''
|
|
409
|
+
? parseFloat(parsedData[gnssIx - (accuracyInfo)], 10)
|
|
410
|
+
: null,
|
|
411
|
+
Vdop:
|
|
412
|
+
accuracyInfo && parsedData[gnssIx - (accuracyInfo) + 1] !== ''
|
|
413
|
+
? parseFloat(parsedData[gnssIx - (accuracyInfo) + 1], 10)
|
|
414
|
+
: null,
|
|
415
|
+
Ddop:
|
|
416
|
+
accuracyInfo && parsedData[gnssIx - 1] !== ''
|
|
417
|
+
? parseFloat(parsedData[gnssIx - 1], 10)
|
|
531
418
|
: null
|
|
532
419
|
})
|
|
533
420
|
}
|
|
@@ -578,8 +465,8 @@ const parse = raw => {
|
|
|
578
465
|
raw: `${parsedData[21]}${parsedData[22]}`,
|
|
579
466
|
sos: false,
|
|
580
467
|
input: {
|
|
581
|
-
'2': utils.nHexDigit(utils.hex2bin(parsedData[21]), 8)[
|
|
582
|
-
'1': utils.nHexDigit(utils.hex2bin(parsedData[21]), 8)[
|
|
468
|
+
'2': utils.nHexDigit(utils.hex2bin(parsedData[21]), 8)[6] === '1',
|
|
469
|
+
'1': utils.nHexDigit(utils.hex2bin(parsedData[21]), 8)[7] === '1'
|
|
583
470
|
},
|
|
584
471
|
output: {
|
|
585
472
|
'3': utils.nHexDigit(utils.hex2bin(parsedData[22]), 8)[5] === '1',
|
|
@@ -614,17 +501,9 @@ const parse = raw => {
|
|
|
614
501
|
) {
|
|
615
502
|
// Common Alarms
|
|
616
503
|
let number = parsedData[6] !== '' ? parseInt(parsedData[6], 10) : 1
|
|
617
|
-
let
|
|
618
|
-
let
|
|
619
|
-
|
|
620
|
-
let includeStatus =
|
|
621
|
-
parsedData[index] !== '' ? parseInt(parsedData[index]) > 3 : null
|
|
622
|
-
|
|
623
|
-
// If get satellites is configured
|
|
624
|
-
if (utils.includeSatellites(parsedData[index])) {
|
|
625
|
-
index += 1
|
|
626
|
-
satelliteInfo = true
|
|
627
|
-
}
|
|
504
|
+
let satelliteInfo = utils.includeSatellites(parsedData[18])
|
|
505
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[18]) ? 3 : 0
|
|
506
|
+
let index = 6 + (12 + satelliteInfo + accuracyInfo) * number
|
|
628
507
|
|
|
629
508
|
data = Object.assign(data, {
|
|
630
509
|
alarm: utils.getAlarm(command[1], parsedData[5], 'gv58lau'),
|
|
@@ -645,71 +524,36 @@ const parse = raw => {
|
|
|
645
524
|
battery: null,
|
|
646
525
|
inputCharge: null
|
|
647
526
|
},
|
|
648
|
-
mcc: parsedData[14] !== '' ? utils.latamMcc[parseInt(parsedData[14], 10)] : null,
|
|
527
|
+
mcc: parsedData[14] !== '' ? utils.latamMcc[parseInt(parsedData[14], 10)] || utils.latamMcc.default : null,
|
|
649
528
|
mnc: parsedData[15] !== '' ? utils.getMNC(parsedData[14], parsedData[15]) : null,
|
|
650
529
|
lac: parsedData[16] !== '' ? parseInt(parsedData[16], 16) : null,
|
|
651
530
|
cid: parsedData[17] !== '' ? parseInt(parsedData[17], 16) : null,
|
|
652
531
|
satellites:
|
|
653
|
-
satelliteInfo && parsedData[index] !== ''
|
|
654
|
-
? parseInt(parsedData[index])
|
|
532
|
+
satelliteInfo && parsedData[index - (satelliteInfo + accuracyInfo) + 1] !== ''
|
|
533
|
+
? parseInt(parsedData[index - (satelliteInfo + accuracyInfo) + 1], 10)
|
|
655
534
|
: null,
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
utils.hex2bin(parsedData[index + 1].substring(2, 4)),
|
|
664
|
-
8
|
|
665
|
-
)[7] === '1',
|
|
666
|
-
'1':
|
|
667
|
-
utils.nHexDigit(
|
|
668
|
-
utils.hex2bin(parsedData[index + 1].substring(2, 4)),
|
|
669
|
-
8
|
|
670
|
-
)[6] === '1'
|
|
671
|
-
},
|
|
672
|
-
output: {
|
|
673
|
-
'3':
|
|
674
|
-
utils.nHexDigit(
|
|
675
|
-
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
676
|
-
8
|
|
677
|
-
)[5] === '1',
|
|
678
|
-
'2':
|
|
679
|
-
utils.nHexDigit(
|
|
680
|
-
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
681
|
-
8
|
|
682
|
-
)[6] === '1',
|
|
683
|
-
'1':
|
|
684
|
-
utils.nHexDigit(
|
|
685
|
-
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
686
|
-
8
|
|
687
|
-
)[7] === '1'
|
|
688
|
-
},
|
|
689
|
-
charge: null,
|
|
690
|
-
state: utils.states[parsedData[index + 1].substring(0, 2)]
|
|
691
|
-
}
|
|
692
|
-
: null,
|
|
693
|
-
odometer: includeStatus
|
|
694
|
-
? parsedData[index + 2] !== ''
|
|
695
|
-
? parseFloat(parsedData[index + 2])
|
|
696
|
-
: null
|
|
697
|
-
: parsedData[index + 1] !== ''
|
|
698
|
-
? parseFloat(parsedData[index + 1])
|
|
535
|
+
Hdop:
|
|
536
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
537
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1])
|
|
538
|
+
: null,
|
|
539
|
+
Vdop:
|
|
540
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
541
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2])
|
|
699
542
|
: null,
|
|
543
|
+
Ddop:
|
|
544
|
+
accuracyInfo && parsedData[index] !== ''
|
|
545
|
+
? parseFloat(parsedData[index])
|
|
546
|
+
: null,
|
|
547
|
+
odometer:
|
|
548
|
+
parsedData[index + 1] !== '' ? parseFloat(parsedData[index + 1]) : null,
|
|
700
549
|
hourmeter: null
|
|
701
550
|
})
|
|
702
551
|
} else if (command[1] === 'GTEPS' || command[1] === 'GTAIS') {
|
|
703
552
|
// External low battery and Low voltage for analog input
|
|
704
553
|
let number = parsedData[6] !== '' ? parseInt(parsedData[6], 10) : 1
|
|
705
|
-
let
|
|
706
|
-
let
|
|
707
|
-
|
|
708
|
-
// If get satellites is configured
|
|
709
|
-
if (utils.includeSatellites(parsedData[18])) {
|
|
710
|
-
index += 1
|
|
711
|
-
satelliteInfo = true
|
|
712
|
-
}
|
|
554
|
+
let satelliteInfo = utils.includeSatellites(parsedData[18])
|
|
555
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[18]) ? 3 : 0
|
|
556
|
+
let index = 6 + (12 + satelliteInfo + accuracyInfo) * number
|
|
713
557
|
|
|
714
558
|
data = Object.assign(data, {
|
|
715
559
|
alarm: utils.getAlarm(command[1], parsedData[5]),
|
|
@@ -731,13 +575,25 @@ const parse = raw => {
|
|
|
731
575
|
battery: parsedData[4] !== '' ? parseFloat(parsedData[4]) / 1000 : null,
|
|
732
576
|
inputCharge: null
|
|
733
577
|
},
|
|
734
|
-
mcc: parsedData[14] !== '' ? utils.latamMcc[parseInt(parsedData[14], 10)] : null,
|
|
578
|
+
mcc: parsedData[14] !== '' ? utils.latamMcc[parseInt(parsedData[14], 10)] || utils.latamMcc.default : null,
|
|
735
579
|
mnc: parsedData[15] !== '' ? utils.getMNC(parsedData[14], parsedData[15]) : null,
|
|
736
580
|
lac: parsedData[16] !== '' ? parseInt(parsedData[16], 16) : null,
|
|
737
581
|
cid: parsedData[17] !== '' ? parseInt(parsedData[17], 16) : null,
|
|
738
582
|
satellites:
|
|
739
|
-
satelliteInfo && parsedData[index] !== ''
|
|
740
|
-
? parseInt(parsedData[index])
|
|
583
|
+
satelliteInfo && parsedData[index - (satelliteInfo + accuracyInfo) + 1] !== ''
|
|
584
|
+
? parseInt(parsedData[index - (satelliteInfo + accuracyInfo) + 1], 10)
|
|
585
|
+
: null,
|
|
586
|
+
Hdop:
|
|
587
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
588
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1])
|
|
589
|
+
: null,
|
|
590
|
+
Vdop:
|
|
591
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
592
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2])
|
|
593
|
+
: null,
|
|
594
|
+
Ddop:
|
|
595
|
+
accuracyInfo && parsedData[index] !== ''
|
|
596
|
+
? parseFloat(parsedData[index])
|
|
741
597
|
: null,
|
|
742
598
|
odometer:
|
|
743
599
|
parsedData[index + 1] !== '' ? parseFloat(parsedData[index + 1]) : null,
|
|
@@ -781,16 +637,10 @@ const parse = raw => {
|
|
|
781
637
|
command[1] === 'GTMPF' ||
|
|
782
638
|
command[1] === 'GTBTC'
|
|
783
639
|
) {
|
|
784
|
-
|
|
785
|
-
let
|
|
786
|
-
let
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
// If get satellites is configured
|
|
790
|
-
if (utils.includeSatellites(parsedData[index])) {
|
|
791
|
-
index += 1
|
|
792
|
-
satelliteInfo = true
|
|
793
|
-
}
|
|
640
|
+
let satelliteInfo = utils.includeSatellites(parsedData[15])
|
|
641
|
+
let includeStatus = utils.includeStatus(parsedData[15])
|
|
642
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[15]) ? 3 : 0
|
|
643
|
+
let index = 15 + (satelliteInfo + includeStatus + accuracyInfo)
|
|
794
644
|
|
|
795
645
|
data = Object.assign(data, {
|
|
796
646
|
alarm: utils.getAlarm(command[1], null),
|
|
@@ -811,51 +661,63 @@ const parse = raw => {
|
|
|
811
661
|
battery: null,
|
|
812
662
|
inputCharge: null
|
|
813
663
|
},
|
|
814
|
-
mcc: parsedData[11] !== '' ? utils.latamMcc[parseInt(parsedData[11], 10)] : null,
|
|
664
|
+
mcc: parsedData[11] !== '' ? utils.latamMcc[parseInt(parsedData[11], 10)] || utils.latamMcc.default : null,
|
|
815
665
|
mnc: parsedData[12] !== '' ? utils.getMNC(parsedData[11], parsedData[12]) : null,
|
|
816
666
|
lac: parsedData[13] !== '' ? parseInt(parsedData[13], 16) : null,
|
|
817
667
|
cid: parsedData[14] !== '' ? parseInt(parsedData[14], 16) : null,
|
|
818
668
|
satellites:
|
|
819
|
-
satelliteInfo && parsedData[index] !== ''
|
|
820
|
-
? parseInt(parsedData[index])
|
|
669
|
+
satelliteInfo && parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1] !== ''
|
|
670
|
+
? parseInt(parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1], 10)
|
|
821
671
|
: null,
|
|
822
|
-
status: includeStatus
|
|
672
|
+
status: includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
|
|
823
673
|
? {
|
|
824
|
-
raw: parsedData[index + 1],
|
|
674
|
+
raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
|
|
825
675
|
sos: false,
|
|
826
676
|
input: {
|
|
827
677
|
'2':
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
678
|
+
utils.nHexDigit(
|
|
679
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
680
|
+
8
|
|
681
|
+
)[6] === '1',
|
|
832
682
|
'1':
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
683
|
+
utils.nHexDigit(
|
|
684
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
685
|
+
8
|
|
686
|
+
)[7] === '1'
|
|
837
687
|
},
|
|
838
688
|
output: {
|
|
839
689
|
'3':
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
690
|
+
utils.nHexDigit(
|
|
691
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
692
|
+
8
|
|
693
|
+
)[5] === '1',
|
|
844
694
|
'2':
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
695
|
+
utils.nHexDigit(
|
|
696
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
697
|
+
8
|
|
698
|
+
)[6] === '1',
|
|
849
699
|
'1':
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
700
|
+
utils.nHexDigit(
|
|
701
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
702
|
+
8
|
|
703
|
+
)[7] === '1'
|
|
854
704
|
},
|
|
855
705
|
charge: null,
|
|
856
|
-
state: utils.states[parsedData[index + 1].substring(0, 2)]
|
|
706
|
+
state: utils.states[parsedData[index - (includeStatus + accuracyInfo) + 1].substring(0, 2)]
|
|
857
707
|
}
|
|
858
708
|
: null,
|
|
709
|
+
Hdop:
|
|
710
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
711
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1])
|
|
712
|
+
: null,
|
|
713
|
+
Vdop:
|
|
714
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
715
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2])
|
|
716
|
+
: null,
|
|
717
|
+
Ddop:
|
|
718
|
+
accuracyInfo && parsedData[index] !== ''
|
|
719
|
+
? parseFloat(parsedData[index])
|
|
720
|
+
: null,
|
|
859
721
|
odometer: null,
|
|
860
722
|
hourmeter: null
|
|
861
723
|
})
|
|
@@ -867,16 +729,10 @@ const parse = raw => {
|
|
|
867
729
|
command[1] === 'GTBPL' ||
|
|
868
730
|
command[1] === 'GTSTT'
|
|
869
731
|
) {
|
|
870
|
-
let
|
|
871
|
-
let
|
|
872
|
-
let
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
// If get satellites is configured
|
|
876
|
-
if (utils.includeSatellites(parsedData[index])) {
|
|
877
|
-
index += 1
|
|
878
|
-
satelliteInfo = true
|
|
879
|
-
}
|
|
732
|
+
let satelliteInfo = utils.includeSatellites(parsedData[16])
|
|
733
|
+
let includeStatus = utils.includeStatus(parsedData[16])
|
|
734
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[16]) ? 3 : 0
|
|
735
|
+
let index = 16 + (satelliteInfo + includeStatus + accuracyInfo)
|
|
880
736
|
|
|
881
737
|
data = Object.assign(data, {
|
|
882
738
|
alarm: utils.getAlarm(command[1], parsedData[4]),
|
|
@@ -902,46 +758,58 @@ const parse = raw => {
|
|
|
902
758
|
lac: parsedData[14] !== '' ? parseInt(parsedData[14], 16) : null,
|
|
903
759
|
cid: parsedData[15] !== '' ? parseInt(parsedData[15], 16) : null,
|
|
904
760
|
satellites:
|
|
905
|
-
satelliteInfo && parsedData[index] !== ''
|
|
906
|
-
? parseInt(parsedData[index])
|
|
761
|
+
satelliteInfo && parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1] !== ''
|
|
762
|
+
? parseInt(parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1], 10)
|
|
907
763
|
: null,
|
|
908
|
-
status: includeStatus
|
|
764
|
+
status: includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
|
|
909
765
|
? {
|
|
910
|
-
raw: parsedData[index + 1],
|
|
766
|
+
raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
|
|
911
767
|
sos: false,
|
|
912
768
|
input: {
|
|
913
769
|
'2':
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
770
|
+
utils.nHexDigit(
|
|
771
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
772
|
+
8
|
|
773
|
+
)[6] === '1',
|
|
918
774
|
'1':
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
775
|
+
utils.nHexDigit(
|
|
776
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
777
|
+
8
|
|
778
|
+
)[7] === '1'
|
|
923
779
|
},
|
|
924
780
|
output: {
|
|
925
781
|
'3':
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
782
|
+
utils.nHexDigit(
|
|
783
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
784
|
+
8
|
|
785
|
+
)[5] === '1',
|
|
930
786
|
'2':
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
787
|
+
utils.nHexDigit(
|
|
788
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
789
|
+
8
|
|
790
|
+
)[6] === '1',
|
|
935
791
|
'1':
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
792
|
+
utils.nHexDigit(
|
|
793
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
794
|
+
8
|
|
795
|
+
)[7] === '1'
|
|
940
796
|
},
|
|
941
797
|
charge: null,
|
|
942
|
-
state: utils.states[parsedData[index + 1].substring(0, 2)]
|
|
798
|
+
state: utils.states[parsedData[index - (includeStatus + accuracyInfo) + 1].substring(0, 2)]
|
|
943
799
|
}
|
|
944
800
|
: null,
|
|
801
|
+
Hdop:
|
|
802
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
803
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1])
|
|
804
|
+
: null,
|
|
805
|
+
Vdop:
|
|
806
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
807
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2])
|
|
808
|
+
: null,
|
|
809
|
+
Ddop:
|
|
810
|
+
accuracyInfo && parsedData[index] !== ''
|
|
811
|
+
? parseFloat(parsedData[index])
|
|
812
|
+
: null,
|
|
945
813
|
odometer: null,
|
|
946
814
|
hourmeter: null
|
|
947
815
|
})
|
|
@@ -1000,16 +868,10 @@ const parse = raw => {
|
|
|
1000
868
|
gnssData: more
|
|
1001
869
|
})
|
|
1002
870
|
} else if (command[1] === 'GTJDS') {
|
|
1003
|
-
let
|
|
1004
|
-
let
|
|
1005
|
-
let
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
// If get satellites is configured
|
|
1009
|
-
if (utils.includeSatellites(parsedData[17])) {
|
|
1010
|
-
index += 1
|
|
1011
|
-
satelliteInfo = true
|
|
1012
|
-
}
|
|
871
|
+
let satelliteInfo = utils.includeSatellites(parsedData[17])
|
|
872
|
+
let includeStatus = utils.includeStatus(parsedData[17])
|
|
873
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[17]) ? 3 : 0
|
|
874
|
+
let index = 17 + (satelliteInfo + includeStatus + accuracyInfo)
|
|
1013
875
|
|
|
1014
876
|
data = Object.assign(data, {
|
|
1015
877
|
alarm: utils.getAlarm(command[1], parsedData[4], parsedData[5]),
|
|
@@ -1030,65 +892,71 @@ const parse = raw => {
|
|
|
1030
892
|
battery: null,
|
|
1031
893
|
inputCharge: null
|
|
1032
894
|
},
|
|
1033
|
-
mcc: parsedData[13] !== '' ? utils.latamMcc[parseInt(parsedData[13], 10)] : null,
|
|
895
|
+
mcc: parsedData[13] !== '' ? utils.latamMcc[parseInt(parsedData[13], 10)] || utils.latamMcc.default : null,
|
|
1034
896
|
mnc: parsedData[14] !== '' ? utils.getMNC(parsedData[13], parsedData[14]) : null,
|
|
1035
897
|
lac: parsedData[15] !== '' ? parseInt(parsedData[15], 16) : null,
|
|
1036
898
|
cid: parsedData[16] !== '' ? parseInt(parsedData[16], 16) : null,
|
|
1037
899
|
satellites:
|
|
1038
|
-
satelliteInfo && parsedData[index] !== ''
|
|
1039
|
-
? parseInt(parsedData[index], 10)
|
|
900
|
+
satelliteInfo && parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1] !== ''
|
|
901
|
+
? parseInt(parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1], 10)
|
|
1040
902
|
: null,
|
|
1041
|
-
status: includeStatus
|
|
903
|
+
status: includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
|
|
1042
904
|
? {
|
|
1043
|
-
raw: parsedData[index + 1],
|
|
905
|
+
raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
|
|
1044
906
|
sos: false,
|
|
1045
907
|
input: {
|
|
1046
908
|
'2':
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
909
|
+
utils.nHexDigit(
|
|
910
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
911
|
+
8
|
|
912
|
+
)[6] === '1',
|
|
1051
913
|
'1':
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
914
|
+
utils.nHexDigit(
|
|
915
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
916
|
+
8
|
|
917
|
+
)[7] === '1'
|
|
1056
918
|
},
|
|
1057
919
|
output: {
|
|
1058
920
|
'3':
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
921
|
+
utils.nHexDigit(
|
|
922
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
923
|
+
8
|
|
924
|
+
)[5] === '1',
|
|
1063
925
|
'2':
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
926
|
+
utils.nHexDigit(
|
|
927
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
928
|
+
8
|
|
929
|
+
)[6] === '1',
|
|
1068
930
|
'1':
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
931
|
+
utils.nHexDigit(
|
|
932
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
933
|
+
8
|
|
934
|
+
)[7] === '1'
|
|
1073
935
|
},
|
|
1074
936
|
charge: null,
|
|
1075
|
-
state: utils.states[parsedData[index + 1].substring(0, 2)]
|
|
937
|
+
state: utils.states[parsedData[index - (includeStatus + accuracyInfo) + 1].substring(0, 2)]
|
|
1076
938
|
}
|
|
1077
939
|
: null,
|
|
940
|
+
Hdop:
|
|
941
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
942
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1])
|
|
943
|
+
: null,
|
|
944
|
+
Vdop:
|
|
945
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
946
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2])
|
|
947
|
+
: null,
|
|
948
|
+
Ddop:
|
|
949
|
+
accuracyInfo && parsedData[index] !== ''
|
|
950
|
+
? parseFloat(parsedData[index])
|
|
951
|
+
: null,
|
|
1078
952
|
odometer: null,
|
|
1079
953
|
hourmeter: null
|
|
1080
954
|
})
|
|
1081
955
|
} else if (command[1] === 'GTIGN' || command[1] === 'GTIGF') {
|
|
1082
|
-
let
|
|
1083
|
-
let
|
|
1084
|
-
let
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
// If get satellites is configured
|
|
1088
|
-
if (utils.includeSatellites(parsedData[index])) {
|
|
1089
|
-
index += 1
|
|
1090
|
-
satelliteInfo = true
|
|
1091
|
-
}
|
|
956
|
+
let satelliteInfo = utils.includeSatellites(parsedData[16])
|
|
957
|
+
let includeStatus = utils.includeStatus(parsedData[16])
|
|
958
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[16]) ? 3 : 0
|
|
959
|
+
let index = 16 + (satelliteInfo + includeStatus + accuracyInfo)
|
|
1092
960
|
|
|
1093
961
|
data = Object.assign(data, {
|
|
1094
962
|
alarm: utils.getAlarm(command[1], parsedData[4]),
|
|
@@ -1109,77 +977,80 @@ const parse = raw => {
|
|
|
1109
977
|
battery: null,
|
|
1110
978
|
inputCharge: null
|
|
1111
979
|
},
|
|
1112
|
-
mcc: parsedData[12] !== '' ? utils.latamMcc[parseInt(parsedData[12], 10)] : null,
|
|
980
|
+
mcc: parsedData[12] !== '' ? utils.latamMcc[parseInt(parsedData[12], 10)] || utils.latamMcc.default : null,
|
|
1113
981
|
mnc: parsedData[13] !== '' ? utils.getMNC(parsedData[12], parsedData[13]) : null,
|
|
1114
982
|
lac: parsedData[14] !== '' ? parseInt(parsedData[14], 16) : null,
|
|
1115
983
|
cid: parsedData[15] !== '' ? parseInt(parsedData[15], 16) : null,
|
|
1116
984
|
satellites:
|
|
1117
|
-
satelliteInfo && parsedData[index] !== ''
|
|
1118
|
-
? parseInt(parsedData[index], 10)
|
|
985
|
+
satelliteInfo && parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1] !== ''
|
|
986
|
+
? parseInt(parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1], 10)
|
|
1119
987
|
: null,
|
|
1120
|
-
status: includeStatus
|
|
988
|
+
status: includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
|
|
1121
989
|
? {
|
|
1122
|
-
raw: parsedData[index + 1],
|
|
990
|
+
raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
|
|
1123
991
|
sos: false,
|
|
1124
992
|
input: {
|
|
1125
993
|
'2':
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
994
|
+
utils.nHexDigit(
|
|
995
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
996
|
+
8
|
|
997
|
+
)[6] === '1',
|
|
1130
998
|
'1':
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
999
|
+
utils.nHexDigit(
|
|
1000
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
1001
|
+
8
|
|
1002
|
+
)[7] === '1'
|
|
1135
1003
|
},
|
|
1136
1004
|
output: {
|
|
1137
1005
|
'3':
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1006
|
+
utils.nHexDigit(
|
|
1007
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1008
|
+
8
|
|
1009
|
+
)[5] === '1',
|
|
1142
1010
|
'2':
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1011
|
+
utils.nHexDigit(
|
|
1012
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1013
|
+
8
|
|
1014
|
+
)[6] === '1',
|
|
1147
1015
|
'1':
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1016
|
+
utils.nHexDigit(
|
|
1017
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1018
|
+
8
|
|
1019
|
+
)[7] === '1'
|
|
1152
1020
|
},
|
|
1153
1021
|
charge: null,
|
|
1154
|
-
state: utils.states[parsedData[index + 1].substring(0, 2)]
|
|
1022
|
+
state: utils.states[parsedData[index - (includeStatus + accuracyInfo) + 1].substring(0, 2)]
|
|
1155
1023
|
}
|
|
1156
1024
|
: null,
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
? parseFloat(parsedData[index +
|
|
1160
|
-
: null
|
|
1161
|
-
: parsedData[index + 2] !== ''
|
|
1162
|
-
? parseFloat(parsedData[index + 2])
|
|
1025
|
+
Hdop:
|
|
1026
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
1027
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1])
|
|
1163
1028
|
: null,
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
?
|
|
1167
|
-
: null
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1029
|
+
Vdop:
|
|
1030
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
1031
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2])
|
|
1032
|
+
: null,
|
|
1033
|
+
Ddop:
|
|
1034
|
+
accuracyInfo && parsedData[index] !== ''
|
|
1035
|
+
? parseFloat(parsedData[index])
|
|
1036
|
+
: null,
|
|
1037
|
+
hourmeter: parsedData[index + 1] !== ''
|
|
1038
|
+
? parseFloat(parsedData[index + 1])
|
|
1039
|
+
: null,
|
|
1040
|
+
odometer: parsedData[index + 2] !== ''
|
|
1041
|
+
? parseFloat(parsedData[index + 2])
|
|
1042
|
+
: null
|
|
1171
1043
|
})
|
|
1172
|
-
} else if (
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
}
|
|
1044
|
+
} else if (
|
|
1045
|
+
command[1] === 'GTIDN' ||
|
|
1046
|
+
command[1] === 'GTIDF' ||
|
|
1047
|
+
command[1] === 'GTSTR' ||
|
|
1048
|
+
command[1] === 'GTSTP' ||
|
|
1049
|
+
command[1] === 'GTLSP') {
|
|
1050
|
+
let satelliteInfo = utils.includeSatellites(parsedData[17])
|
|
1051
|
+
let includeStatus = utils.includeStatus(parsedData[17])
|
|
1052
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[17]) ? 3 : 0
|
|
1053
|
+
let index = 17 + (satelliteInfo + includeStatus + accuracyInfo)
|
|
1183
1054
|
|
|
1184
1055
|
data = Object.assign(data, {
|
|
1185
1056
|
alarm: utils.getAlarm(command[1], parsedData[5]),
|
|
@@ -1200,161 +1071,73 @@ const parse = raw => {
|
|
|
1200
1071
|
battery: null,
|
|
1201
1072
|
inputCharge: null
|
|
1202
1073
|
},
|
|
1203
|
-
mcc: parsedData[13] !== '' ? utils.latamMcc[parseInt(parsedData[13], 10)] : null,
|
|
1074
|
+
mcc: parsedData[13] !== '' ? utils.latamMcc[parseInt(parsedData[13], 10)] || utils.latamMcc.default : null,
|
|
1204
1075
|
mnc: parsedData[14] !== '' ? utils.getMNC(parsedData[13], parsedData[14]) : null,
|
|
1205
1076
|
lac: parsedData[15] !== '' ? parseInt(parsedData[15], 16) : null,
|
|
1206
1077
|
cid: parsedData[16] !== '' ? parseInt(parsedData[16], 16) : null,
|
|
1207
1078
|
satellites:
|
|
1208
|
-
satelliteInfo && parsedData[index] !== ''
|
|
1209
|
-
? parseInt(parsedData[index], 10)
|
|
1079
|
+
satelliteInfo && parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1] !== ''
|
|
1080
|
+
? parseInt(parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1], 10)
|
|
1210
1081
|
: null,
|
|
1211
|
-
status: includeStatus
|
|
1082
|
+
status: includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
|
|
1212
1083
|
? {
|
|
1213
|
-
raw: parsedData[index + 1],
|
|
1084
|
+
raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
|
|
1214
1085
|
sos: false,
|
|
1215
1086
|
input: {
|
|
1216
1087
|
'2':
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1088
|
+
utils.nHexDigit(
|
|
1089
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
1090
|
+
8
|
|
1091
|
+
)[6] === '1',
|
|
1221
1092
|
'1':
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1093
|
+
utils.nHexDigit(
|
|
1094
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
1095
|
+
8
|
|
1096
|
+
)[7] === '1'
|
|
1226
1097
|
},
|
|
1227
1098
|
output: {
|
|
1228
1099
|
'3':
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1100
|
+
utils.nHexDigit(
|
|
1101
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1102
|
+
8
|
|
1103
|
+
)[5] === '1',
|
|
1233
1104
|
'2':
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1105
|
+
utils.nHexDigit(
|
|
1106
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1107
|
+
8
|
|
1108
|
+
)[6] === '1',
|
|
1238
1109
|
'1':
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1110
|
+
utils.nHexDigit(
|
|
1111
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1112
|
+
8
|
|
1113
|
+
)[7] === '1'
|
|
1243
1114
|
},
|
|
1244
1115
|
charge: null,
|
|
1245
|
-
state: utils.states[parsedData[index + 1].substring(0, 2)]
|
|
1116
|
+
state: utils.states[parsedData[index - (includeStatus + accuracyInfo) + 1].substring(0, 2)]
|
|
1246
1117
|
}
|
|
1247
1118
|
: null,
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
? parseFloat(parsedData[index +
|
|
1251
|
-
: null
|
|
1252
|
-
: parsedData[index + 1] !== ''
|
|
1253
|
-
? parseFloat(parsedData[index + 1])
|
|
1119
|
+
Hdop:
|
|
1120
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
1121
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1])
|
|
1254
1122
|
: null,
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
command[1] === 'GTSTR' ||
|
|
1259
|
-
command[1] === 'GTSTP' ||
|
|
1260
|
-
command[1] === 'GTLSP'
|
|
1261
|
-
) {
|
|
1262
|
-
let index = 17 // position append mask
|
|
1263
|
-
let satelliteInfo = false
|
|
1264
|
-
let includeStatus =
|
|
1265
|
-
parsedData[index] !== '' ? parseInt(parsedData[index]) > 3 : null
|
|
1266
|
-
|
|
1267
|
-
// If get satellites is configured
|
|
1268
|
-
if (utils.includeSatellites(parsedData[index])) {
|
|
1269
|
-
index += 1
|
|
1270
|
-
satelliteInfo = true
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
data = Object.assign(data, {
|
|
1274
|
-
alarm: utils.getAlarm(command[1], null),
|
|
1275
|
-
loc: {
|
|
1276
|
-
type: 'Point',
|
|
1277
|
-
coordinates: [parseFloat(parsedData[10]), parseFloat(parsedData[11])]
|
|
1278
|
-
},
|
|
1279
|
-
speed: parsedData[7] !== '' ? parseFloat(parsedData[7]) : null,
|
|
1280
|
-
gpsStatus: utils.checkGps(
|
|
1281
|
-
parseFloat(parsedData[10]),
|
|
1282
|
-
parseFloat(parsedData[11])
|
|
1283
|
-
),
|
|
1284
|
-
hdop: parsedData[6] !== '' ? parseFloat(parsedData[6]) : null,
|
|
1285
|
-
azimuth: parsedData[8] !== '' ? parseFloat(parsedData[8]) : null,
|
|
1286
|
-
altitude: parsedData[9] !== '' ? parseFloat(parsedData[9]) : null,
|
|
1287
|
-
datetime: parsedData[12] !== '' ? utils.parseDate(parsedData[12]) : null,
|
|
1288
|
-
voltage: {
|
|
1289
|
-
battery: null,
|
|
1290
|
-
inputCharge: null
|
|
1291
|
-
},
|
|
1292
|
-
mcc: parsedData[13] !== '' ? utils.latamMcc[parseInt(parsedData[13], 10)] : null,
|
|
1293
|
-
mnc: parsedData[14] !== '' ? utils.getMNC(parsedData[13], parsedData[14]) : null,
|
|
1294
|
-
lac: parsedData[15] !== '' ? parseInt(parsedData[15], 16) : null,
|
|
1295
|
-
cid: parsedData[16] !== '' ? parseInt(parsedData[16], 16) : null,
|
|
1296
|
-
satellites:
|
|
1297
|
-
satelliteInfo && parsedData[index] !== ''
|
|
1298
|
-
? parseInt(parsedData[index], 10)
|
|
1123
|
+
Vdop:
|
|
1124
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
1125
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2])
|
|
1299
1126
|
: null,
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
sos: false,
|
|
1304
|
-
input: {
|
|
1305
|
-
'2':
|
|
1306
|
-
utils.nHexDigit(
|
|
1307
|
-
utils.hex2bin(parsedData[index + 1].substring(2, 4)),
|
|
1308
|
-
8
|
|
1309
|
-
)[7] === '1',
|
|
1310
|
-
'1':
|
|
1311
|
-
utils.nHexDigit(
|
|
1312
|
-
utils.hex2bin(parsedData[index + 1].substring(2, 4)),
|
|
1313
|
-
8
|
|
1314
|
-
)[6] === '1'
|
|
1315
|
-
},
|
|
1316
|
-
output: {
|
|
1317
|
-
'3':
|
|
1318
|
-
utils.nHexDigit(
|
|
1319
|
-
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
1320
|
-
8
|
|
1321
|
-
)[5] === '1',
|
|
1322
|
-
'2':
|
|
1323
|
-
utils.nHexDigit(
|
|
1324
|
-
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
1325
|
-
8
|
|
1326
|
-
)[6] === '1',
|
|
1327
|
-
'1':
|
|
1328
|
-
utils.nHexDigit(
|
|
1329
|
-
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
1330
|
-
8
|
|
1331
|
-
)[7] === '1'
|
|
1332
|
-
},
|
|
1333
|
-
charge: null,
|
|
1334
|
-
state: utils.states[parsedData[index + 1].substring(0, 2)]
|
|
1335
|
-
}
|
|
1336
|
-
: null,
|
|
1337
|
-
odometer: includeStatus
|
|
1338
|
-
? parsedData[index + 2] !== ''
|
|
1339
|
-
? parseFloat(parsedData[index + 2])
|
|
1340
|
-
: null
|
|
1341
|
-
: parsedData[index + 1] !== ''
|
|
1342
|
-
? parseFloat(parsedData[index + 1])
|
|
1127
|
+
Ddop:
|
|
1128
|
+
accuracyInfo && parsedData[index] !== ''
|
|
1129
|
+
? parseFloat(parsedData[index])
|
|
1343
1130
|
: null,
|
|
1131
|
+
odometer: parsedData[index + 1] !== ''
|
|
1132
|
+
? parseFloat(parsedData[index + 1])
|
|
1133
|
+
: null,
|
|
1344
1134
|
hourmeter: null
|
|
1345
1135
|
})
|
|
1346
1136
|
} else if (command[1] === 'GTGSS') {
|
|
1347
|
-
|
|
1348
|
-
let
|
|
1349
|
-
let
|
|
1350
|
-
let includeStatus
|
|
1351
|
-
parsedData[index] !== '' ? parseInt(parsedData[index]) > 3 : null
|
|
1352
|
-
|
|
1353
|
-
// If get satellites is configured
|
|
1354
|
-
if (utils.includeSatellites(parsedData[index])) {
|
|
1355
|
-
index += 1
|
|
1356
|
-
satelliteInfo = true
|
|
1357
|
-
}
|
|
1137
|
+
let satelliteInfo = utils.includeSatellites(parsedData[19])
|
|
1138
|
+
let includeStatus = utils.includeStatus(parsedData[19])
|
|
1139
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[19]) ? 3 : 0
|
|
1140
|
+
let index = 19 + (satelliteInfo + includeStatus + accuracyInfo)
|
|
1358
1141
|
|
|
1359
1142
|
data = Object.assign(data, {
|
|
1360
1143
|
alarm: utils.getAlarm(command[1], parsedData[4]),
|
|
@@ -1375,66 +1158,72 @@ const parse = raw => {
|
|
|
1375
1158
|
battery: null,
|
|
1376
1159
|
inputCharge: null
|
|
1377
1160
|
},
|
|
1378
|
-
mcc: parsedData[15] !== '' ? utils.latamMcc[parseInt(parsedData[15], 10)] : null,
|
|
1161
|
+
mcc: parsedData[15] !== '' ? utils.latamMcc[parseInt(parsedData[15], 10)] || utils.latamMcc.default : null,
|
|
1379
1162
|
mnc: parsedData[16] !== '' ? utils.getMNC(parsedData[15], parsedData[16]) : null,
|
|
1380
1163
|
lac: parsedData[17] !== '' ? parseInt(parsedData[17], 16) : null,
|
|
1381
1164
|
cid: parsedData[18] !== '' ? parseInt(parsedData[18], 16) : null,
|
|
1382
1165
|
usedSatellites: parsedData[5] !== '' ? parseInt(parsedData[5], 16) : null,
|
|
1383
1166
|
satellites:
|
|
1384
|
-
satelliteInfo && parsedData[index] !== ''
|
|
1385
|
-
? parseInt(parsedData[index], 10)
|
|
1167
|
+
satelliteInfo && parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1] !== ''
|
|
1168
|
+
? parseInt(parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1], 10)
|
|
1386
1169
|
: null,
|
|
1387
|
-
status: includeStatus
|
|
1170
|
+
status: includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
|
|
1388
1171
|
? {
|
|
1389
|
-
raw: parsedData[index + 1],
|
|
1172
|
+
raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
|
|
1390
1173
|
sos: false,
|
|
1391
1174
|
input: {
|
|
1392
1175
|
'2':
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1176
|
+
utils.nHexDigit(
|
|
1177
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
1178
|
+
8
|
|
1179
|
+
)[6] === '1',
|
|
1397
1180
|
'1':
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1181
|
+
utils.nHexDigit(
|
|
1182
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
1183
|
+
8
|
|
1184
|
+
)[7] === '1'
|
|
1402
1185
|
},
|
|
1403
1186
|
output: {
|
|
1404
1187
|
'3':
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1188
|
+
utils.nHexDigit(
|
|
1189
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1190
|
+
8
|
|
1191
|
+
)[5] === '1',
|
|
1409
1192
|
'2':
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1193
|
+
utils.nHexDigit(
|
|
1194
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1195
|
+
8
|
|
1196
|
+
)[6] === '1',
|
|
1414
1197
|
'1':
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1198
|
+
utils.nHexDigit(
|
|
1199
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1200
|
+
8
|
|
1201
|
+
)[7] === '1'
|
|
1419
1202
|
},
|
|
1420
1203
|
charge: null,
|
|
1421
|
-
state: utils.states[parsedData[index + 1].substring(0, 2)]
|
|
1204
|
+
state: utils.states[parsedData[index - (includeStatus + accuracyInfo) + 1].substring(0, 2)]
|
|
1422
1205
|
}
|
|
1423
1206
|
: null,
|
|
1207
|
+
Hdop:
|
|
1208
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
1209
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1])
|
|
1210
|
+
: null,
|
|
1211
|
+
Vdop:
|
|
1212
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
1213
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2])
|
|
1214
|
+
: null,
|
|
1215
|
+
Ddop:
|
|
1216
|
+
accuracyInfo && parsedData[index] !== ''
|
|
1217
|
+
? parseFloat(parsedData[index])
|
|
1218
|
+
: null,
|
|
1424
1219
|
odometer: null,
|
|
1425
1220
|
hourmeter: null
|
|
1426
1221
|
})
|
|
1427
1222
|
} else if (command[1] === 'GTIDA') {
|
|
1428
|
-
|
|
1429
|
-
let
|
|
1430
|
-
let
|
|
1431
|
-
let
|
|
1432
|
-
|
|
1433
|
-
// If get satellites is configured
|
|
1434
|
-
if (utils.includeSatellites(parsedData[index])) {
|
|
1435
|
-
index += 1
|
|
1436
|
-
satelliteInfo = true
|
|
1437
|
-
}
|
|
1223
|
+
let number = parsedData[7] !== '' ? parseInt(parsedData[7]) : 1
|
|
1224
|
+
let satelliteInfo = utils.includeSatellites(parsedData[19])
|
|
1225
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[19]) ? 3 : 0
|
|
1226
|
+
let index = 7 + (12 + satelliteInfo + accuracyInfo) * number
|
|
1438
1227
|
|
|
1439
1228
|
data = Object.assign(data, {
|
|
1440
1229
|
alarm: utils.getAlarm(command[1], `${parsedData[5]},${parsedData[6]}`),
|
|
@@ -1456,64 +1245,34 @@ const parse = raw => {
|
|
|
1456
1245
|
battery: null,
|
|
1457
1246
|
inputCharge: null
|
|
1458
1247
|
},
|
|
1459
|
-
mcc: parsedData[15] !== '' ? utils.latamMcc[parseInt(parsedData[15], 10)] : null,
|
|
1248
|
+
mcc: parsedData[15] !== '' ? utils.latamMcc[parseInt(parsedData[15], 10)] || utils.latamMcc.default : null,
|
|
1460
1249
|
mnc: parsedData[16] !== '' ? utils.getMNC(parsedData[15], parsedData[16]) : null,
|
|
1461
1250
|
lac: parsedData[17] !== '' ? parseInt(parsedData[17], 16) : null,
|
|
1462
1251
|
cid: parsedData[18] !== '' ? parseInt(parsedData[18], 16) : null,
|
|
1463
1252
|
satellites:
|
|
1464
|
-
satelliteInfo && parsedData[index] !== ''
|
|
1465
|
-
? parseInt(parsedData[index], 10)
|
|
1253
|
+
satelliteInfo && parsedData[index - (satelliteInfo + accuracyInfo) + 1] !== ''
|
|
1254
|
+
? parseInt(parsedData[index - (satelliteInfo + accuracyInfo) + 1], 10)
|
|
1255
|
+
: null,
|
|
1256
|
+
Hdop:
|
|
1257
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
1258
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1], 10)
|
|
1259
|
+
: null,
|
|
1260
|
+
Vdop:
|
|
1261
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
1262
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2], 10)
|
|
1263
|
+
: null,
|
|
1264
|
+
Ddop:
|
|
1265
|
+
accuracyInfo && parsedData[index] !== ''
|
|
1266
|
+
? parseFloat(parsedData[index], 10)
|
|
1466
1267
|
: null,
|
|
1467
1268
|
odometer:
|
|
1468
1269
|
parsedData[index + 1] !== '' ? parseFloat(parsedData[index + 1]) : null,
|
|
1469
1270
|
hourmeter: null
|
|
1470
1271
|
})
|
|
1471
1272
|
} else if (command[1] === 'GTCAN') {
|
|
1472
|
-
let
|
|
1473
|
-
let
|
|
1474
|
-
|
|
1475
|
-
// If get satellites is configured
|
|
1476
|
-
if (utils.includeSatellites(parsedData[index])) {
|
|
1477
|
-
index += 1
|
|
1478
|
-
satelliteInfo = true
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
let inicatorsBin =
|
|
1482
|
-
parsedData[24] !== ''
|
|
1483
|
-
? utils.nHexDigit(utils.hex2bin(parsedData[24]), 16)
|
|
1484
|
-
: null
|
|
1485
|
-
let lights =
|
|
1486
|
-
parsedData[25] !== ''
|
|
1487
|
-
? utils.nHexDigit(utils.hex2bin(parsedData[25]), 8)
|
|
1488
|
-
: null
|
|
1489
|
-
let doors =
|
|
1490
|
-
parsedData[26] !== ''
|
|
1491
|
-
? utils.nHexDigit(utils.hex2bin(parsedData[26]), 8)
|
|
1492
|
-
: null
|
|
1493
|
-
let canExpansionMask =
|
|
1494
|
-
parsedData[29] !== ''
|
|
1495
|
-
? utils
|
|
1496
|
-
.nHexDigit(utils.hex2bin(parsedData[29]), 32)
|
|
1497
|
-
.split('')
|
|
1498
|
-
.reverse()
|
|
1499
|
-
.join('')
|
|
1500
|
-
: null
|
|
1501
|
-
let expansionBin =
|
|
1502
|
-
parsedData[50] !== ''
|
|
1503
|
-
? utils
|
|
1504
|
-
.nHexDigit(utils.hex2bin(parsedData[50]), 16)
|
|
1505
|
-
.split('')
|
|
1506
|
-
.reverse()
|
|
1507
|
-
.join('')
|
|
1508
|
-
: null
|
|
1509
|
-
let tachographBin =
|
|
1510
|
-
parsedData[23] !== ''
|
|
1511
|
-
? utils
|
|
1512
|
-
.nHexDigit(utils.hex2bin(parsedData[23]), 8)
|
|
1513
|
-
.split('')
|
|
1514
|
-
.reverse()
|
|
1515
|
-
.join('')
|
|
1516
|
-
: null
|
|
1273
|
+
let satelliteInfo = utils.includeSatellites(parsedData[67])
|
|
1274
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[67]) ? 3 : 0
|
|
1275
|
+
let index = 67 + (satelliteInfo + accuracyInfo)
|
|
1517
1276
|
|
|
1518
1277
|
data = Object.assign(data, {
|
|
1519
1278
|
alarm: utils.getAlarm(command[1], parsedData[4]),
|
|
@@ -1535,210 +1294,29 @@ const parse = raw => {
|
|
|
1535
1294
|
battery: null,
|
|
1536
1295
|
inputCharge: null
|
|
1537
1296
|
},
|
|
1538
|
-
mcc: parsedData[63] !== '' ? utils.latamMcc[parseInt(parsedData[63], 10)] : null,
|
|
1297
|
+
mcc: parsedData[63] !== '' ? utils.latamMcc[parseInt(parsedData[63], 10)] || utils.latamMcc.default : null,
|
|
1539
1298
|
mnc: parsedData[64] !== '' ? utils.getMNC(parsedData[63], parsedData[64]) : null,
|
|
1540
1299
|
lac: parsedData[65] !== '' ? parseInt(parsedData[65], 16) : null,
|
|
1541
1300
|
cid: parsedData[66] !== '' ? parseInt(parsedData[66], 16) : null,
|
|
1542
|
-
satellites:
|
|
1543
|
-
satelliteInfo && parsedData[index]
|
|
1544
|
-
? parseInt(parsedData[index], 10)
|
|
1545
|
-
: null,
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
acceleratorPressure:
|
|
1562
|
-
parsedData[17] !== '' ? parseFloat(parsedData[17]) : null, // %
|
|
1563
|
-
engineHours: parsedData[18] !== '' ? parseFloat(parsedData[18]) : null,
|
|
1564
|
-
drivingTime: parsedData[19] !== '' ? parseFloat(parsedData[19]) : null,
|
|
1565
|
-
idleTime: parsedData[20] !== '' ? parseFloat(parsedData[20]) : null,
|
|
1566
|
-
idleFuelUsed: parsedData[21] !== '' ? parseFloat(parsedData[21]) : null,
|
|
1567
|
-
axleWight: parsedData[22] !== '' ? parsedData[22] : null,
|
|
1568
|
-
tachograph: {
|
|
1569
|
-
raw: parsedData[23] !== '' ? parsedData[23] : null,
|
|
1570
|
-
validDriverData: tachographBin ? tachographBin[7] === '1' : null,
|
|
1571
|
-
insertedDriverCard: tachographBin ? tachographBin[5] === '1' : null,
|
|
1572
|
-
driverWorkingState: tachographBin
|
|
1573
|
-
? utils.dWorkingStates[parseInt(tachographBin.substring(3, 5), 2)]
|
|
1574
|
-
: null,
|
|
1575
|
-
drivingTimeState: tachographBin
|
|
1576
|
-
? utils.dTimeStates[parseInt(tachographBin.substring(5, 8), 2)]
|
|
1577
|
-
: null
|
|
1578
|
-
},
|
|
1579
|
-
indicators: {
|
|
1580
|
-
raw: parsedData[24] !== '' ? parsedData[24] : null,
|
|
1581
|
-
lowFuel: inicatorsBin ? inicatorsBin[0] === '1' : null,
|
|
1582
|
-
driverSeatbelt: inicatorsBin ? inicatorsBin[1] === '1' : null,
|
|
1583
|
-
airConditioning: inicatorsBin ? inicatorsBin[2] === '1' : null,
|
|
1584
|
-
cruiseControl: inicatorsBin ? inicatorsBin[3] === '1' : null,
|
|
1585
|
-
brakePedal: inicatorsBin ? inicatorsBin[4] === '1' : null,
|
|
1586
|
-
clutchPedal: inicatorsBin ? inicatorsBin[5] === '1' : null,
|
|
1587
|
-
handbrake: inicatorsBin ? inicatorsBin[6] === '1' : null,
|
|
1588
|
-
centralLock: inicatorsBin ? inicatorsBin[7] === '1' : null,
|
|
1589
|
-
reverseGear: inicatorsBin ? inicatorsBin[8] === '1' : null,
|
|
1590
|
-
runningLights: inicatorsBin ? inicatorsBin[9] === '1' : null,
|
|
1591
|
-
lowBeams: inicatorsBin ? inicatorsBin[10] === '1' : null,
|
|
1592
|
-
highBeams: inicatorsBin ? inicatorsBin[11] === '1' : null,
|
|
1593
|
-
rearFogLights: inicatorsBin ? inicatorsBin[12] === '1' : null,
|
|
1594
|
-
frontFogLights: inicatorsBin ? inicatorsBin[13] === '1' : null,
|
|
1595
|
-
doors: inicatorsBin ? inicatorsBin[14] === '1' : null,
|
|
1596
|
-
trunk: inicatorsBin ? inicatorsBin[15] === '1' : null
|
|
1597
|
-
},
|
|
1598
|
-
lights: {
|
|
1599
|
-
raw: parsedData[25] !== '' ? parsedData[25] : null,
|
|
1600
|
-
running: lights ? lights[0] === '1' : null,
|
|
1601
|
-
lowBeams: lights ? lights[1] === '1' : null,
|
|
1602
|
-
frontFog: lights ? lights[2] === '1' : null,
|
|
1603
|
-
rearFog: lights ? lights[3] === '1' : null,
|
|
1604
|
-
hazard: lights ? lights[4] === '1' : null
|
|
1605
|
-
},
|
|
1606
|
-
doors: {
|
|
1607
|
-
raw: parsedData[26] !== '' ? parsedData[26] : null,
|
|
1608
|
-
driver: doors ? doors[0] === '1' : null,
|
|
1609
|
-
passenger: doors ? doors[1] === '1' : null,
|
|
1610
|
-
rearLeft: doors ? doors[2] === '1' : null,
|
|
1611
|
-
rearRight: doors ? doors[3] === '1' : null,
|
|
1612
|
-
trunk: doors ? doors[4] === '1' : null,
|
|
1613
|
-
hood: doors ? doors[5] === '1' : null
|
|
1614
|
-
},
|
|
1615
|
-
overSpeedTime: parsedData[27] !== '' ? parsedData[27] : null,
|
|
1616
|
-
overSpeedEngineTime: parsedData[28] !== '' ? parsedData[28] : null,
|
|
1617
|
-
canReportExpansionMask: {
|
|
1618
|
-
raw: parsedData[29] !== '' ? parsedData[29] : null,
|
|
1619
|
-
engineTorque: canExpansionMask ? canExpansionMask[23] === '1' : null,
|
|
1620
|
-
rapidAccelerations: canExpansionMask
|
|
1621
|
-
? canExpansionMask[22] === '1'
|
|
1622
|
-
: null,
|
|
1623
|
-
rapidBrakings: canExpansionMask ? canExpansionMask[21] === '1' : null,
|
|
1624
|
-
expansionInformation: canExpansionMask
|
|
1625
|
-
? canExpansionMask[20] === '1'
|
|
1626
|
-
: null,
|
|
1627
|
-
registrationNumber: canExpansionMask
|
|
1628
|
-
? canExpansionMask[19] === '1'
|
|
1629
|
-
: null,
|
|
1630
|
-
tachographDriver2Name: canExpansionMask
|
|
1631
|
-
? canExpansionMask[18] === '1'
|
|
1632
|
-
: null,
|
|
1633
|
-
tachographDriver1Name: canExpansionMask
|
|
1634
|
-
? canExpansionMask[17] === '1'
|
|
1635
|
-
: null,
|
|
1636
|
-
tachographDriver2Card: canExpansionMask
|
|
1637
|
-
? canExpansionMask[16] === '1'
|
|
1638
|
-
: null,
|
|
1639
|
-
tachographDriver1Card: canExpansionMask
|
|
1640
|
-
? canExpansionMask[15] === '1'
|
|
1641
|
-
: null,
|
|
1642
|
-
totalBrakeApplications: canExpansionMask
|
|
1643
|
-
? canExpansionMask[14] === '1'
|
|
1644
|
-
: null,
|
|
1645
|
-
totalAcceleratorKickDownTime: canExpansionMask
|
|
1646
|
-
? canExpansionMask[13] === '1'
|
|
1647
|
-
: null,
|
|
1648
|
-
totalCruiseControlTime: canExpansionMask
|
|
1649
|
-
? canExpansionMask[12] === '1'
|
|
1650
|
-
: null,
|
|
1651
|
-
totalEffectiveEngineSpeedTime: canExpansionMask
|
|
1652
|
-
? canExpansionMask[11] === '1'
|
|
1653
|
-
: null,
|
|
1654
|
-
totalAcceleratorKickDown: canExpansionMask
|
|
1655
|
-
? canExpansionMask[10] === '1'
|
|
1656
|
-
: null,
|
|
1657
|
-
pedalBrakingFactor: canExpansionMask
|
|
1658
|
-
? canExpansionMask[9] === '1'
|
|
1659
|
-
: null,
|
|
1660
|
-
engineBrakingFactor: canExpansionMask
|
|
1661
|
-
? canExpansionMask[8] === '1'
|
|
1662
|
-
: null,
|
|
1663
|
-
analogInputValue: canExpansionMask
|
|
1664
|
-
? canExpansionMask[7] === '1'
|
|
1665
|
-
: null,
|
|
1666
|
-
tachographDrivingDirection: canExpansionMask
|
|
1667
|
-
? canExpansionMask[6] === '1'
|
|
1668
|
-
: null,
|
|
1669
|
-
tachographVehicleMotionSignal: canExpansionMask
|
|
1670
|
-
? canExpansionMask[5] === '1'
|
|
1671
|
-
: null,
|
|
1672
|
-
tachographOverspeedSignal: canExpansionMask
|
|
1673
|
-
? canExpansionMask[4] === '1'
|
|
1674
|
-
: null,
|
|
1675
|
-
AxleWeight4: canExpansionMask ? canExpansionMask[3] === '1' : null,
|
|
1676
|
-
AxleWeight3: canExpansionMask ? canExpansionMask[2] === '1' : null,
|
|
1677
|
-
AxleWeight1: canExpansionMask ? canExpansionMask[1] === '1' : null,
|
|
1678
|
-
adBlueLevel: canExpansionMask ? canExpansionMask[0] === '1' : null
|
|
1679
|
-
},
|
|
1680
|
-
canExpanded: {
|
|
1681
|
-
adBlueLevel:
|
|
1682
|
-
parsedData[30] !== '' ? parseFloat(parsedData[30]) : null,
|
|
1683
|
-
axleWeight1: parsedData[31] !== '' ? parseInt(parsedData[31]) : null,
|
|
1684
|
-
axleWeight3: parsedData[32] !== '' ? parseInt(parsedData[32]) : null,
|
|
1685
|
-
axleWeight4: parsedData[33] !== '' ? parseInt(parsedData[33]) : null,
|
|
1686
|
-
tachographOverspeedSignal:
|
|
1687
|
-
parsedData[34] !== '' ? parseInt(parsedData[34]) : null,
|
|
1688
|
-
tachographVehicleMotionSignal:
|
|
1689
|
-
parsedData[35] !== '' ? parseInt(parsedData[35]) : null,
|
|
1690
|
-
tachographDrivingDirection:
|
|
1691
|
-
parsedData[36] !== '' ? parseInt(parsedData[36]) : null,
|
|
1692
|
-
analogInputValue:
|
|
1693
|
-
parsedData[37] !== '' ? parseInt(parsedData[37]) : null,
|
|
1694
|
-
engineBrakingFactor:
|
|
1695
|
-
parsedData[38] !== '' ? parseInt(parsedData[38]) : null,
|
|
1696
|
-
pedalBrakingFactor:
|
|
1697
|
-
parsedData[39] !== '' ? parseInt(parsedData[39]) : null,
|
|
1698
|
-
totalAcceleratorKickDown:
|
|
1699
|
-
parsedData[40] !== '' ? parseInt(parsedData[40]) : null,
|
|
1700
|
-
totalEffectiveEngineSpeedTime:
|
|
1701
|
-
parsedData[41] !== '' ? parseFloat(parsedData[41]) : null,
|
|
1702
|
-
totalCruiseControlTime:
|
|
1703
|
-
parsedData[42] !== '' ? parseFloat(parsedData[42]) : null,
|
|
1704
|
-
totalAcceleratorKickDownTime:
|
|
1705
|
-
parsedData[43] !== '' ? parseFloat(parsedData[43]) : null,
|
|
1706
|
-
totalBrakeApplications:
|
|
1707
|
-
parsedData[44] !== '' ? parseInt(parsedData[44]) : null,
|
|
1708
|
-
tachographDriver1Card:
|
|
1709
|
-
parsedData[45] !== '' ? parseInt(parsedData[45]) : null,
|
|
1710
|
-
tachographDriver2Card:
|
|
1711
|
-
parsedData[46] !== '' ? parseInt(parsedData[46]) : null,
|
|
1712
|
-
tachographDriver1Name: parsedData[47] !== '' ? parsedData[47] : null,
|
|
1713
|
-
tachographDriver2Name: parsedData[48] !== '' ? parsedData[48] : null,
|
|
1714
|
-
registrationNumber:
|
|
1715
|
-
parsedData[49] !== '' ? parseInt(parsedData[49]) : null,
|
|
1716
|
-
expansionInformation: {
|
|
1717
|
-
raw: parsedData[50] !== '' ? parsedData[50] : null,
|
|
1718
|
-
webasto: expansionBin ? expansionBin[0] === '1' : null,
|
|
1719
|
-
brakeFluidLowIndicator: expansionBin
|
|
1720
|
-
? expansionBin[1] === '1'
|
|
1721
|
-
: null,
|
|
1722
|
-
coolantLevelLowIndicator: expansionBin
|
|
1723
|
-
? expansionBin[2] === '1'
|
|
1724
|
-
: null,
|
|
1725
|
-
batteryIndicator: expansionBin ? expansionBin[3] === '1' : null,
|
|
1726
|
-
brakeSystemaFailureIndicator: expansionBin
|
|
1727
|
-
? expansionBin[4] === '1'
|
|
1728
|
-
: null,
|
|
1729
|
-
oilPressureIndicator: expansionBin ? expansionBin[5] === '1' : null,
|
|
1730
|
-
engineHotIndicator: expansionBin ? expansionBin[6] === '1' : null,
|
|
1731
|
-
ABSFailureIndicator: expansionBin ? expansionBin[7] === '1' : null,
|
|
1732
|
-
checkEngineIndicator: expansionBin ? expansionBin[9] === '1' : null,
|
|
1733
|
-
aribagsIndicator: expansionBin ? expansionBin[10] === '1' : null,
|
|
1734
|
-
serviceCallIndicator: expansionBin
|
|
1735
|
-
? expansionBin[11] === '1'
|
|
1736
|
-
: null,
|
|
1737
|
-
oilLevelLowIndicator: expansionBin ? expansionBin[12] === '1' : null
|
|
1738
|
-
},
|
|
1739
|
-
adblueLevel: parsedData[30] !== '' ? parsedData[30] : null
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1301
|
+
satellites:
|
|
1302
|
+
satelliteInfo && parsedData[index - (satelliteInfo + accuracyInfo) + 1] !== ''
|
|
1303
|
+
? parseInt(parsedData[index - (satelliteInfo + accuracyInfo) + 1], 10)
|
|
1304
|
+
: null,
|
|
1305
|
+
Hdop:
|
|
1306
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
1307
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1], 10)
|
|
1308
|
+
: null,
|
|
1309
|
+
Vdop:
|
|
1310
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
1311
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2], 10)
|
|
1312
|
+
: null,
|
|
1313
|
+
Ddop:
|
|
1314
|
+
accuracyInfo && parsedData[index] !== ''
|
|
1315
|
+
? parseFloat(parsedData[index], 10)
|
|
1316
|
+
: null,
|
|
1317
|
+
odometer: null,
|
|
1318
|
+
hourmeter: null,
|
|
1319
|
+
can: utils.getCanData(parsedData, 5),
|
|
1742
1320
|
})
|
|
1743
1321
|
} else if (command[1] === 'GTDAT') {
|
|
1744
1322
|
let dataIndex = 4
|
|
@@ -1749,14 +1327,9 @@ const parse = raw => {
|
|
|
1749
1327
|
})
|
|
1750
1328
|
} else {
|
|
1751
1329
|
dataIndex = 7
|
|
1752
|
-
let
|
|
1753
|
-
let
|
|
1754
|
-
|
|
1755
|
-
// If get satellites is configured
|
|
1756
|
-
if (utils.includeSatellites(parsedData[index])) {
|
|
1757
|
-
index += 1
|
|
1758
|
-
satelliteInfo = true
|
|
1759
|
-
}
|
|
1330
|
+
let satelliteInfo = utils.includeSatellites(parsedData[19])
|
|
1331
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[19]) ? 3 : 0
|
|
1332
|
+
let index = 19 + (satelliteInfo + accuracyInfo)
|
|
1760
1333
|
|
|
1761
1334
|
data = Object.assign(data, {
|
|
1762
1335
|
loc: {
|
|
@@ -1781,13 +1354,25 @@ const parse = raw => {
|
|
|
1781
1354
|
adb: null,
|
|
1782
1355
|
adc: null
|
|
1783
1356
|
},
|
|
1784
|
-
mcc: parsedData[15] !== '' ? utils.latamMcc[parseInt(parsedData[15], 10)] : null,
|
|
1357
|
+
mcc: parsedData[15] !== '' ? utils.latamMcc[parseInt(parsedData[15], 10)] || utils.latamMcc.default : null,
|
|
1785
1358
|
mnc: parsedData[16] !== '' ? utils.getMNC(parsedData[15], parsedData[16]) : null,
|
|
1786
1359
|
lac: parsedData[17] !== '' ? parseInt(parsedData[17], 16) : null,
|
|
1787
1360
|
cid: parsedData[18] !== '' ? parseInt(parsedData[18], 16) : null,
|
|
1788
1361
|
satellites:
|
|
1789
|
-
satelliteInfo && parsedData[index] !== ''
|
|
1790
|
-
? parseInt(parsedData[index], 10)
|
|
1362
|
+
satelliteInfo && parsedData[index - (satelliteInfo + accuracyInfo) + 1] !== ''
|
|
1363
|
+
? parseInt(parsedData[index - (satelliteInfo + accuracyInfo) + 1], 10)
|
|
1364
|
+
: null,
|
|
1365
|
+
Hdop:
|
|
1366
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
1367
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1], 10)
|
|
1368
|
+
: null,
|
|
1369
|
+
Vdop:
|
|
1370
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
1371
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2], 10)
|
|
1372
|
+
: null,
|
|
1373
|
+
Ddop:
|
|
1374
|
+
accuracyInfo && parsedData[index] !== ''
|
|
1375
|
+
? parseFloat(parsedData[index], 10)
|
|
1791
1376
|
: null,
|
|
1792
1377
|
odometer: null,
|
|
1793
1378
|
hourmeter: null
|
|
@@ -1798,16 +1383,10 @@ const parse = raw => {
|
|
|
1798
1383
|
alarm: utils.getAlarm(command[1], parsedData[dataIndex])
|
|
1799
1384
|
})
|
|
1800
1385
|
} else if (command[1] === 'GTDOS') {
|
|
1801
|
-
let
|
|
1802
|
-
let
|
|
1803
|
-
let
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
// If get satellites is configured
|
|
1807
|
-
if (utils.includeSatellites(parsedData[index])) {
|
|
1808
|
-
index += 1
|
|
1809
|
-
satelliteInfo = true
|
|
1810
|
-
}
|
|
1386
|
+
let satelliteInfo = utils.includeSatellites(parsedData[17])
|
|
1387
|
+
let includeStatus = utils.includeStatus(parsedData[17])
|
|
1388
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[17]) ? 3 : 0
|
|
1389
|
+
let index = 17 + (satelliteInfo + includeStatus + accuracyInfo)
|
|
1811
1390
|
|
|
1812
1391
|
data = Object.assign(data, {
|
|
1813
1392
|
alarm: utils.getAlarm(command[1], `${parsedData[4]},${parsedData[5]}`),
|
|
@@ -1828,66 +1407,72 @@ const parse = raw => {
|
|
|
1828
1407
|
battery: null,
|
|
1829
1408
|
inputCharge: null
|
|
1830
1409
|
},
|
|
1831
|
-
mcc: parsedData[13] !== '' ? utils.latamMcc[parseInt(parsedData[13], 10)] : null,
|
|
1410
|
+
mcc: parsedData[13] !== '' ? utils.latamMcc[parseInt(parsedData[13], 10)] || utils.latamMcc.default : null,
|
|
1832
1411
|
mnc: parsedData[14] !== '' ? utils.getMNC(parsedData[13], parsedData[14]) : null,
|
|
1833
1412
|
lac: parsedData[15] !== '' ? parseInt(parsedData[15], 16) : null,
|
|
1834
1413
|
cid: parsedData[16] !== '' ? parseInt(parsedData[16], 16) : null,
|
|
1835
1414
|
satellites:
|
|
1836
|
-
satelliteInfo && parsedData[index] !== ''
|
|
1837
|
-
? parseInt(parsedData[index], 10)
|
|
1415
|
+
satelliteInfo && parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1] !== ''
|
|
1416
|
+
? parseInt(parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1], 10)
|
|
1838
1417
|
: null,
|
|
1839
|
-
status: includeStatus
|
|
1418
|
+
status: includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
|
|
1840
1419
|
? {
|
|
1841
|
-
raw: parsedData[index + 1],
|
|
1420
|
+
raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
|
|
1842
1421
|
sos: false,
|
|
1843
1422
|
input: {
|
|
1844
1423
|
'2':
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1424
|
+
utils.nHexDigit(
|
|
1425
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
1426
|
+
8
|
|
1427
|
+
)[6] === '1',
|
|
1849
1428
|
'1':
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1429
|
+
utils.nHexDigit(
|
|
1430
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
1431
|
+
8
|
|
1432
|
+
)[7] === '1'
|
|
1854
1433
|
},
|
|
1855
1434
|
output: {
|
|
1856
1435
|
'3':
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1436
|
+
utils.nHexDigit(
|
|
1437
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1438
|
+
8
|
|
1439
|
+
)[5] === '1',
|
|
1861
1440
|
'2':
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1441
|
+
utils.nHexDigit(
|
|
1442
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1443
|
+
8
|
|
1444
|
+
)[6] === '1',
|
|
1866
1445
|
'1':
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1446
|
+
utils.nHexDigit(
|
|
1447
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1448
|
+
8
|
|
1449
|
+
)[7] === '1'
|
|
1871
1450
|
},
|
|
1872
1451
|
charge: null,
|
|
1873
|
-
state: utils.states[parsedData[index + 1].substring(0, 2)]
|
|
1452
|
+
state: utils.states[parsedData[index - (includeStatus + accuracyInfo) + 1].substring(0, 2)]
|
|
1874
1453
|
}
|
|
1875
1454
|
: null,
|
|
1455
|
+
Hdop:
|
|
1456
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
1457
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1])
|
|
1458
|
+
: null,
|
|
1459
|
+
Vdop:
|
|
1460
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
1461
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2])
|
|
1462
|
+
: null,
|
|
1463
|
+
Ddop:
|
|
1464
|
+
accuracyInfo && parsedData[index] !== ''
|
|
1465
|
+
? parseFloat(parsedData[index])
|
|
1466
|
+
: null,
|
|
1876
1467
|
odometer: null,
|
|
1877
1468
|
hourmeter: null
|
|
1878
1469
|
})
|
|
1879
1470
|
} else if (command[1] === 'GTDOM') {
|
|
1880
1471
|
// Waveform beeing monitored
|
|
1881
|
-
let
|
|
1882
|
-
let
|
|
1883
|
-
let
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
// If get satellites is configured
|
|
1887
|
-
if (utils.includeSatellites(parsedData[index])) {
|
|
1888
|
-
index += 1
|
|
1889
|
-
satelliteInfo = true
|
|
1890
|
-
}
|
|
1472
|
+
let satelliteInfo = utils.includeSatellites(parsedData[18])
|
|
1473
|
+
let includeStatus = utils.includeStatus(parsedData[18])
|
|
1474
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[18]) ? 3 : 0
|
|
1475
|
+
let index = 18 + (satelliteInfo + includeStatus + accuracyInfo)
|
|
1891
1476
|
|
|
1892
1477
|
data = Object.assign(data, {
|
|
1893
1478
|
alarm: utils.getAlarm(command[1], [parsedData[4], parsedData[5]]),
|
|
@@ -1908,51 +1493,63 @@ const parse = raw => {
|
|
|
1908
1493
|
battery: null,
|
|
1909
1494
|
inputCharge: null
|
|
1910
1495
|
},
|
|
1911
|
-
mcc: parsedData[14] !== '' ? utils.latamMcc[parseInt(parsedData[14], 10)] : null,
|
|
1496
|
+
mcc: parsedData[14] !== '' ? utils.latamMcc[parseInt(parsedData[14], 10)] || utils.latamMcc.default : null,
|
|
1912
1497
|
mnc: parsedData[15] !== '' ? utils.getMNC(parsedData[14], parsedData[15]) : null,
|
|
1913
1498
|
lac: parsedData[16] !== '' ? parseInt(parsedData[16], 16) : null,
|
|
1914
1499
|
cid: parsedData[17] !== '' ? parseInt(parsedData[17], 16) : null,
|
|
1915
1500
|
satellites:
|
|
1916
|
-
satelliteInfo && parsedData[index] !== ''
|
|
1917
|
-
? parseInt(parsedData[index], 10)
|
|
1501
|
+
satelliteInfo && parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1] !== ''
|
|
1502
|
+
? parseInt(parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1], 10)
|
|
1918
1503
|
: null,
|
|
1919
|
-
status: includeStatus
|
|
1504
|
+
status: includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
|
|
1920
1505
|
? {
|
|
1921
|
-
raw: parsedData[index + 1],
|
|
1506
|
+
raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
|
|
1922
1507
|
sos: false,
|
|
1923
1508
|
input: {
|
|
1924
1509
|
'2':
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1510
|
+
utils.nHexDigit(
|
|
1511
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
1512
|
+
8
|
|
1513
|
+
)[6] === '1',
|
|
1929
1514
|
'1':
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1515
|
+
utils.nHexDigit(
|
|
1516
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
1517
|
+
8
|
|
1518
|
+
)[7] === '1'
|
|
1934
1519
|
},
|
|
1935
1520
|
output: {
|
|
1936
1521
|
'3':
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1522
|
+
utils.nHexDigit(
|
|
1523
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1524
|
+
8
|
|
1525
|
+
)[5] === '1',
|
|
1941
1526
|
'2':
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1527
|
+
utils.nHexDigit(
|
|
1528
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1529
|
+
8
|
|
1530
|
+
)[6] === '1',
|
|
1946
1531
|
'1':
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1532
|
+
utils.nHexDigit(
|
|
1533
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1534
|
+
8
|
|
1535
|
+
)[7] === '1'
|
|
1951
1536
|
},
|
|
1952
1537
|
charge: null,
|
|
1953
|
-
state: utils.states[parsedData[index + 1].substring(0, 2)]
|
|
1538
|
+
state: utils.states[parsedData[index - (includeStatus + accuracyInfo) + 1].substring(0, 2)]
|
|
1954
1539
|
}
|
|
1955
1540
|
: null,
|
|
1541
|
+
Hdop:
|
|
1542
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
1543
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1])
|
|
1544
|
+
: null,
|
|
1545
|
+
Vdop:
|
|
1546
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
1547
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2])
|
|
1548
|
+
: null,
|
|
1549
|
+
Ddop:
|
|
1550
|
+
accuracyInfo && parsedData[index] !== ''
|
|
1551
|
+
? parseFloat(parsedData[index])
|
|
1552
|
+
: null,
|
|
1956
1553
|
odometer: null,
|
|
1957
1554
|
hourmeter: null
|
|
1958
1555
|
})
|
|
@@ -1966,16 +1563,10 @@ const parse = raw => {
|
|
|
1966
1563
|
})
|
|
1967
1564
|
} else if (command[1] === 'GTBCS' || command[1] === 'GTBDS') {
|
|
1968
1565
|
// Bluetooth connection/desconnection
|
|
1969
|
-
let
|
|
1970
|
-
let
|
|
1971
|
-
let
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
// If get satellites is configured
|
|
1975
|
-
if (utils.includeSatellites(parsedData[index])) {
|
|
1976
|
-
index = includeStatus ? index + 2 : index + 1
|
|
1977
|
-
satelliteInfo = true
|
|
1978
|
-
}
|
|
1566
|
+
let satelliteInfo = utils.includeSatellites(parsedData[16])
|
|
1567
|
+
let includeStatus = utils.includeStatus(parsedData[16])
|
|
1568
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[16]) ? 3 : 0
|
|
1569
|
+
let index = 16 + (satelliteInfo + includeStatus + accuracyInfo)
|
|
1979
1570
|
|
|
1980
1571
|
data = Object.assign(data, {
|
|
1981
1572
|
alarm: utils.getAlarm(command[1], null, 'gv58lau'),
|
|
@@ -1996,54 +1587,63 @@ const parse = raw => {
|
|
|
1996
1587
|
battery: null,
|
|
1997
1588
|
inputCharge: null
|
|
1998
1589
|
},
|
|
1999
|
-
mcc: parsedData[12] !== '' ? utils.latamMcc[parseInt(parsedData[12], 10)] : null,
|
|
1590
|
+
mcc: parsedData[12] !== '' ? utils.latamMcc[parseInt(parsedData[12], 10)] || utils.latamMcc.default : null,
|
|
2000
1591
|
mnc: parsedData[13] !== '' ? utils.getMNC(parsedData[12], parsedData[13]) : null,
|
|
2001
1592
|
lac: parsedData[14] !== '' ? parseInt(parsedData[14], 16) : null,
|
|
2002
1593
|
cid: parsedData[15] !== '' ? parseInt(parsedData[15], 16) : null,
|
|
2003
|
-
satellites:
|
|
2004
|
-
|
|
2005
|
-
? parseInt(parsedData[index - 1])
|
|
2006
|
-
: null
|
|
2007
|
-
: satelliteInfo && parsedData[index] !== ''
|
|
2008
|
-
? parseInt(parsedData[index])
|
|
1594
|
+
satellites:
|
|
1595
|
+
satelliteInfo && parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1] !== ''
|
|
1596
|
+
? parseInt(parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1], 10)
|
|
2009
1597
|
: null,
|
|
2010
|
-
status: includeStatus
|
|
1598
|
+
status: includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
|
|
2011
1599
|
? {
|
|
2012
|
-
raw: parsedData[index],
|
|
1600
|
+
raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
|
|
2013
1601
|
sos: false,
|
|
2014
1602
|
input: {
|
|
2015
1603
|
'2':
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
1604
|
+
utils.nHexDigit(
|
|
1605
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
1606
|
+
8
|
|
1607
|
+
)[6] === '1',
|
|
2020
1608
|
'1':
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
1609
|
+
utils.nHexDigit(
|
|
1610
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
1611
|
+
8
|
|
1612
|
+
)[7] === '1'
|
|
2025
1613
|
},
|
|
2026
1614
|
output: {
|
|
2027
1615
|
'3':
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
1616
|
+
utils.nHexDigit(
|
|
1617
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1618
|
+
8
|
|
1619
|
+
)[5] === '1',
|
|
2032
1620
|
'2':
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
1621
|
+
utils.nHexDigit(
|
|
1622
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1623
|
+
8
|
|
1624
|
+
)[6] === '1',
|
|
2037
1625
|
'1':
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
1626
|
+
utils.nHexDigit(
|
|
1627
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1628
|
+
8
|
|
1629
|
+
)[7] === '1'
|
|
2042
1630
|
},
|
|
2043
1631
|
charge: null,
|
|
2044
|
-
state: utils.states[parsedData[index].substring(0, 2)]
|
|
1632
|
+
state: utils.states[parsedData[index - (includeStatus + accuracyInfo) + 1].substring(0, 2)]
|
|
2045
1633
|
}
|
|
2046
1634
|
: null,
|
|
1635
|
+
Hdop:
|
|
1636
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
1637
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1])
|
|
1638
|
+
: null,
|
|
1639
|
+
Vdop:
|
|
1640
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
1641
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2])
|
|
1642
|
+
: null,
|
|
1643
|
+
Ddop:
|
|
1644
|
+
accuracyInfo && parsedData[index] !== ''
|
|
1645
|
+
? parseFloat(parsedData[index])
|
|
1646
|
+
: null,
|
|
2047
1647
|
odometer: null,
|
|
2048
1648
|
hourmeter: null,
|
|
2049
1649
|
bluetooth: {
|
|
@@ -2052,13 +1652,13 @@ const parse = raw => {
|
|
|
2052
1652
|
bluetoothInfo: {
|
|
2053
1653
|
name:
|
|
2054
1654
|
parsedData[index + 2] !== '' &&
|
|
2055
|
-
|
|
1655
|
+
utils.nHexDigit(utils.hex2bin(parsedData[index + 1]), 16)[15] ===
|
|
2056
1656
|
'1'
|
|
2057
1657
|
? parsedData[index + 2]
|
|
2058
1658
|
: null,
|
|
2059
1659
|
mac:
|
|
2060
1660
|
parsedData[index + 3] !== '' &&
|
|
2061
|
-
|
|
1661
|
+
utils.nHexDigit(utils.hex2bin(parsedData[index + 1]), 16)[14] ===
|
|
2062
1662
|
'1'
|
|
2063
1663
|
? parsedData[index + 3]
|
|
2064
1664
|
: null
|
|
@@ -2069,17 +1669,17 @@ const parse = raw => {
|
|
|
2069
1669
|
name: null,
|
|
2070
1670
|
role:
|
|
2071
1671
|
parsedData[index + 4] !== '' &&
|
|
2072
|
-
|
|
1672
|
+
utils.nHexDigit(utils.hex2bin(parsedData[index + 1]), 16)[7] === '1'
|
|
2073
1673
|
? utils.peerRoles[parsedData[index + 4]]
|
|
2074
1674
|
: null,
|
|
2075
1675
|
type:
|
|
2076
1676
|
parsedData[index + 5] !== '' &&
|
|
2077
|
-
|
|
1677
|
+
utils.nHexDigit(utils.hex2bin(parsedData[index + 1]), 16)[5] === '1'
|
|
2078
1678
|
? utils.peerAddressesTypes[parsedData[index + 5]]
|
|
2079
1679
|
: null,
|
|
2080
1680
|
mac:
|
|
2081
1681
|
parsedData[index + 6] !== '' &&
|
|
2082
|
-
|
|
1682
|
+
utils.nHexDigit(utils.hex2bin(parsedData[index + 1]), 16)[4] === '1'
|
|
2083
1683
|
? parsedData[index + 6]
|
|
2084
1684
|
: null
|
|
2085
1685
|
},
|
|
@@ -2109,7 +1709,6 @@ const parse = raw => {
|
|
|
2109
1709
|
})
|
|
2110
1710
|
} else if (command[1] === 'GTBAA') {
|
|
2111
1711
|
// Bluetooth alarms
|
|
2112
|
-
let satelliteInfo = false
|
|
2113
1712
|
let appendIx = 8
|
|
2114
1713
|
let appendMask = utils.nHexDigit(utils.hex2bin(parsedData[appendIx]), 16)
|
|
2115
1714
|
let btAccessory = parsedData[5]
|
|
@@ -2120,31 +1719,105 @@ const parse = raw => {
|
|
|
2120
1719
|
let aTmpIx = aBatIx + parseInt(appendMask[11])
|
|
2121
1720
|
let aHumIx = aTmpIx + parseInt(appendMask[10])
|
|
2122
1721
|
let ioIx = aHumIx + parseInt(appendMask[8])
|
|
2123
|
-
let
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
1722
|
+
let aEvIx = appendMask[8] === '1' && appendMask[7] === '1'
|
|
1723
|
+
? ioIx + 3 : ioIx + parseInt(appendMask[7])
|
|
1724
|
+
let pressIx = appendMask[7] === '1' && appendMask[6] === '1'
|
|
1725
|
+
? aEvIx + 2 : aEvIx + parseInt(appendMask[6])
|
|
2127
1726
|
let timeIx = pressIx + parseInt(appendMask[5])
|
|
2128
1727
|
let eTmpIx = timeIx + parseInt(appendMask[4])
|
|
2129
1728
|
let magIx = eTmpIx + parseInt(appendMask[3])
|
|
2130
|
-
let aBatpIx =
|
|
2131
|
-
|
|
1729
|
+
let aBatpIx = appendMask[3] === '1' && appendMask[2] === '1'
|
|
1730
|
+
? magIx + 3 : magIx + parseInt(appendMask[2])
|
|
2132
1731
|
let relIx = aBatpIx + parseInt(appendMask[1])
|
|
2133
1732
|
|
|
2134
|
-
let newIndex =
|
|
2135
|
-
let satIndex = newIndex + 11
|
|
1733
|
+
let newIndex = relIx + 1 + parseInt(appendMask[1])
|
|
2136
1734
|
|
|
2137
|
-
let
|
|
2138
|
-
|
|
1735
|
+
let satelliteInfo = utils.includeSatellites(parsedData[newIndex + 11])
|
|
1736
|
+
let includeStatus = utils.includeStatus(parsedData[newIndex + 11])
|
|
1737
|
+
let accuracyInfo = utils.includeGnnsAccuracy(parsedData[newIndex + 11]) ? 3 : 0
|
|
1738
|
+
let index = newIndex + 11 + (satelliteInfo + includeStatus + accuracyInfo)
|
|
2139
1739
|
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
1740
|
+
let bleInfo = {
|
|
1741
|
+
accesory:
|
|
1742
|
+
btAccessory !== '' ? utils.bluetoothAccessories[btAccessory] : null,
|
|
1743
|
+
model: parsedData[6] !== '' ? parseInt(parsedData[6]) : null,
|
|
1744
|
+
name:
|
|
1745
|
+
parsedData[aNameIx] !== '' && appendMask[15] === '1'
|
|
1746
|
+
? parsedData[aNameIx]
|
|
1747
|
+
: null,
|
|
1748
|
+
role: null,
|
|
1749
|
+
type: null,
|
|
1750
|
+
mac:
|
|
1751
|
+
parsedData[aMacIx] !== '' && appendMask[14] === '1'
|
|
1752
|
+
? parsedData[aMacIx]
|
|
1753
|
+
: null,
|
|
1754
|
+
status:
|
|
1755
|
+
parsedData[aStatIx] !== '' && appendMask[13] === '1'
|
|
1756
|
+
? parseInt(parsedData[aStatIx])
|
|
1757
|
+
: null,
|
|
1758
|
+
batteryLevel:
|
|
1759
|
+
parsedData[aBatIx] !== '' && appendMask[12] === '1'
|
|
1760
|
+
? parseInt(parsedData[aBatIx])
|
|
1761
|
+
: null,
|
|
1762
|
+
batteryPercentage:
|
|
1763
|
+
parsedData[aBatpIx] !== '' && appendMask[2] === '1'
|
|
1764
|
+
? parseFloat(parsedData[aBatpIx])
|
|
1765
|
+
: null
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
let bleData = {
|
|
1769
|
+
temperature:
|
|
1770
|
+
parsedData[aTmpIx] !== '' && appendMask[11] === '1'
|
|
1771
|
+
? parseInt(parsedData[aTmpIx])
|
|
1772
|
+
: null,
|
|
1773
|
+
humidity:
|
|
1774
|
+
parsedData[aHumIx] !== '' && appendMask[10] === '1'
|
|
1775
|
+
? parseInt(parsedData[aHumIx])
|
|
1776
|
+
: null,
|
|
1777
|
+
event:
|
|
1778
|
+
parsedData[aEvIx] !== '' && appendMask[7] === '1'
|
|
1779
|
+
? parseInt(parsedData[aEvIx])
|
|
1780
|
+
: null,
|
|
1781
|
+
tirePresure:
|
|
1782
|
+
parsedData[pressIx] !== '' && appendMask[6] === '1'
|
|
1783
|
+
? parseInt(parsedData[pressIx])
|
|
1784
|
+
: null,
|
|
1785
|
+
timestamp:
|
|
1786
|
+
parsedData[timeIx] !== '' && appendMask[5] === '1'
|
|
1787
|
+
? utils.parseDate(parsedData[timeIx])
|
|
1788
|
+
: null,
|
|
1789
|
+
enhancedTemperature:
|
|
1790
|
+
parsedData[eTmpIx] !== '' && appendMask[4] === '1'
|
|
1791
|
+
? parseFloat(parsedData[eTmpIx])
|
|
1792
|
+
: null,
|
|
1793
|
+
magDevice: {
|
|
1794
|
+
id:
|
|
1795
|
+
parsedData[magIx] !== '' && appendMask[3] === '1'
|
|
1796
|
+
? parsedData[magIx]
|
|
1797
|
+
: null,
|
|
1798
|
+
eventCounter:
|
|
1799
|
+
parsedData[magIx + 1] !== '' && appendMask[3] === '1'
|
|
1800
|
+
? parseInt(parsedData[magIx + 1])
|
|
1801
|
+
: null,
|
|
1802
|
+
magnetState:
|
|
1803
|
+
parsedData[magIx + 2] !== '' && appendMask[3] === '1'
|
|
1804
|
+
? parseInt(parsedData[magIx + 2])
|
|
1805
|
+
: null
|
|
1806
|
+
},
|
|
1807
|
+
relay: {
|
|
1808
|
+
configResult:
|
|
1809
|
+
parsedData[relIx] !== '' && appendMask[1] === '1'
|
|
1810
|
+
? parseInt(parsedData[relIx])
|
|
1811
|
+
: null,
|
|
1812
|
+
state:
|
|
1813
|
+
parsedData[relIx + 1] !== '' && appendMask[1] === '1'
|
|
1814
|
+
? parseInt(parsedData[relIx + 1])
|
|
1815
|
+
: null
|
|
1816
|
+
}
|
|
2144
1817
|
}
|
|
2145
1818
|
|
|
2146
1819
|
data = Object.assign(data, {
|
|
2147
|
-
alarm: utils.getAlarm(command[1], parsedData[7],
|
|
1820
|
+
alarm: utils.getAlarm(command[1], parsedData[7], [parsedData[4], bleInfo.mac, bleData]),
|
|
2148
1821
|
loc: {
|
|
2149
1822
|
type: 'Point',
|
|
2150
1823
|
coordinates: [
|
|
@@ -2195,46 +1868,58 @@ const parse = raw => {
|
|
|
2195
1868
|
? parseInt(parsedData[newIndex + 10], 16)
|
|
2196
1869
|
: null,
|
|
2197
1870
|
satellites:
|
|
2198
|
-
satelliteInfo && parsedData[
|
|
2199
|
-
? parseInt(parsedData[
|
|
1871
|
+
satelliteInfo && parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1] !== ''
|
|
1872
|
+
? parseInt(parsedData[index - (satelliteInfo + includeStatus + accuracyInfo) + 1], 10)
|
|
2200
1873
|
: null,
|
|
2201
|
-
status: includeStatus
|
|
1874
|
+
status: includeStatus && parsedData[index - (includeStatus + accuracyInfo) + 1]
|
|
2202
1875
|
? {
|
|
2203
|
-
raw: parsedData[
|
|
1876
|
+
raw: parsedData[index - (includeStatus + accuracyInfo) + 1],
|
|
2204
1877
|
sos: false,
|
|
2205
1878
|
input: {
|
|
2206
1879
|
'2':
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
1880
|
+
utils.nHexDigit(
|
|
1881
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
1882
|
+
8
|
|
1883
|
+
)[6] === '1',
|
|
2211
1884
|
'1':
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
1885
|
+
utils.nHexDigit(
|
|
1886
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(2, 4)),
|
|
1887
|
+
8
|
|
1888
|
+
)[7] === '1'
|
|
2216
1889
|
},
|
|
2217
1890
|
output: {
|
|
2218
1891
|
'3':
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
1892
|
+
utils.nHexDigit(
|
|
1893
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1894
|
+
8
|
|
1895
|
+
)[5] === '1',
|
|
2223
1896
|
'2':
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
1897
|
+
utils.nHexDigit(
|
|
1898
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1899
|
+
8
|
|
1900
|
+
)[6] === '1',
|
|
2228
1901
|
'1':
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
1902
|
+
utils.nHexDigit(
|
|
1903
|
+
utils.hex2bin(parsedData[index - (includeStatus + accuracyInfo) + 1].substring(4, 6)),
|
|
1904
|
+
8
|
|
1905
|
+
)[7] === '1'
|
|
2233
1906
|
},
|
|
2234
1907
|
charge: null,
|
|
2235
|
-
state: utils.states[parsedData[
|
|
1908
|
+
state: utils.states[parsedData[index - (includeStatus + accuracyInfo) + 1].substring(0, 2)]
|
|
2236
1909
|
}
|
|
2237
1910
|
: null,
|
|
1911
|
+
Hdop:
|
|
1912
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 1] !== ''
|
|
1913
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 1])
|
|
1914
|
+
: null,
|
|
1915
|
+
Vdop:
|
|
1916
|
+
accuracyInfo && parsedData[index - (accuracyInfo) + 2] !== ''
|
|
1917
|
+
? parseFloat(parsedData[index - (accuracyInfo) + 2])
|
|
1918
|
+
: null,
|
|
1919
|
+
Ddop:
|
|
1920
|
+
accuracyInfo && parsedData[index] !== ''
|
|
1921
|
+
? parseFloat(parsedData[index])
|
|
1922
|
+
: null,
|
|
2238
1923
|
odometer: null,
|
|
2239
1924
|
hourmeter: null,
|
|
2240
1925
|
bluetooth: {
|
|
@@ -2250,87 +1935,8 @@ const parse = raw => {
|
|
|
2250
1935
|
? parsedData[aMacIx]
|
|
2251
1936
|
: null
|
|
2252
1937
|
},
|
|
2253
|
-
accessoryInfo:
|
|
2254
|
-
|
|
2255
|
-
btAccessory !== '' ? utils.bluetoothAccessories[btAccessory] : null,
|
|
2256
|
-
model: parsedData[6] !== '' ? parseInt(parsedData[6]) : null,
|
|
2257
|
-
name:
|
|
2258
|
-
parsedData[aNameIx] !== '' && appendMask[15] === '1'
|
|
2259
|
-
? parsedData[aNameIx]
|
|
2260
|
-
: null,
|
|
2261
|
-
role: null,
|
|
2262
|
-
type: null,
|
|
2263
|
-
mac:
|
|
2264
|
-
parsedData[aMacIx] !== '' && appendMask[14] === '1'
|
|
2265
|
-
? parsedData[aMacIx]
|
|
2266
|
-
: null,
|
|
2267
|
-
status:
|
|
2268
|
-
parsedData[aStatIx] !== '' && appendMask[13] === '1'
|
|
2269
|
-
? parseInt(parsedData[aStatIx])
|
|
2270
|
-
: null,
|
|
2271
|
-
batteryLevel:
|
|
2272
|
-
parsedData[aBatIx] !== '' && appendMask[12] === '1'
|
|
2273
|
-
? parseInt(parsedData[aBatIx])
|
|
2274
|
-
: null,
|
|
2275
|
-
batteryPercentage:
|
|
2276
|
-
parsedData[aBatpIx] !== '' && appendMask[2] === '1'
|
|
2277
|
-
? parseFloat(parsedData[aBatpIx])
|
|
2278
|
-
: null
|
|
2279
|
-
},
|
|
2280
|
-
accessoryData: {
|
|
2281
|
-
temperature:
|
|
2282
|
-
parsedData[aTmpIx] !== '' && appendMask[11] === '1'
|
|
2283
|
-
? parseInt(parsedData[aTmpIx])
|
|
2284
|
-
: null,
|
|
2285
|
-
humidity:
|
|
2286
|
-
parsedData[aHumIx] !== '' && appendMask[10] === '1'
|
|
2287
|
-
? parseInt(parsedData[aHumIx])
|
|
2288
|
-
: null,
|
|
2289
|
-
mode:
|
|
2290
|
-
parsedData[modeIx] !== '' && appendMask[7] === '1'
|
|
2291
|
-
? parseInt(parsedData[modeIx])
|
|
2292
|
-
: null,
|
|
2293
|
-
event:
|
|
2294
|
-
parsedData[aEvIx] !== '' && appendMask[7] === '1'
|
|
2295
|
-
? parseInt(parsedData[aEvIx])
|
|
2296
|
-
: null,
|
|
2297
|
-
tirePresure:
|
|
2298
|
-
parsedData[pressIx] !== '' && appendMask[6] === '1'
|
|
2299
|
-
? parseInt(parsedData[pressIx])
|
|
2300
|
-
: null,
|
|
2301
|
-
timestamp:
|
|
2302
|
-
parsedData[timeIx] !== '' && appendMask[5] === '1'
|
|
2303
|
-
? utils.parseDate(parsedData[timeIx])
|
|
2304
|
-
: null,
|
|
2305
|
-
enhancedTemperature:
|
|
2306
|
-
parsedData[eTmpIx] !== '' && appendMask[4] === '1'
|
|
2307
|
-
? parseFloat(parsedData[eTmpIx])
|
|
2308
|
-
: null,
|
|
2309
|
-
magDevice: {
|
|
2310
|
-
id:
|
|
2311
|
-
parsedData[magIx] !== '' && appendMask[3] === '1'
|
|
2312
|
-
? parsedData[magIx]
|
|
2313
|
-
: null,
|
|
2314
|
-
eventCounter:
|
|
2315
|
-
parsedData[magIx + 1] !== '' && appendMask[3] === '1'
|
|
2316
|
-
? parseInt(parsedData[magIx + 1])
|
|
2317
|
-
: null,
|
|
2318
|
-
magnetState:
|
|
2319
|
-
parsedData[magIx + 2] !== '' && appendMask[3] === '1'
|
|
2320
|
-
? parseInt(parsedData[magIx + 2])
|
|
2321
|
-
: null
|
|
2322
|
-
},
|
|
2323
|
-
relay: {
|
|
2324
|
-
configResult:
|
|
2325
|
-
parsedData[relIx] !== '' && appendMask[1] === '1'
|
|
2326
|
-
? parseInt(parsedData[relIx])
|
|
2327
|
-
: null,
|
|
2328
|
-
state:
|
|
2329
|
-
parsedData[relIx + 1] !== '' && appendMask[1] === '1'
|
|
2330
|
-
? parseInt(parsedData[relIx + 1])
|
|
2331
|
-
: null
|
|
2332
|
-
}
|
|
2333
|
-
}
|
|
1938
|
+
accessoryInfo: bleInfo,
|
|
1939
|
+
accessoryData: bleData
|
|
2334
1940
|
}
|
|
2335
1941
|
})
|
|
2336
1942
|
} else if (command[1] === 'GTBID') {
|
|
@@ -2449,29 +2055,29 @@ const parse = raw => {
|
|
|
2449
2055
|
appendMask[0] === '1' && parsedData[typeIx + 1] !== ''
|
|
2450
2056
|
? {
|
|
2451
2057
|
idMfrData:
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2058
|
+
parsedData[typeIx] === '0' && parsedData[typeIx + 1] !== ''
|
|
2059
|
+
? parsedData[typeIx + 1]
|
|
2060
|
+
: null,
|
|
2455
2061
|
uuid:
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2062
|
+
parsedData[typeIx] === '1' && parsedData[typeIx + 1] !== ''
|
|
2063
|
+
? parsedData[typeIx + 1]
|
|
2064
|
+
: null,
|
|
2459
2065
|
major:
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2066
|
+
parsedData[typeIx] === '1' && parsedData[typeIx + 2] !== ''
|
|
2067
|
+
? parsedData[typeIx + 2]
|
|
2068
|
+
: null,
|
|
2463
2069
|
minor:
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2070
|
+
parsedData[typeIx] === '1' && parsedData[typeIx + 3] !== ''
|
|
2071
|
+
? parsedData[typeIx + 3]
|
|
2072
|
+
: null,
|
|
2467
2073
|
nid:
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2074
|
+
parsedData[typeIx] === '2' && parsedData[typeIx + 1] !== ''
|
|
2075
|
+
? parsedData[typeIx + 1]
|
|
2076
|
+
: null,
|
|
2471
2077
|
bid:
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2078
|
+
parsedData[typeIx] === '2' && parsedData[typeIx + 2] !== ''
|
|
2079
|
+
? parsedData[typeIx + 2]
|
|
2080
|
+
: null
|
|
2475
2081
|
}
|
|
2476
2082
|
: null
|
|
2477
2083
|
})
|
|
@@ -2521,7 +2127,7 @@ const parse = raw => {
|
|
|
2521
2127
|
battery: null,
|
|
2522
2128
|
inputCharge: null
|
|
2523
2129
|
},
|
|
2524
|
-
mcc: parsedData[14] !== '' ? utils.latamMcc[parseInt(parsedData[14], 10)] : null,
|
|
2130
|
+
mcc: parsedData[14] !== '' ? utils.latamMcc[parseInt(parsedData[14], 10)] || utils.latamMcc.default : null,
|
|
2525
2131
|
mnc: parsedData[15] !== '' ? utils.getMNC(parsedData[14], parsedData[15]) : null,
|
|
2526
2132
|
lac: parsedData[16] !== '' ? parseInt(parsedData[16], 16) : null,
|
|
2527
2133
|
cid: parsedData[17] !== '' ? parseInt(parsedData[17], 16) : null,
|
|
@@ -2535,32 +2141,32 @@ const parse = raw => {
|
|
|
2535
2141
|
sos: false,
|
|
2536
2142
|
input: {
|
|
2537
2143
|
'2':
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2144
|
+
utils.nHexDigit(
|
|
2145
|
+
utils.hex2bin(parsedData[index + 1].substring(2, 4)),
|
|
2146
|
+
8
|
|
2147
|
+
)[6] === '1',
|
|
2542
2148
|
'1':
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2149
|
+
utils.nHexDigit(
|
|
2150
|
+
utils.hex2bin(parsedData[index + 1].substring(2, 4)),
|
|
2151
|
+
8
|
|
2152
|
+
)[7] === '1'
|
|
2547
2153
|
},
|
|
2548
2154
|
output: {
|
|
2549
2155
|
'3':
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2156
|
+
utils.nHexDigit(
|
|
2157
|
+
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
2158
|
+
8
|
|
2159
|
+
)[5] === '1',
|
|
2554
2160
|
'2':
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2161
|
+
utils.nHexDigit(
|
|
2162
|
+
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
2163
|
+
8
|
|
2164
|
+
)[6] === '1',
|
|
2559
2165
|
'1':
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2166
|
+
utils.nHexDigit(
|
|
2167
|
+
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
2168
|
+
8
|
|
2169
|
+
)[7] === '1'
|
|
2564
2170
|
},
|
|
2565
2171
|
charge: null,
|
|
2566
2172
|
state: utils.states[parsedData[index + 1].substring(0, 2)]
|
|
@@ -2597,12 +2203,12 @@ const parse = raw => {
|
|
|
2597
2203
|
: null,
|
|
2598
2204
|
lac:
|
|
2599
2205
|
parsedData[index + 2] !== '' ||
|
|
2600
|
-
|
|
2206
|
+
parsedData[index + 2].toUpperCase() === 'FFFF'
|
|
2601
2207
|
? parseInt(parsedData[index + 2], 16)
|
|
2602
2208
|
: null,
|
|
2603
2209
|
cid:
|
|
2604
2210
|
parsedData[index + 3] !== '' ||
|
|
2605
|
-
|
|
2211
|
+
parsedData[index + 3].toUpperCase() === 'FFFF'
|
|
2606
2212
|
? parseInt(parsedData[index + 3], 16)
|
|
2607
2213
|
: null,
|
|
2608
2214
|
rxLevel:
|
|
@@ -2631,12 +2237,12 @@ const parse = raw => {
|
|
|
2631
2237
|
: null,
|
|
2632
2238
|
lac:
|
|
2633
2239
|
parsedData[index + 2] !== '' ||
|
|
2634
|
-
|
|
2240
|
+
parsedData[index + 2].toUpperCase() === 'FFFF'
|
|
2635
2241
|
? parseInt(parsedData[index + 2], 16)
|
|
2636
2242
|
: null,
|
|
2637
2243
|
cid:
|
|
2638
2244
|
parsedData[index + 3] !== '' ||
|
|
2639
|
-
|
|
2245
|
+
parsedData[index + 3].toUpperCase() === 'FFFF'
|
|
2640
2246
|
? parseInt(parsedData[index + 3], 16)
|
|
2641
2247
|
: null,
|
|
2642
2248
|
rxLevel:
|
|
@@ -2741,7 +2347,7 @@ const parse = raw => {
|
|
|
2741
2347
|
azimuth: parsedData[62] !== '' ? parseFloat(parsedData[62]) : null,
|
|
2742
2348
|
altitude: parsedData[63] !== '' ? parseFloat(parsedData[63]) : null,
|
|
2743
2349
|
datetime: parsedData[66] !== '' ? utils.parseDate(parsedData[66]) : null,
|
|
2744
|
-
mcc: parsedData[67] !== '' ? utils.latamMcc[parseInt(parsedData[67], 10)] : null,
|
|
2350
|
+
mcc: parsedData[67] !== '' ? utils.latamMcc[parseInt(parsedData[67], 10)] || utils.latamMcc.default : null,
|
|
2745
2351
|
mnc: parsedData[68] !== '' ? utils.getMNC(parsedData[67], parsedData[68]) : null,
|
|
2746
2352
|
lac: parsedData[69] !== '' ? parseInt(parsedData[69], 16) : null,
|
|
2747
2353
|
cid: parsedData[70] !== '' ? parseInt(parsedData[70], 16) : null,
|
|
@@ -2755,32 +2361,32 @@ const parse = raw => {
|
|
|
2755
2361
|
sos: false,
|
|
2756
2362
|
input: {
|
|
2757
2363
|
'2':
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2364
|
+
utils.nHexDigit(
|
|
2365
|
+
utils.hex2bin(parsedData[index + 1].substring(2, 4)),
|
|
2366
|
+
8
|
|
2367
|
+
)[6] === '1',
|
|
2762
2368
|
'1':
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2369
|
+
utils.nHexDigit(
|
|
2370
|
+
utils.hex2bin(parsedData[index + 1].substring(2, 4)),
|
|
2371
|
+
8
|
|
2372
|
+
)[7] === '1'
|
|
2767
2373
|
},
|
|
2768
2374
|
output: {
|
|
2769
2375
|
'3':
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2376
|
+
utils.nHexDigit(
|
|
2377
|
+
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
2378
|
+
8
|
|
2379
|
+
)[5] === '1',
|
|
2774
2380
|
'2':
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2381
|
+
utils.nHexDigit(
|
|
2382
|
+
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
2383
|
+
8
|
|
2384
|
+
)[6] === '1',
|
|
2779
2385
|
'1':
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2386
|
+
utils.nHexDigit(
|
|
2387
|
+
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
2388
|
+
8
|
|
2389
|
+
)[7] === '1'
|
|
2784
2390
|
},
|
|
2785
2391
|
charge: null,
|
|
2786
2392
|
state: utils.states[parsedData[index + 1].substring(0, 2)]
|
|
@@ -2793,12 +2399,12 @@ const parse = raw => {
|
|
|
2793
2399
|
raw: parsedData[5] !== '' ? parsedData[5] : null,
|
|
2794
2400
|
oilLevelLowIndicator: alarmMask1 ? alarmMask1[28] === '1' : null,
|
|
2795
2401
|
serviceCallIndicator: alarmMask1 ? alarmMask1[27] === '1' : null,
|
|
2796
|
-
|
|
2402
|
+
airbagsIndicator: alarmMask1 ? alarmMask1[26] === '1' : null,
|
|
2797
2403
|
checkEngineIndicator: alarmMask1 ? alarmMask1[25] === '1' : null,
|
|
2798
2404
|
ABSFailureIndicator: alarmMask1 ? alarmMask1[23] === '1' : null,
|
|
2799
2405
|
engineHotIndicator: alarmMask1 ? alarmMask1[22] === '1' : null,
|
|
2800
2406
|
oilPressureIndicator: alarmMask1 ? alarmMask1[21] === '1' : null,
|
|
2801
|
-
|
|
2407
|
+
brakeSystemFailureIndicator: alarmMask1
|
|
2802
2408
|
? alarmMask1[20] === '1'
|
|
2803
2409
|
: null,
|
|
2804
2410
|
batteryIndicator: alarmMask1 ? alarmMask1[19] === '1' : null,
|
|
@@ -3023,14 +2629,14 @@ const parse = raw => {
|
|
|
3023
2629
|
? expansionBin[2] === '1'
|
|
3024
2630
|
: null,
|
|
3025
2631
|
batteryIndicator: expansionBin ? expansionBin[3] === '1' : null,
|
|
3026
|
-
|
|
2632
|
+
brakeSystemFailureIndicator: expansionBin
|
|
3027
2633
|
? expansionBin[4] === '1'
|
|
3028
2634
|
: null,
|
|
3029
2635
|
oilPressureIndicator: expansionBin ? expansionBin[5] === '1' : null,
|
|
3030
2636
|
engineHotIndicator: expansionBin ? expansionBin[6] === '1' : null,
|
|
3031
2637
|
ABSFailureIndicator: expansionBin ? expansionBin[7] === '1' : null,
|
|
3032
2638
|
checkEngineIndicator: expansionBin ? expansionBin[9] === '1' : null,
|
|
3033
|
-
|
|
2639
|
+
airbagsIndicator: expansionBin ? expansionBin[10] === '1' : null,
|
|
3034
2640
|
serviceCallIndicator: expansionBin
|
|
3035
2641
|
? expansionBin[11] === '1'
|
|
3036
2642
|
: null,
|
|
@@ -3077,7 +2683,7 @@ const parse = raw => {
|
|
|
3077
2683
|
battery: null,
|
|
3078
2684
|
inputCharge: null
|
|
3079
2685
|
},
|
|
3080
|
-
mcc: parsedData[15] !== '' ? utils.latamMcc[parseInt(parsedData[15], 10)] : null,
|
|
2686
|
+
mcc: parsedData[15] !== '' ? utils.latamMcc[parseInt(parsedData[15], 10)] || utils.latamMcc.default : null,
|
|
3081
2687
|
mnc: parsedData[16] !== '' ? utils.getMNC(parsedData[15], parsedData[16]) : null,
|
|
3082
2688
|
lac: parsedData[17] !== '' ? parseInt(parsedData[17], 16) : null,
|
|
3083
2689
|
cid: parsedData[18] !== '' ? parseInt(parsedData[18], 16) : null,
|
|
@@ -3126,7 +2732,7 @@ const parse = raw => {
|
|
|
3126
2732
|
battery: null,
|
|
3127
2733
|
inputCharge: null
|
|
3128
2734
|
},
|
|
3129
|
-
mcc: parsedData[20] !== '' ? utils.latamMcc[parseInt(parsedData[20], 10)] : null,
|
|
2735
|
+
mcc: parsedData[20] !== '' ? utils.latamMcc[parseInt(parsedData[20], 10)] || utils.latamMcc.default : null,
|
|
3130
2736
|
mnc: parsedData[21] !== '' ? utils.getMNC(parsedData[20], parsedData[21]) : null,
|
|
3131
2737
|
lac: parsedData[22] !== '' ? parseInt(parsedData[22], 16) : null,
|
|
3132
2738
|
cid: parsedData[23] !== '' ? parseInt(parsedData[23], 16) : null,
|
|
@@ -3140,32 +2746,32 @@ const parse = raw => {
|
|
|
3140
2746
|
sos: false,
|
|
3141
2747
|
input: {
|
|
3142
2748
|
'2':
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
2749
|
+
utils.nHexDigit(
|
|
2750
|
+
utils.hex2bin(parsedData[index + 1].substring(2, 4)),
|
|
2751
|
+
8
|
|
2752
|
+
)[6] === '1',
|
|
3147
2753
|
'1':
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
2754
|
+
utils.nHexDigit(
|
|
2755
|
+
utils.hex2bin(parsedData[index + 1].substring(2, 4)),
|
|
2756
|
+
8
|
|
2757
|
+
)[7] === '1'
|
|
3152
2758
|
},
|
|
3153
2759
|
output: {
|
|
3154
2760
|
'3':
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
2761
|
+
utils.nHexDigit(
|
|
2762
|
+
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
2763
|
+
8
|
|
2764
|
+
)[5] === '1',
|
|
3159
2765
|
'2':
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
2766
|
+
utils.nHexDigit(
|
|
2767
|
+
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
2768
|
+
8
|
|
2769
|
+
)[6] === '1',
|
|
3164
2770
|
'1':
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
2771
|
+
utils.nHexDigit(
|
|
2772
|
+
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
2773
|
+
8
|
|
2774
|
+
)[7] === '1'
|
|
3169
2775
|
},
|
|
3170
2776
|
charge: null,
|
|
3171
2777
|
state: utils.states[parsedData[index + 1].substring(0, 2)]
|
|
@@ -3232,7 +2838,7 @@ const parse = raw => {
|
|
|
3232
2838
|
battery: null,
|
|
3233
2839
|
inputCharge: null
|
|
3234
2840
|
},
|
|
3235
|
-
mcc: parsedData[14] !== '' ? utils.latamMcc[parseInt(parsedData[14], 10)] : null,
|
|
2841
|
+
mcc: parsedData[14] !== '' ? utils.latamMcc[parseInt(parsedData[14], 10)] || utils.latamMcc.default : null,
|
|
3236
2842
|
mnc: parsedData[15] !== '' ? utils.getMNC(parsedData[14], parsedData[15]) : null,
|
|
3237
2843
|
lac: parsedData[16] !== '' ? parseInt(parsedData[16], 16) : null,
|
|
3238
2844
|
cid: parsedData[17] !== '' ? parseInt(parsedData[17], 16) : null,
|
|
@@ -3246,32 +2852,32 @@ const parse = raw => {
|
|
|
3246
2852
|
sos: false,
|
|
3247
2853
|
input: {
|
|
3248
2854
|
'2':
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
2855
|
+
utils.nHexDigit(
|
|
2856
|
+
utils.hex2bin(parsedData[index + 1].substring(2, 4)),
|
|
2857
|
+
8
|
|
2858
|
+
)[6] === '1',
|
|
3253
2859
|
'1':
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
2860
|
+
utils.nHexDigit(
|
|
2861
|
+
utils.hex2bin(parsedData[index + 1].substring(2, 4)),
|
|
2862
|
+
8
|
|
2863
|
+
)[7] === '1'
|
|
3258
2864
|
},
|
|
3259
2865
|
output: {
|
|
3260
2866
|
'3':
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
2867
|
+
utils.nHexDigit(
|
|
2868
|
+
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
2869
|
+
8
|
|
2870
|
+
)[5] === '1',
|
|
3265
2871
|
'2':
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
2872
|
+
utils.nHexDigit(
|
|
2873
|
+
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
2874
|
+
8
|
|
2875
|
+
)[6] === '1',
|
|
3270
2876
|
'1':
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
2877
|
+
utils.nHexDigit(
|
|
2878
|
+
utils.hex2bin(parsedData[index + 1].substring(4, 6)),
|
|
2879
|
+
8
|
|
2880
|
+
)[7] === '1'
|
|
3275
2881
|
},
|
|
3276
2882
|
charge: null,
|
|
3277
2883
|
state: utils.states[parsedData[index + 1].substring(0, 2)]
|