diff options
Diffstat (limited to 'src/org/traccar/protocol/GalileoProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/GalileoProtocolDecoder.java | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java index 3944b37de..d8a1651bb 100644 --- a/src/org/traccar/protocol/GalileoProtocolDecoder.java +++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java @@ -20,6 +20,7 @@ import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; +import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; import java.net.SocketAddress; @@ -117,7 +118,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { position.setTime(new Date(buf.readUnsignedInt() * 1000)); break; case 0x33: - position.setSpeed(buf.readUnsignedShort() * 0.0539957); + position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort() * 0.1)); position.setCourse(buf.readUnsignedShort() * 0.1); break; case 0x34: @@ -248,11 +249,10 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { boolean hasLocation = false; DeviceSession deviceSession = null; - Position position = new Position(); + Position position = new Position(getProtocolName()); while (buf.readerIndex() < length) { - // Check if new message started int tag = buf.readUnsignedByte(); if (tags.contains(tag)) { if (hasLocation && position.getFixTime() != null) { @@ -260,7 +260,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { } tags.clear(); hasLocation = false; - position = new Position(); + position = new Position(getProtocolName()); // new position starts } tags.add(tag); @@ -278,13 +278,6 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { } - if (hasLocation && position.getFixTime() != null) { - positions.add(position); - } else if (position.getAttributes().containsKey(Position.KEY_RESULT)) { - getLastLocation(position, null); - positions.add(position); - } - if (deviceSession == null) { deviceSession = getDeviceSession(channel, remoteAddress); if (deviceSession == null) { @@ -292,10 +285,17 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { } } + if (hasLocation && position.getFixTime() != null) { + positions.add(position); + } else if (position.getAttributes().containsKey(Position.KEY_RESULT)) { + position.setDeviceId(deviceSession.getDeviceId()); + getLastLocation(position, null); + positions.add(position); + } + sendReply(channel, buf.readUnsignedShort()); for (Position p : positions) { - p.setProtocol(getProtocolName()); p.setDeviceId(deviceSession.getDeviceId()); } |