From b9b2217b2acd3d3e0a202ea0be59bb88e45a4da8 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 27 Mar 2018 07:15:36 +1300 Subject: Fix EGTS decoding issues --- src/org/traccar/protocol/EgtsProtocolDecoder.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/protocol/EgtsProtocolDecoder.java b/src/org/traccar/protocol/EgtsProtocolDecoder.java index fe82a51ed..e13f18fed 100644 --- a/src/org/traccar/protocol/EgtsProtocolDecoder.java +++ b/src/org/traccar/protocol/EgtsProtocolDecoder.java @@ -162,10 +162,12 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedShort(); // home dispatcher identifier } if (BitUtil.check(flags, 1)) { - getDeviceSession(channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.US_ASCII)); + getDeviceSession( + channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.US_ASCII).trim()); } if (BitUtil.check(flags, 2)) { - getDeviceSession(channel, remoteAddress, buf.readBytes(16).toString(StandardCharsets.US_ASCII)); + getDeviceSession( + channel, remoteAddress, buf.readBytes(16).toString(StandardCharsets.US_ASCII).trim()); } if (BitUtil.check(flags, 3)) { buf.skipBytes(3); // language identifier @@ -177,7 +179,8 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedShort(); // buffer size } if (BitUtil.check(flags, 7)) { - getDeviceSession(channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.US_ASCII)); + getDeviceSession( + channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.US_ASCII).trim()); } response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0); @@ -241,7 +244,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { buf.readerIndex(end); } - if (deviceSession != null) { + if (serviceType == SERVICE_TELEDATA && deviceSession != null) { positions.add(position); } } -- cgit v1.2.3