aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-11-11 21:15:03 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2021-11-11 21:15:03 -0800
commit148b251ff1c129b4b8c8038a47e1dc55a05e6f5d (patch)
tree5ea6a2bdca7554c93e14f520f00820a9a17a809a /src
parentee709450564299831dc90e648f6f11bb9e19b6d0 (diff)
downloadtraccar-server-148b251ff1c129b4b8c8038a47e1dc55a05e6f5d.tar.gz
traccar-server-148b251ff1c129b4b8c8038a47e1dc55a05e6f5d.tar.bz2
traccar-server-148b251ff1c129b4b8c8038a47e1dc55a05e6f5d.zip
New protocol variation
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java108
-rw-r--r--src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java3
2 files changed, 68 insertions, 43 deletions
diff --git a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
index 9b12f1c15..5eab10498 100644
--- a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2021 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,15 +68,23 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
.number("(d+),") // runtime
.number("(d+)|") // mcc
.number("(d+)|") // mnc
- .number("(x+)|") // lac
- .number("(x+),") // cid
+ .number("(x+)?|") // lac
+ .number("(x+)?,") // cid
.number("(xx)") // input
.number("(xx),") // output
+ .groupBegin()
+ .number("(d+.d+)|") // battery
+ .number("(d+.d+)|") // power
+ .number("d+.d+|") // rtc voltage
+ .number("d+.d+|") // mcu voltage
+ .number("d+.d+,") // gps voltage
+ .or()
.number("(x+)?|") // adc1
.number("(x+)?|") // adc2
.number("(x+)?|") // adc3
.number("(x+)|") // battery
.number("(x+)?,") // power
+ .groupEnd()
.groupBegin()
.expression("([^,]+)?,").optional() // event specific
.expression("[^,]*,") // reserved
@@ -174,51 +182,65 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, parser.nextInt());
position.set("runtime", parser.next());
- position.setNetwork(new Network(CellTower.from(
- parser.nextInt(), parser.nextInt(), parser.nextHexInt(), parser.nextHexInt(), rssi)));
+ int mcc = parser.nextInt();
+ int mnc = parser.nextInt();
+ int lac = parser.nextHexInt(0);
+ int cid = parser.nextHexInt(0);
+ if (mcc != 0 && mnc != 0) {
+ position.setNetwork(new Network(CellTower.from(mcc, mnc, lac, cid, rssi)));
+ }
position.set(Position.KEY_INPUT, parser.nextHexInt());
position.set(Position.KEY_OUTPUT, parser.nextHexInt());
- for (int i = 1; i <= 3; i++) {
- position.set(Position.PREFIX_ADC + i, parser.nextHexInt());
- }
+ if (parser.hasNext(2)) {
+
+ position.set(Position.KEY_BATTERY, parser.nextDouble());
+ position.set(Position.KEY_POWER, parser.nextDouble());
+
+ } else {
+
+ for (int i = 1; i <= 3; i++) {
+ position.set(Position.PREFIX_ADC + i, parser.nextHexInt());
+ }
+
+ String deviceModel = Context.getIdentityManager().getById(deviceSession.getDeviceId()).getModel();
+ if (deviceModel == null) {
+ deviceModel = "";
+ }
+ switch (deviceModel.toUpperCase()) {
+ case "MVT340":
+ case "MVT380":
+ position.set(Position.KEY_BATTERY, parser.nextHexInt(0) * 3.0 * 2.0 / 1024.0);
+ position.set(Position.KEY_POWER, parser.nextHexInt(0) * 3.0 * 16.0 / 1024.0);
+ break;
+ case "MT90":
+ position.set(Position.KEY_BATTERY, parser.nextHexInt(0) * 3.3 * 2.0 / 4096.0);
+ position.set(Position.KEY_POWER, parser.nextHexInt(0));
+ break;
+ case "T1":
+ case "T3":
+ case "MVT100":
+ case "MVT600":
+ case "MVT800":
+ case "TC68":
+ case "TC68S":
+ position.set(Position.KEY_BATTERY, parser.nextHexInt(0) * 3.3 * 2.0 / 4096.0);
+ position.set(Position.KEY_POWER, parser.nextHexInt(0) * 3.3 * 16.0 / 4096.0);
+ break;
+ case "T311":
+ case "T322X":
+ case "T333":
+ case "T355":
+ position.set(Position.KEY_BATTERY, parser.nextHexInt(0) / 100.0);
+ position.set(Position.KEY_POWER, parser.nextHexInt(0) / 100.0);
+ break;
+ default:
+ position.set(Position.KEY_BATTERY, parser.nextHexInt(0));
+ position.set(Position.KEY_POWER, parser.nextHexInt(0));
+ break;
+ }
- String deviceModel = Context.getIdentityManager().getById(deviceSession.getDeviceId()).getModel();
- if (deviceModel == null) {
- deviceModel = "";
- }
- switch (deviceModel.toUpperCase()) {
- case "MVT340":
- case "MVT380":
- position.set(Position.KEY_BATTERY, parser.nextHexInt(0) * 3.0 * 2.0 / 1024.0);
- position.set(Position.KEY_POWER, parser.nextHexInt(0) * 3.0 * 16.0 / 1024.0);
- break;
- case "MT90":
- position.set(Position.KEY_BATTERY, parser.nextHexInt(0) * 3.3 * 2.0 / 4096.0);
- position.set(Position.KEY_POWER, parser.nextHexInt(0));
- break;
- case "T1":
- case "T3":
- case "MVT100":
- case "MVT600":
- case "MVT800":
- case "TC68":
- case "TC68S":
- position.set(Position.KEY_BATTERY, parser.nextHexInt(0) * 3.3 * 2.0 / 4096.0);
- position.set(Position.KEY_POWER, parser.nextHexInt(0) * 3.3 * 16.0 / 4096.0);
- break;
- case "T311":
- case "T322X":
- case "T333":
- case "T355":
- position.set(Position.KEY_BATTERY, parser.nextHexInt(0) / 100.0);
- position.set(Position.KEY_POWER, parser.nextHexInt(0) / 100.0);
- break;
- default:
- position.set(Position.KEY_BATTERY, parser.nextHexInt(0));
- position.set(Position.KEY_POWER, parser.nextHexInt(0));
- break;
}
String eventData = parser.next();
diff --git a/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java
index 3f0e5b2d3..58861c139 100644
--- a/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class MeitrackProtocolDecoderTest extends ProtocolTest {
var decoder = new MeitrackProtocolDecoder(null);
+ verifyPosition(decoder, buffer(
+ "$$D149,867047043162018,AAA,35,-1.264865,36.800705,211001105240,A,9,20,41.0,323,1,1697,1,0,000|00||,0000,4.33|12.96|1.92|2.72|2.69,0.000000|0|0.000000,*E1"));
+
verifyPositions(decoder, binary(
"2424413132332c3836313538353034333230303836322c4343452c010000000100590015000305010609071b0b081c000939010a07000b1700199e011a9505921a0099c4089c5500c93e00405a000602a8b114000343f12e0604d18806270c654a2e000da20537009bb8963904010e0c0d020300aa7a0af69e0100002a35340d0a"));