diff options
Diffstat (limited to 'src/org/traccar/protocol')
4 files changed, 19 insertions, 26 deletions
diff --git a/src/org/traccar/protocol/BceProtocolDecoder.java b/src/org/traccar/protocol/BceProtocolDecoder.java index 2f96ab317..ac8e257e3 100644 --- a/src/org/traccar/protocol/BceProtocolDecoder.java +++ b/src/org/traccar/protocol/BceProtocolDecoder.java @@ -136,7 +136,7 @@ public class BceProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); } - if (position.getValid() != null) { + if (checkBit(mask, 0)) { positions.add(position); } } diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java index 99b745175..e30eaf914 100644 --- a/src/org/traccar/protocol/GalileoProtocolDecoder.java +++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java @@ -90,6 +90,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { List<Position> positions = new LinkedList<Position>(); Set<Integer> tags = new HashSet<Integer>(); + boolean hasLocation = false; Position position = new Position(); ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); @@ -99,8 +100,11 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { int tag = buf.readUnsignedByte(); if (tags.contains(tag)) { position.setExtendedInfo(extendedInfo.toString()); - positions.add(position); + if (hasLocation && position.getFixTime() != null) { + positions.add(position); + } tags.clear(); + hasLocation = false; position = new Position(); extendedInfo = new ExtendedInfoFormatter(getProtocol()); } @@ -119,6 +123,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { break; case TAG_COORDINATES: + hasLocation = true; position.setValid((buf.readUnsignedByte() & 0xf0) == 0x00); position.setLatitude(buf.readInt() / 1000000.0); position.setLongitude(buf.readInt() / 1000000.0); @@ -157,7 +162,9 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { } position.setExtendedInfo(extendedInfo.toString()); - positions.add(position); + if (hasLocation && position.getFixTime() != null) { + positions.add(position); + } if (!hasDeviceId()) { Log.warning("Unknown device"); @@ -166,18 +173,8 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { sendReply(channel, buf.readUnsignedShort()); - for (Iterator<Position> i = positions.iterator(); i.hasNext(); ) { - Position p = i.next(); - + for (Position p : positions) { p.setDeviceId(getDeviceId()); - - if (p.getAltitude() == null) { - p.setAltitude(0.0); - } - - if (p.getValid() == null || p.getTime() == null || p.getSpeed() == null) { - i.remove(); - } } if (positions.isEmpty()) { diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java index 8a5afc17f..7ac0dccdf 100644 --- a/src/org/traccar/protocol/NavisProtocolDecoder.java +++ b/src/org/traccar/protocol/NavisProtocolDecoder.java @@ -20,7 +20,6 @@ import java.nio.charset.Charset; import java.util.Calendar; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -29,8 +28,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; @@ -64,8 +61,8 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { } private class ParseResult { - private long id; - private Position position; + private final long id; + private final Position position; public ParseResult(long id, Position position) { this.id = id; @@ -226,7 +223,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { sendReply(channel, response); // No location data - if (result.getPosition().getValid() == null) { + if (result.getPosition().getFixTime() == null) { return null; } @@ -239,7 +236,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { for (int i = 0; i < count; i++) { Position position = parsePosition(buf).getPosition(); - if (position.getValid() != null) { + if (position.getFixTime() != null) { positions.add(position); } } diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java index 9ad590ad4..0872f6238 100644 --- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java +++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java @@ -19,14 +19,11 @@ import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.ChannelBufferTools; -import org.traccar.helper.Log; import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; import java.util.Date; -import java.util.Properties; public class UlbotechProtocolDecoder extends BaseProtocolDecoder { @@ -72,6 +69,8 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { long seconds = buf.readUnsignedInt() & 0x7fffffffl; seconds += 946684800l; // 2000-01-01 00:00 position.setTime(new Date(seconds * 1000)); + + boolean hasLocation = false; while (buf.readableBytes() > 3) { @@ -81,10 +80,10 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { switch (type) { case DATA_GPS: + hasLocation = true; position.setValid(true); position.setLatitude(buf.readInt() / 1000000.0); position.setLongitude(buf.readInt() / 1000000.0); - position.setAltitude(0.0); position.setSpeed(buf.readUnsignedShort() * 0.539957); position.setCourse((double) buf.readUnsignedShort()); extendedInfo.set("hdop", buf.readUnsignedShort()); @@ -98,7 +97,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { position.setExtendedInfo(extendedInfo.toString()); - if (position.getValid() != null) { + if (hasLocation) { return position; } return null; |