aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-09-21 16:06:34 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-09-21 16:06:34 +1200
commit902135f2821c86f650ef13dbfe27ae6ef00ece61 (patch)
treed4b9f7874d39b387837d78b280bfa7aaf84c9a8c
parent41822317fef73a66c6d436da5a8f0e0a83eaca8e (diff)
downloadtrackermap-server-902135f2821c86f650ef13dbfe27ae6ef00ece61.tar.gz
trackermap-server-902135f2821c86f650ef13dbfe27ae6ef00ece61.tar.bz2
trackermap-server-902135f2821c86f650ef13dbfe27ae6ef00ece61.zip
Update Milesmate protocol
-rw-r--r--src/org/traccar/protocol/MilesmateProtocolDecoder.java21
-rw-r--r--test/org/traccar/protocol/MilesmateProtocolDecoderTest.java3
2 files changed, 13 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/MilesmateProtocolDecoder.java b/src/org/traccar/protocol/MilesmateProtocolDecoder.java
index 7240ad9fc..62d81e5a1 100644
--- a/src/org/traccar/protocol/MilesmateProtocolDecoder.java
+++ b/src/org/traccar/protocol/MilesmateProtocolDecoder.java
@@ -19,7 +19,6 @@ import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
-import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -46,8 +45,8 @@ public class MilesmateProtocolDecoder extends BaseProtocolDecoder {
.number("G:(d+.d+),") // speed
.number("H:(dd)(dd)(dd),") // date (ddmmyy)
.expression("I:[GL],") // location source
- .number("J:([01]{8}),") // flags
- .number("K:([01]{7})") // flags
+ .number("J:(d{8}),") // flags
+ .number("K:(d{7})") // flags
.expression("([AV]),") // validity
.number("L:d{4},") // pin
.number("M:(d+.d+)") // course
@@ -88,15 +87,15 @@ public class MilesmateProtocolDecoder extends BaseProtocolDecoder {
dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
position.setTime(dateBuilder.getDate());
- int flags = parser.nextBinInt();
- position.set(Position.KEY_IGNITION, BitUtil.check(flags, 8 - 1));
- position.set(Position.KEY_ALARM, BitUtil.check(flags, 8 - 2) ? Position.ALARM_SOS : null);
- position.set(Position.KEY_CHARGE, BitUtil.check(flags, 8 - 6));
- position.set(Position.KEY_ALARM, BitUtil.check(flags, 8 - 8) ? Position.ALARM_OVERSPEED : null);
+ String flags = parser.next();
+ position.set(Position.KEY_IGNITION, flags.charAt(0) == '1');
+ position.set(Position.KEY_ALARM, flags.charAt(1) == '1' ? Position.ALARM_SOS : null);
+ position.set(Position.KEY_CHARGE, flags.charAt(5) == '1');
+ position.set(Position.KEY_ALARM, flags.charAt(7) == '1' ? Position.ALARM_OVERSPEED : null);
- flags = parser.nextBinInt() << 1;
- position.set(Position.KEY_BLOCKED, BitUtil.check(flags, 8 - 1));
- position.set(Position.KEY_ALARM, BitUtil.check(flags, 8 - 2) ? Position.ALARM_TOW : null);
+ flags = parser.next();
+ position.set(Position.KEY_BLOCKED, flags.charAt(0) == '1');
+ position.set(Position.KEY_ALARM, flags.charAt(1) == '1' ? Position.ALARM_TOW : null);
position.setValid(parser.next().equals("A"));
diff --git a/test/org/traccar/protocol/MilesmateProtocolDecoderTest.java b/test/org/traccar/protocol/MilesmateProtocolDecoderTest.java
index 400c3d9bf..c5c749a04 100644
--- a/test/org/traccar/protocol/MilesmateProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/MilesmateProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class MilesmateProtocolDecoderTest extends ProtocolTest {
MilesmateProtocolDecoder decoder = new MilesmateProtocolDecoder(new MilesmateProtocol());
verifyPosition(decoder, text(
+ "ApiString={A:861359037373030,B:09.8,C:00.0,D:083506,E:2838.5529N,F:07717.8049E,G:000.00,H:170918,I:G,J:00004100,K:0000000A,L:1234,M:126.86}"));
+
+ verifyPosition(decoder, text(
"ApiString={A:861359037496211,B:12.7,C:06.0,D:060218,E:2837.1003N,F:07723.3162E,G:016.80,H:310818,I:G,J:10010100,K:0000000A,L:1234,M:358.33}"),
position("2018-08-31 06:02:18.000", true, 28.61834, 77.38860));