aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/GatorProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-01-18 19:07:39 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2014-01-18 19:07:39 +1300
commitba4af96c2b771e3984887de0a4d2d7338aed1270 (patch)
tree1a44ff7bd7d8292d67986b7c51aa1b50504050d1 /src/org/traccar/protocol/GatorProtocolDecoder.java
parent0f0bcf8bf31723e67d703d8ea67e40a921536d9a (diff)
downloadtrackermap-server-ba4af96c2b771e3984887de0a4d2d7338aed1270.tar.gz
trackermap-server-ba4af96c2b771e3984887de0a4d2d7338aed1270.tar.bz2
trackermap-server-ba4af96c2b771e3984887de0a4d2d7338aed1270.zip
Implement KHD protocol
Diffstat (limited to 'src/org/traccar/protocol/GatorProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/GatorProtocolDecoder.java22
1 files changed, 2 insertions, 20 deletions
diff --git a/src/org/traccar/protocol/GatorProtocolDecoder.java b/src/org/traccar/protocol/GatorProtocolDecoder.java
index 041e44588..b2baf455a 100644
--- a/src/org/traccar/protocol/GatorProtocolDecoder.java
+++ b/src/org/traccar/protocol/GatorProtocolDecoder.java
@@ -45,24 +45,6 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder {
private static final int PACKET_CAMERA_RESPONSE = 0x56;
private static final int PACKET_PICTURE_DATA = 0x57;
- private double readCoordinate(ChannelBuffer buf) {
- int b1 = buf.readUnsignedByte();
- int b2 = buf.readUnsignedByte();
- int b3 = buf.readUnsignedByte();
- int b4 = buf.readUnsignedByte();
-
- double value = (b2 & 0xf) * 10 + (b3 >> 4);
- value += (((b3 & 0xf) * 10 + (b4 >> 4)) * 10 + (b4 & 0xf)) / 1000.0;
- value /= 60;
- value += ((b1 >> 4 & 0x7) * 10 + (b1 & 0xf)) * 10 + (b2 >> 4);
-
- if ((b1 & 0x80) != 0) {
- value = -value;
- }
-
- return value;
- }
-
@Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, Object msg)
@@ -105,8 +87,8 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder {
position.setTime(time.getTime());
// Location
- position.setLatitude(readCoordinate(buf));
- position.setLongitude(readCoordinate(buf));
+ position.setLatitude(ChannelBufferTools.readCoordinate(buf));
+ position.setLongitude(ChannelBufferTools.readCoordinate(buf));
position.setSpeed(ChannelBufferTools.readHexInteger(buf, 4) * 0.539957);
position.setCourse((double) ChannelBufferTools.readHexInteger(buf, 4));
position.setAltitude(0.0);