aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-12-02 21:17:50 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2014-12-02 21:17:50 +1300
commit3ccb5c95e3b4483b9eeb7039119afbf9bd0617b8 (patch)
treeadf36e7e9f9247b276f0423754a4a120af1be260
parent146508be837b4c89eac752ef54c6902d017c3bd8 (diff)
downloadtrackermap-server-3ccb5c95e3b4483b9eeb7039119afbf9bd0617b8.tar.gz
trackermap-server-3ccb5c95e3b4483b9eeb7039119afbf9bd0617b8.tar.bz2
trackermap-server-3ccb5c95e3b4483b9eeb7039119afbf9bd0617b8.zip
Fix Gator id decoding
-rw-r--r--src/org/traccar/protocol/GatorProtocolDecoder.java7
-rw-r--r--test/org/traccar/protocol/GatorProtocolDecoderTest.java3
2 files changed, 8 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/GatorProtocolDecoder.java b/src/org/traccar/protocol/GatorProtocolDecoder.java
index 9fb74dacc..5bc205214 100644
--- a/src/org/traccar/protocol/GatorProtocolDecoder.java
+++ b/src/org/traccar/protocol/GatorProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2013 - 2014 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,7 +60,10 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedShort(); // length
// Pseudo IP address
- String id = String.valueOf(buf.readUnsignedInt());
+ String id = String.format("%02d%02d%02d%02d",
+ buf.readUnsignedByte(), buf.readUnsignedByte(),
+ buf.readUnsignedByte(), buf.readUnsignedByte());
+ id = id.replaceFirst("^0+(?!$)", "");
if (type == PACKET_POSITION_DATA ||
type == PACKET_ROLLCALL_RESPONSE ||
diff --git a/test/org/traccar/protocol/GatorProtocolDecoderTest.java b/test/org/traccar/protocol/GatorProtocolDecoderTest.java
index 6668d41ce..75c2847ca 100644
--- a/test/org/traccar/protocol/GatorProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/GatorProtocolDecoderTest.java
@@ -12,6 +12,9 @@ public class GatorProtocolDecoderTest {
public void testDecode() throws Exception {
GatorProtocolDecoder decoder = new GatorProtocolDecoder(new TestDataManager(), null, null);
+
+ verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(
+ new int[] {0x24,0x24,0x80,0x00,0x26,0x00,0x09,0x63,0x2d,0x14,0x11,0x21,0x07,0x27,0x02,0x05,0x92,0x26,0x18,0x01,0x04,0x36,0x75,0x00,0x00,0x00,0x00,0xc0,0x47,0x00,0x07,0x9c,0x0c,0x34,0x00,0x0a,0xd8,0x0b,0x00,0xff,0x00,0x0a,0x0d}))));
verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(
new int[] {0x24,0x24,0x81,0x00,0x23,0x0C,0xA2,0x32,0x85,0x10,0x03,0x06,0x14,0x59,0x07,0x02,0x23,0x46,0x90,0x11,0x35,0x29,0x47,0x00,0x00,0x00,0x00,0xC0,0x40,0x01,0x01,0x2C,0x0E,0x11,0x00,0x00,0x00,0x21,0xCB,0x0D}))));