queclink-parser 1.9.13 → 1.9.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/gv58lau.js CHANGED
@@ -322,7 +322,6 @@ const parse = raw => {
322
322
 
323
323
  // Bluetooth Accessories
324
324
  if (bluetoothAccessory) {
325
- let btDevices = []
326
325
  let btIndex
327
326
 
328
327
  if (canData) {
@@ -331,170 +330,8 @@ const parse = raw => {
331
330
  btIndex = index + 9
332
331
  }
333
332
 
334
- let cnt = btIndex + 1
335
- let btNum = parsedData[btIndex] !== '' ? parseInt(parsedData[btIndex]) : 1
333
+ let btDevices = utils.getBleData(parsedData, btIndex)
336
334
 
337
- for (let c = 0; c < btNum; c++) {
338
- let appendMask = utils.nHexDigit(utils.hex2bin(parsedData[cnt + 4]), 16)
339
-
340
- let aNameIx = cnt + 4 + parseInt(appendMask[15])
341
- let aMacIx = aNameIx + parseInt(appendMask[14])
342
- let aStatIx = aMacIx + parseInt(appendMask[13])
343
- let aBatIx = aStatIx + parseInt(appendMask[12])
344
- let aTmpIx = aBatIx + parseInt(appendMask[11])
345
- let aHumIx = aTmpIx + parseInt(appendMask[10])
346
- let ioIx = aHumIx + parseInt(appendMask[8])
347
- let modeIx =
348
- appendMask[8] === '1' ? ioIx + 2 + parseInt(appendMask[7]) : ioIx
349
- let aEvIx = appendMask[7] === '1' ? modeIx + 1 : modeIx
350
- let pressIx = aEvIx + parseInt(appendMask[6])
351
- let timeIx = pressIx + parseInt(appendMask[5])
352
- let eTmpIx = timeIx + parseInt(appendMask[4])
353
- let magIx = eTmpIx + parseInt(appendMask[3])
354
- let aBatpIx =
355
- appendMask[3] === '1' ? magIx + 2 + parseInt(appendMask[2]) : eTmpIx
356
- let relIx = aBatpIx + parseInt(appendMask[1])
357
-
358
- btDevices.push({
359
- index: parsedData[cnt],
360
- type: utils.bluetoothAccessories[parsedData[cnt + 1]],
361
- model:
362
- parsedData[cnt + 2] !== ''
363
- ? utils.bluetoothModels[parsedData[cnt + 1]][parsedData[cnt + 2]]
364
- : utils.bluetoothAccessories[parsedData[cnt + 1]],
365
- appendMask: parsedData[cnt + 4],
366
- rawData:
367
- parsedData[cnt + 3] !== ''
368
- ? {
369
- raw: parsedData[cnt + 3],
370
- fuelLevel:
371
- `${parsedData[cnt + 1]}${parsedData[cnt + 2]}` === '10'
372
- ? parsedData[cnt + 3]
373
- : null,
374
- temperature:
375
- `${parsedData[cnt + 1]}${parsedData[cnt + 2]}` === '20'
376
- ? utils.getBtTempHumData(
377
- parsedData[cnt + 3].substring(4, 8)
378
- )
379
- : `${parsedData[cnt + 1]}${parsedData[cnt + 2]}` === '21'
380
- ? parsedData[cnt + 3] // Conversion not specified in documentation
381
- : `${parsedData[cnt + 1]}${parsedData[cnt + 2]}` ===
382
- '62'
383
- ? utils.getBtTempHumData(
384
- parsedData[cnt + 3].substring(0, 4)
385
- )
386
- : ['64', '65'].includes(
387
- `${parsedData[cnt + 1]}${parsedData[cnt + 2]}`
388
- )
389
- ? parseInt(
390
- parsedData[cnt + 3].substring(4, 8),
391
- 16
392
- ) / 100
393
- : null,
394
- humidity:
395
- `${parsedData[cnt + 1]}${parsedData[cnt + 2]}` === '20'
396
- ? utils.getBtTempHumData(
397
- parsedData[cnt + 3].substring(4, 8)
398
- )
399
- : `${parsedData[cnt + 1]}${parsedData[cnt + 2]}` === '62'
400
- ? utils.getBtTempHumData(
401
- parsedData[cnt + 3].substring(4, 8)
402
- )
403
- : ['64', '65'].includes(
404
- `${parsedData[cnt + 1]}${parsedData[cnt + 2]}`
405
- )
406
- ? parseInt(parsedData[cnt + 3].substring(0, 4), 16) /
407
- 100
408
- : null
409
- }
410
- : null,
411
- name:
412
- parsedData[aNameIx] !== '' && appendMask[15] === '1'
413
- ? parsedData[aNameIx]
414
- : null,
415
- mac:
416
- parsedData[aMacIx] !== '' && appendMask[14] === '1'
417
- ? parsedData[aMacIx]
418
- : null,
419
- status:
420
- parsedData[aStatIx] !== '' && appendMask[13] === '1'
421
- ? parseInt(parsedData[aStatIx])
422
- : null,
423
- batteryLevel:
424
- parsedData[aBatIx] !== '' && appendMask[12] === '1'
425
- ? parseInt(parsedData[aBatIx])
426
- : null,
427
- batteryPercentage:
428
- parsedData[aBatpIx] !== '' && appendMask[2] === '1'
429
- ? parseFloat(parsedData[aBatpIx])
430
- : null,
431
- accessoryData: {
432
- rawData: parsedData[cnt + 3] !== '' ? parsedData[cnt + 3] : null,
433
- temperature:
434
- parsedData[aTmpIx] !== '' && appendMask[11] === '1'
435
- ? parseInt(parsedData[aTmpIx])
436
- : null,
437
- humidity:
438
- parsedData[aHumIx] !== '' && appendMask[10] === '1'
439
- ? parseInt(parsedData[aHumIx])
440
- : null,
441
- outputStatus:
442
- parsedData[ioIx] !== '' && appendMask[8] === '1'
443
- ? parsedData[ioIx]
444
- : null,
445
- inputStatus:
446
- parsedData[ioIx + 1] !== '' && appendMask[8] === '1'
447
- ? parsedData[ioIx + 1]
448
- : null,
449
- analogInputStatus:
450
- parsedData[ioIx + 2] !== '' && appendMask[8] === '1'
451
- ? parsedData[ioIx + 2]
452
- : null,
453
- mode:
454
- parsedData[modeIx] !== '' && appendMask[7] === '1'
455
- ? parseInt(parsedData[modeIx])
456
- : null,
457
- event:
458
- parsedData[aEvIx] !== '' && appendMask[7] === '1'
459
- ? parseInt(parsedData[aEvIx])
460
- : null,
461
- tirePresure:
462
- parsedData[pressIx] !== '' && appendMask[6] === '1'
463
- ? parseInt(parsedData[pressIx])
464
- : null,
465
- timestamp:
466
- parsedData[timeIx] !== '' && appendMask[5] === '1'
467
- ? utils.parseDate(parsedData[timeIx])
468
- : null,
469
- enhancedTemperature:
470
- parsedData[eTmpIx] !== '' && appendMask[4] === '1'
471
- ? parseFloat(parsedData[eTmpIx])
472
- : null,
473
- magDevice: {
474
- id:
475
- parsedData[magIx] !== '' && appendMask[3] === '1'
476
- ? parsedData[magIx]
477
- : null,
478
- eventCounter:
479
- parsedData[magIx + 1] !== '' && appendMask[3] === '1'
480
- ? parseInt(parsedData[magIx + 1])
481
- : null,
482
- magnetState:
483
- parsedData[magIx + 2] !== '' && appendMask[3] === '1'
484
- ? parseInt(parsedData[magIx + 2])
485
- : null
486
- },
487
- relay: {
488
- state:
489
- parsedData[relIx] !== '' && appendMask[1] === '1'
490
- ? parseInt(parsedData[relIx])
491
- : null
492
- }
493
- }
494
- })
495
- cnt = appendMask[1] === '1' ? relIx + 1 : relIx + 2
496
- cnt = parsedData[cnt + 3] !== '' ? cnt - 1 : cnt
497
- }
498
335
  externalData = Object.assign(externalData, {
499
336
  btDevices: btDevices
500
337
  })
@@ -1882,26 +1719,105 @@ const parse = raw => {
1882
1719
  let aTmpIx = aBatIx + parseInt(appendMask[11])
1883
1720
  let aHumIx = aTmpIx + parseInt(appendMask[10])
1884
1721
  let ioIx = aHumIx + parseInt(appendMask[8])
1885
- let modeIx =
1886
- appendMask[8] === '1' ? ioIx + 2 + parseInt(appendMask[7]) : ioIx
1887
- let aEvIx = appendMask[7] === '1' ? modeIx + 1 : modeIx
1888
- let pressIx = aEvIx + parseInt(appendMask[6])
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])
1889
1726
  let timeIx = pressIx + parseInt(appendMask[5])
1890
1727
  let eTmpIx = timeIx + parseInt(appendMask[4])
1891
1728
  let magIx = eTmpIx + parseInt(appendMask[3])
1892
- let aBatpIx =
1893
- appendMask[3] === '1' ? magIx + 2 + parseInt(appendMask[2]) : eTmpIx
1729
+ let aBatpIx = appendMask[3] === '1' && appendMask[2] === '1'
1730
+ ? magIx + 3 : magIx + parseInt(appendMask[2])
1894
1731
  let relIx = aBatpIx + parseInt(appendMask[1])
1895
1732
 
1896
- let newIndex = appendMask[1] === '1' ? relIx + 2 : relIx + 1
1733
+ let newIndex = relIx + 1 + parseInt(appendMask[1])
1897
1734
 
1898
1735
  let satelliteInfo = utils.includeSatellites(parsedData[newIndex + 11])
1899
1736
  let includeStatus = utils.includeStatus(parsedData[newIndex + 11])
1900
1737
  let accuracyInfo = utils.includeGnnsAccuracy(parsedData[newIndex + 11]) ? 3 : 0
1901
1738
  let index = newIndex + 11 + (satelliteInfo + includeStatus + accuracyInfo)
1902
1739
 
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]) / 6.895
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
+ }
1817
+ }
1818
+
1903
1819
  data = Object.assign(data, {
1904
- alarm: utils.getAlarm(command[1], parsedData[7], 'gv58lau'),
1820
+ alarm: utils.getAlarm(command[1], parsedData[7], [parsedData[4], bleInfo.mac, bleData]),
1905
1821
  loc: {
1906
1822
  type: 'Point',
1907
1823
  coordinates: [
@@ -2019,87 +1935,8 @@ const parse = raw => {
2019
1935
  ? parsedData[aMacIx]
2020
1936
  : null
2021
1937
  },
2022
- accessoryInfo: {
2023
- accesory:
2024
- btAccessory !== '' ? utils.bluetoothAccessories[btAccessory] : null,
2025
- model: parsedData[6] !== '' ? parseInt(parsedData[6]) : null,
2026
- name:
2027
- parsedData[aNameIx] !== '' && appendMask[15] === '1'
2028
- ? parsedData[aNameIx]
2029
- : null,
2030
- role: null,
2031
- type: null,
2032
- mac:
2033
- parsedData[aMacIx] !== '' && appendMask[14] === '1'
2034
- ? parsedData[aMacIx]
2035
- : null,
2036
- status:
2037
- parsedData[aStatIx] !== '' && appendMask[13] === '1'
2038
- ? parseInt(parsedData[aStatIx])
2039
- : null,
2040
- batteryLevel:
2041
- parsedData[aBatIx] !== '' && appendMask[12] === '1'
2042
- ? parseInt(parsedData[aBatIx])
2043
- : null,
2044
- batteryPercentage:
2045
- parsedData[aBatpIx] !== '' && appendMask[2] === '1'
2046
- ? parseFloat(parsedData[aBatpIx])
2047
- : null
2048
- },
2049
- accessoryData: {
2050
- temperature:
2051
- parsedData[aTmpIx] !== '' && appendMask[11] === '1'
2052
- ? parseInt(parsedData[aTmpIx])
2053
- : null,
2054
- humidity:
2055
- parsedData[aHumIx] !== '' && appendMask[10] === '1'
2056
- ? parseInt(parsedData[aHumIx])
2057
- : null,
2058
- mode:
2059
- parsedData[modeIx] !== '' && appendMask[7] === '1'
2060
- ? parseInt(parsedData[modeIx])
2061
- : null,
2062
- event:
2063
- parsedData[aEvIx] !== '' && appendMask[7] === '1'
2064
- ? parseInt(parsedData[aEvIx])
2065
- : null,
2066
- tirePresure:
2067
- parsedData[pressIx] !== '' && appendMask[6] === '1'
2068
- ? parseInt(parsedData[pressIx])
2069
- : null,
2070
- timestamp:
2071
- parsedData[timeIx] !== '' && appendMask[5] === '1'
2072
- ? utils.parseDate(parsedData[timeIx])
2073
- : null,
2074
- enhancedTemperature:
2075
- parsedData[eTmpIx] !== '' && appendMask[4] === '1'
2076
- ? parseFloat(parsedData[eTmpIx])
2077
- : null,
2078
- magDevice: {
2079
- id:
2080
- parsedData[magIx] !== '' && appendMask[3] === '1'
2081
- ? parsedData[magIx]
2082
- : null,
2083
- eventCounter:
2084
- parsedData[magIx + 1] !== '' && appendMask[3] === '1'
2085
- ? parseInt(parsedData[magIx + 1])
2086
- : null,
2087
- magnetState:
2088
- parsedData[magIx + 2] !== '' && appendMask[3] === '1'
2089
- ? parseInt(parsedData[magIx + 2])
2090
- : null
2091
- },
2092
- relay: {
2093
- configResult:
2094
- parsedData[relIx] !== '' && appendMask[1] === '1'
2095
- ? parseInt(parsedData[relIx])
2096
- : null,
2097
- state:
2098
- parsedData[relIx + 1] !== '' && appendMask[1] === '1'
2099
- ? parseInt(parsedData[relIx + 1])
2100
- : null
2101
- }
2102
- }
1938
+ accessoryInfo: bleInfo,
1939
+ accessoryData: bleData
2103
1940
  }
2104
1941
  })
2105
1942
  } else if (command[1] === 'GTBID') {
@@ -2562,12 +2399,12 @@ const parse = raw => {
2562
2399
  raw: parsedData[5] !== '' ? parsedData[5] : null,
2563
2400
  oilLevelLowIndicator: alarmMask1 ? alarmMask1[28] === '1' : null,
2564
2401
  serviceCallIndicator: alarmMask1 ? alarmMask1[27] === '1' : null,
2565
- aribagsIndicator: alarmMask1 ? alarmMask1[26] === '1' : null,
2402
+ airbagsIndicator: alarmMask1 ? alarmMask1[26] === '1' : null,
2566
2403
  checkEngineIndicator: alarmMask1 ? alarmMask1[25] === '1' : null,
2567
2404
  ABSFailureIndicator: alarmMask1 ? alarmMask1[23] === '1' : null,
2568
2405
  engineHotIndicator: alarmMask1 ? alarmMask1[22] === '1' : null,
2569
2406
  oilPressureIndicator: alarmMask1 ? alarmMask1[21] === '1' : null,
2570
- brakeSystemaFailureIndicator: alarmMask1
2407
+ brakeSystemFailureIndicator: alarmMask1
2571
2408
  ? alarmMask1[20] === '1'
2572
2409
  : null,
2573
2410
  batteryIndicator: alarmMask1 ? alarmMask1[19] === '1' : null,
@@ -2792,14 +2629,14 @@ const parse = raw => {
2792
2629
  ? expansionBin[2] === '1'
2793
2630
  : null,
2794
2631
  batteryIndicator: expansionBin ? expansionBin[3] === '1' : null,
2795
- brakeSystemaFailureIndicator: expansionBin
2632
+ brakeSystemFailureIndicator: expansionBin
2796
2633
  ? expansionBin[4] === '1'
2797
2634
  : null,
2798
2635
  oilPressureIndicator: expansionBin ? expansionBin[5] === '1' : null,
2799
2636
  engineHotIndicator: expansionBin ? expansionBin[6] === '1' : null,
2800
2637
  ABSFailureIndicator: expansionBin ? expansionBin[7] === '1' : null,
2801
2638
  checkEngineIndicator: expansionBin ? expansionBin[9] === '1' : null,
2802
- aribagsIndicator: expansionBin ? expansionBin[10] === '1' : null,
2639
+ airbagsIndicator: expansionBin ? expansionBin[10] === '1' : null,
2803
2640
  serviceCallIndicator: expansionBin
2804
2641
  ? expansionBin[11] === '1'
2805
2642
  : null,
package/src/index.js CHANGED
@@ -309,9 +309,16 @@ const parseCommand = data => {
309
309
  mode = /on(E)?/.test(state) ? 3 : 0
310
310
  const alarmId = data.alarmId || 0
311
311
  const sensorId = data.sensorId || '0000000000000000'
312
+ const index = data.sensor_index || 2
313
+ const sensorType = utils.bleTempHumSensors[data.sensor_type]
312
314
  const minTemp = data.minTemp || 0
313
315
  const maxTemp = data.maxTemp || 0
314
- command = `AT+GTTMP=${password},${alarmId},${mode},${sensorId},,,${minTemp},${maxTemp},,,2,10,,,0,0,0,0,,,,,${serialId}$`
316
+ if (sensorType === '0') {
317
+ command = `AT+GTTMP=${password},${alarmId},${mode},${sensorId},,,${minTemp},${maxTemp},,,2,10,,,0,0,0,0,,,,,${serialId}$`
318
+ } else {
319
+ command = `AT+GTBAS=${password},${index},6,${sensorType},,${sensorId},83F,,2400,,${mode},${minTemp},${maxTemp},2,,,,,,,,0,0,0,0,,,${serialId}$`
320
+ }
321
+
315
322
  } else if (/^copiloto_temp_alarm_(on|off)(E)?$/.test(data.instruction)) {
316
323
  // AT+GTDAT=gv300w,2,,>CMD3005,60,18,0,5,-3<,0,,,,FFFF$
317
324
  // Temperature Alarm
@@ -230,23 +230,23 @@
230
230
  "GTBDS": "Accesorio bluetooth desconectado",
231
231
  "GTBAA": {
232
232
  "00": "Accesorio con batería baja",
233
- "01": "Temperatura baja",
234
- "02": "Temperatura alta",
235
- "03": "Temperatura dentro del rango configurado",
233
+ "01": "Temperatura bajo el rango definido ()",
234
+ "02": "Temperatura sobre el rango definido ()",
235
+ "03": "Regreso a temperatura dentro de rango ()",
236
236
  "04": "Botón presionado",
237
- "07": "Bajo nivel de humedad",
238
- "08": "Alto nivel de humedad",
239
- "09": "Humedad dentro del rango congigurado",
237
+ "07": "Bajo nivel de humedad ()",
238
+ "08": "Alto nivel de humedad ()",
239
+ "09": "Regreso a humedad dentro de rango ()",
240
240
  "0A": "Evento de ángulo",
241
241
  "0C": "Evento de magneto",
242
- "0E": "Presión baja en neumático",
243
- "0F": "Presión alta en neumático",
244
- "10": "Presión de neumático en el rango configurado",
242
+ "0E": "Neumático con presión baja ()",
243
+ "0F": "Neumático con presión alta ()",
244
+ "10": "Regreso a presión de neumáticos dentro de rango ()",
245
245
  "11": "No se ha detectado accesorio bluetooth",
246
246
  "12": "Se ha detectado un accesorio bluetooth",
247
247
  "13": "Puerta abierta",
248
248
  "14": "Puerta cerrada",
249
- "15": "Cambio de estado en Relé BT"
249
+ "15": "Relay bluetooth __"
250
250
  },
251
251
  "GTBID": "Se ha detectado baliza bluetooth",
252
252
  "GTLBA": {
@@ -300,7 +300,7 @@
300
300
  "GTVVS": "Config: ignición virtual",
301
301
  "GTAVS": "Config: ignición por acelerómetro",
302
302
  "GTVMS": "Config: modo de ignición",
303
- "GTBTS": "Config: protocolo bluetooth",
303
+ "GTBTS": "Config: general bluetooth",
304
304
  "GTBAS": "Config: accesorio bluetooth",
305
305
  "GTBID": "Config: baliza bluetooth",
306
306
  "GTHMC": "Config: horómetro",