From ae30beb0b049c0dc84d337adbffe68703f7d6e61 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 10 Sep 2018 16:53:41 +1200 Subject: Support Prime 07 protocol --- src/org/traccar/protocol/H02ProtocolDecoder.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index 64c45a22f..9603200ab 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -107,10 +107,18 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(getProtocolName()); + boolean longId = buf.readableBytes() == 42; + buf.readByte(); // marker - DeviceSession deviceSession = getDeviceSession( - channel, remoteAddress, ByteBufUtil.hexDump(buf.readSlice(5))); + String id; + if (longId) { + id = ByteBufUtil.hexDump(buf.readSlice(8)).substring(0, 15); + } else { + id = ByteBufUtil.hexDump(buf.readSlice(5)); + } + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id); if (deviceSession == null) { return null; } @@ -183,6 +191,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { .expression("([EW]),") .number("(d+.?d*),") // speed .number("(d+.?d*)?,") // course + .number("(?:d+,)?") // battery .number("(?:(dd)(dd)(dd))?") // date (ddmmyy) .groupBegin() .expression(",[^,]*,") -- cgit v1.2.3