aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-02-05 23:06:06 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-02-05 23:06:06 +1300
commit5a11de47a894bc27dc7c52c0befa10a5011c400b (patch)
tree55affa1a8f6dcf71c4853a4892b5b85718d13653 /src
parent652c9ee29e9802c50db6defd75c05b1c5e0d0b3a (diff)
downloadtraccar-server-5a11de47a894bc27dc7c52c0befa10a5011c400b.tar.gz
traccar-server-5a11de47a894bc27dc7c52c0befa10a5011c400b.tar.bz2
traccar-server-5a11de47a894bc27dc7c52c0befa10a5011c400b.zip
Fix Navigil protocol decoder
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/NavigilFrameDecoder.java3
-rw-r--r--src/org/traccar/protocol/NavigilProtocolDecoder.java29
2 files changed, 17 insertions, 15 deletions
diff --git a/src/org/traccar/protocol/NavigilFrameDecoder.java b/src/org/traccar/protocol/NavigilFrameDecoder.java
index f806e138f..48328b2e5 100644
--- a/src/org/traccar/protocol/NavigilFrameDecoder.java
+++ b/src/org/traccar/protocol/NavigilFrameDecoder.java
@@ -47,8 +47,9 @@ public class NavigilFrameDecoder extends FrameDecoder {
if (buf.readableBytes() >= length) {
if (hasPreamble) {
buf.readUnsignedInt();
+ length -= 4;
}
- return buf.readBytes(length - 4);
+ return buf.readBytes(length);
}
return null;
diff --git a/src/org/traccar/protocol/NavigilProtocolDecoder.java b/src/org/traccar/protocol/NavigilProtocolDecoder.java
index 49e099523..3e116486f 100644
--- a/src/org/traccar/protocol/NavigilProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavigilProtocolDecoder.java
@@ -52,7 +52,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
private static final int MESSAGE_ACKNOWLEDGEMENT = 255;
private static Date convertTimestamp(long timestamp) {
- return new Date(timestamp - LEAP_SECONDS_DELTA);
+ return new Date((timestamp - LEAP_SECONDS_DELTA) * 1000l);
}
private int senderSequenceNumber = 1;
@@ -88,8 +88,8 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedShort(); // report trigger
buf.readUnsignedShort(); // flags
- position.setLatitude(buf.readUnsignedInt() * 0.0000001);
- position.setLongitude(buf.readUnsignedInt() * 0.0000001);
+ position.setLatitude(buf.readInt() * 0.0000001);
+ position.setLongitude(buf.readInt() * 0.0000001);
position.setAltitude((double) buf.readUnsignedShort());
buf.readUnsignedShort(); // satellites in fix
@@ -128,8 +128,8 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
position.setTime(convertTimestamp(buf.readUnsignedInt()));
- position.setLatitude(buf.readUnsignedInt() * 0.0000001);
- position.setLongitude(buf.readUnsignedInt() * 0.0000001);
+ position.setLatitude(buf.readInt() * 0.0000001);
+ position.setLongitude(buf.readInt() * 0.0000001);
position.setAltitude((double) buf.readUnsignedShort());
buf.readUnsignedByte(); // satellites in fix
@@ -161,8 +161,8 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceId);
position.setTime(convertTimestamp(timestamp));
- position.setLatitude(buf.readUnsignedMedium() * 0.00002);
- position.setLongitude(buf.readUnsignedMedium() * 0.00002);
+ position.setLatitude(buf.readMedium() * 0.00002);
+ position.setLongitude(buf.readMedium() * 0.00002);
position.setAltitude(0.0);
position.setSpeed(buf.readUnsignedByte() * 0.539957);
@@ -185,8 +185,8 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceId);
position.setTime(convertTimestamp(timestamp));
- position.setLatitude(buf.readUnsignedInt() * 0.0000001);
- position.setLongitude(buf.readUnsignedInt() * 0.0000001);
+ position.setLatitude(buf.readInt() * 0.0000001);
+ position.setLongitude(buf.readInt() * 0.0000001);
position.setAltitude(0.0);
buf.readUnsignedByte(); // report trigger
@@ -197,7 +197,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
short flags = buf.readUnsignedByte();
position.setValid((flags & 0x80) == 0x80 && (flags & 0x40) == 0x40);
- buf.readUnsignedByte(); // satellites in fix
+ int x = buf.readUnsignedByte(); // satellites in fix
buf.readUnsignedInt(); // distance
position.setExtendedInfo(extendedInfo.toString());
@@ -221,8 +221,8 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
position.setTime(convertTimestamp(buf.readUnsignedInt()));
- position.setLatitude(buf.readUnsignedInt() * 0.0000001);
- position.setLongitude(buf.readUnsignedInt() * 0.0000001);
+ position.setLatitude(buf.readInt() * 0.0000001);
+ position.setLongitude(buf.readInt() * 0.0000001);
position.setAltitude((double) buf.readUnsignedShort());
buf.readUnsignedByte(); // satellites in fix
@@ -260,8 +260,8 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedShort(); // duration
- position.setLatitude(buf.readUnsignedInt() * 0.0000001);
- position.setLongitude(buf.readUnsignedInt() * 0.0000001);
+ position.setLatitude(buf.readInt() * 0.0000001);
+ position.setLongitude(buf.readInt() * 0.0000001);
position.setAltitude(0.0);
position.setSpeed(buf.readUnsignedByte() * 0.539957);
@@ -287,6 +287,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // version id
int sequenceNumber = buf.readUnsignedShort();
int messageId = buf.readUnsignedShort();
+ buf.readUnsignedShort(); // length
int flags = buf.readUnsignedShort();
buf.readUnsignedShort(); // checksum