diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-09-21 16:06:34 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-09-21 16:06:34 +1200 |
commit | 902135f2821c86f650ef13dbfe27ae6ef00ece61 (patch) | |
tree | d4b9f7874d39b387837d78b280bfa7aaf84c9a8c /src/org | |
parent | 41822317fef73a66c6d436da5a8f0e0a83eaca8e (diff) | |
download | traccar-server-902135f2821c86f650ef13dbfe27ae6ef00ece61.tar.gz traccar-server-902135f2821c86f650ef13dbfe27ae6ef00ece61.tar.bz2 traccar-server-902135f2821c86f650ef13dbfe27ae6ef00ece61.zip |
Update Milesmate protocol
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/MilesmateProtocolDecoder.java | 21 |
1 files changed, 10 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")); |