aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-01-20 23:17:23 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2014-01-20 23:17:23 +1300
commita7dc44e7b2ebfd8ad70f274ce25727cc9d06118b (patch)
tree3efdf6eff1c662c107b98fb158fac76d5f20f0b8
parent2fcb2bbaa9239e8c457d2d836c17ddea89c27c3a (diff)
downloadtrackermap-server-a7dc44e7b2ebfd8ad70f274ce25727cc9d06118b.tar.gz
trackermap-server-a7dc44e7b2ebfd8ad70f274ce25727cc9d06118b.tar.bz2
trackermap-server-a7dc44e7b2ebfd8ad70f274ce25727cc9d06118b.zip
Fix Ruptela IMEI decoding
-rw-r--r--src/org/traccar/protocol/RuptelaProtocolDecoder.java4
-rw-r--r--test/org/traccar/protocol/RuptelaProtocolDecoderTest.java22
2 files changed, 7 insertions, 19 deletions
diff --git a/src/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/org/traccar/protocol/RuptelaProtocolDecoder.java
index 32bf76425..c9f8bd392 100644
--- a/src/org/traccar/protocol/RuptelaProtocolDecoder.java
+++ b/src/org/traccar/protocol/RuptelaProtocolDecoder.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.
@@ -45,7 +45,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedShort(); // data length
// Identify device
- String imei = String.valueOf(buf.readLong());
+ String imei = String.format("%015d", buf.readLong());
long deviceId;
try {
deviceId = getDataManager().getDeviceByImei(imei).getId();
diff --git a/test/org/traccar/protocol/RuptelaProtocolDecoderTest.java b/test/org/traccar/protocol/RuptelaProtocolDecoderTest.java
index bb793d6a0..ddca66aa0 100644
--- a/test/org/traccar/protocol/RuptelaProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/RuptelaProtocolDecoderTest.java
@@ -3,8 +3,8 @@ package org.traccar.protocol;
import org.traccar.helper.TestDataManager;
import org.jboss.netty.buffer.ChannelBuffers;
import static org.traccar.helper.DecoderVerifier.verify;
-import static org.junit.Assert.assertNull;
import org.junit.Test;
+import org.traccar.helper.ChannelBufferTools;
public class RuptelaProtocolDecoderTest {
@@ -14,23 +14,11 @@ public class RuptelaProtocolDecoderTest {
RuptelaProtocolDecoder decoder = new RuptelaProtocolDecoder(null);
decoder.setDataManager(new TestDataManager());
- byte[] buf1 = {0x00,0x79,0x00,0x00,0x0b,0x1a,0x2a,0x55,(byte)0x85,(byte)0xc3,0x01,0x00,0x02,0x4e,(byte)0x9c,0x03,0x69,0x00,0x00,0x0f,0x10,0x17,0x33,0x20,(byte)0x8f,(byte)0xf4,0x5e,0x07,(byte)0xb3,0x1b,0x57,0x0a,0x00,0x10,0x09,0x09,0x06,0x05,0x01,0x1b,0x1a,0x02,0x00,0x03,0x00,0x1c,0x01,(byte)0xad,0x01,0x02,0x1d,0x33,(byte)0x8e,0x16,0x00,0x00,0x02,(byte)0x96,0x00,0x00,0x60,0x1a,0x41,0x01,0x4b,(byte)0xc1,0x6d,0x00,0x4e,(byte)0x9c,0x03,(byte)0x84,0x00,0x00,0x0f,0x10,0x4f,(byte)0xdf,0x20,(byte)0x90,0x0d,0x20,0x07,0x51,0x03,(byte)0xb0,0x0a,0x00,0x13 ,0x08,0x09,0x06,0x05,0x01,0x1b,0x1a,0x02,0x00,0x03,0x00,0x1c,0x01,(byte)0xad,0x01,0x02,0x1d,0x33,(byte)0xb1,0x16,0x00,0x00,0x02,(byte)0x96,0x00,0x00,0x60,0x1a,0x41,0x01,0x4b,(byte)0xc1,(byte)0xea,0x00,0x28,(byte)0xf9};
- verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(buf1)));
+ int[] buf1 = {0x00,0x79,0x00,0x00,0x0b,0x1a,0x2a,0x55,0x85,0xc3,0x01,0x00,0x02,0x4e,0x9c,0x03,0x69,0x00,0x00,0x0f,0x10,0x17,0x33,0x20,0x8f,0xf4,0x5e,0x07,0xb3,0x1b,0x57,0x0a,0x00,0x10,0x09,0x09,0x06,0x05,0x01,0x1b,0x1a,0x02,0x00,0x03,0x00,0x1c,0x01,0xad,0x01,0x02,0x1d,0x33,0x8e,0x16,0x00,0x00,0x02,0x96,0x00,0x00,0x60,0x1a,0x41,0x01,0x4b,0xc1,0x6d,0x00,0x4e,0x9c,0x03,0x84,0x00,0x00,0x0f,0x10,0x4f,0xdf,0x20,0x90,0x0d,0x20,0x07,0x51,0x03,0xb0,0x0a,0x00,0x13 ,0x08,0x09,0x06,0x05,0x01,0x1b,0x1a,0x02,0x00,0x03,0x00,0x1c,0x01,0xad,0x01,0x02,0x1d,0x33,0xb1,0x16,0x00,0x00,0x02,0x96,0x00,0x00,0x60,0x1a,0x41,0x01,0x4b,0xc1,0xea,0x00,0x28,0xf9};
+ verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf1))));
- /*byte[] buf2 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,(byte)0xA7,0x08,0x04,0x00,0x00,0x01,0x13,(byte)0xfc,0x20,(byte)0x8d,(byte)0xff,0x00,0x0f,0x14,(byte)0xf6,0x50,0x20,(byte)0x9c,(byte)0xca,(byte)0x80,0x00,0x6f,0x00,(byte)0xd6,0x04,0x00,0x04,0x00,0x04,0x03,0x01,0x01,0x15,0x03,0x16,0x03,0x00,0x01,0x46,0x00,0x00,0x01,0x5d,0x00,0x00,0x00,0x01,0x13,(byte)0xfc,0x17,0x61,0x0b,0x00,0x0f,0x14,(byte)0xff,(byte)0xe0,0x20,(byte)0x9c,(byte)0xc5,(byte)0x80,0x00,0x6e,0x00,(byte)0xc0,0x05,0x00,0x01,0x00,0x04,0x03,0x01,0x01,0x15,0x03,0x16,0x01,0x00,0x01,0x46,0x00,0x00,0x01,0x5e,0x00,0x00,0x00,0x01,0x13,(byte)0xfc,0x28,0x49,0x45,0x00,0x0f,0x15,0x0f,0x00,0x20,(byte)0x9c,(byte)0xd2,0x00,0x00,(byte)0x95,0x01,0x08,0x04,0x00,0x00,0x00,0x04,0x03,0x01,0x01,0x15,0x00,0x16,0x03,0x00,0x01,0x46,0x00,0x00,0x01,0x5d,0x00,0x00,0x00,0x01,0x13,(byte)0xfc,0x26,0x7c,0x5b,0x00,0x0f,0x15,0x0a,0x50,0x20,(byte)0x9c,(byte)0xcc,(byte)0xc0,0x00,(byte)0x93,0x00,0x68,0x04,0x00,0x00,0x00,0x04,0x03,0x01,0x01,0x15,0x00,0x16,0x03,0x00,0x01,0x46,0x00,0x00,0x01,0x5b,0x00,0x04,0x00,0x00};
- verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(buf2)));
-
- byte[] buf3 = {0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x47,0x08,0x06,0x00,0x00,0x01,0x3e,0x5a,0x60,(byte)0xa4,(byte)0xcb,0x00,0x3f,(byte)0xa7,(byte)0xb7,(byte)0x80,(byte)0xfc,0x42,0x45,0x18,0x00,0x42,0x00,0x00,0x0a,0x00,0x00,0x00,0x09,0x05,0x01,0x01,0x02,0x00,(byte)0xb3,0x00,(byte)0xb4,0x00,(byte)0xf0,0x00,0x03,0x42,0x68,(byte)0xa7,0x46,0x01,0x18,0x18,0x00,0x00,0x01,(byte)0xc7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x3e,0x5d,(byte)0xc8,(byte)0xba,0x28,0x00,0x3f,(byte)0xa7,(byte)0xc0,(byte)0x80,(byte)0xfc,0x42,0x46,0x04,0x00,0x01,0x00,0x00,0x05,0x00,0x00,0x00,0x09,0x05,0x01,0x01,0x02,0x00,(byte)0xb3,0x00,(byte)0xb4,0x00,(byte)0xf0,0x01,0x03,0x42,0x68,(byte)0xb4,0x46,0x00,(byte)0xef,0x18,0x00,0x00,0x01,(byte)0xc7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x3e,0x5d,(byte)0xc9,0x04,0x55,0x00,0x3f,(byte)0xa7,(byte)0xb6,0x40,(byte)0xfc,0x42,0x43,(byte)0x88,0x00,0x3a,0x00,0x00,0x07,0x00,0x00,(byte)0xf0,0x09,0x05,0x01,0x01,0x02,0x00,(byte)0xb3,0x00,(byte)0xb4,0x00,(byte)0xf0,0x00,0x03,0x42,0x68,(byte)0xdc,0x46,0x00,(byte)0xf7,0x18,0x00,0x00,0x01,(byte)0xc7,0x00,0x00,0x00,0x1d,0x00,0x00,0x00,0x01,0x3e,0x5d,(byte)0xc9,(byte)0xd3,0x68,0x00,0x3f,(byte)0xa7,(byte)0xb8,0x00,(byte)0xfc,0x42,0x44,0x30,0x00,0x49,0x00,0x00,0x04,0x00,0x00,0x00,0x09,0x05,0x01,0x01,0x02,0x00,(byte)0xb3,0x00,(byte)0xb4,0x00,(byte)0xf0,0x01,0x03,0x42,0x67,(byte)0xde,0x46,0x01,0x07,0x18,0x00,0x00,0x01,(byte)0xc7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x3e,0x5d,(byte)0xca,0x31,0x1d,0x00,0x3f,(byte)0xa7,(byte)0xb6,(byte)0x80,(byte)0xfc,0x42,0x43,(byte)0xcc,0x00,0x42,0x00,0x00,0x07,0x00,0x00,(byte)0xf0,0x09,0x05,0x01,0x01,0x02,0x00,(byte)0xb3,0x00,(byte)0xb4,0x00,(byte)0xf0,0x00,0x03,0x42,0x68,0x53,0x46,0x01,0x0b,0x18,0x00,0x00,0x01,(byte)0xc7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x3e,0x5d,(byte)0xcf,(byte)0xaf,(byte)0xe9,0x00,0x3f,(byte)0xa7,(byte)0xb6,0x00,(byte)0xfc,0x42,0x42,(byte)0xf0,0x00,0x3d,0x00,0x00,0x08,0x00,0x00,0x00,0x09,0x05,0x01,0x01,0x02,0x00,(byte)0xb3,0x00,(byte)0xb4,0x00,(byte)0xf0,0x00,0x03,0x42,0x68,0x52,0x46,0x01,0x19,0x18,0x00,0x00,0x01,(byte)0xc7,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x02,0x75};
- verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(buf3)));
-
- byte[] buf4 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x08,0x01,0x00,0x00,0x01,0x3e,(byte)0xff,(byte)0x8d,0x6f,(byte)0x98,0x00,0x17,0x32,(byte)0x95,0x00,0x21,0x11,(byte)0xf4,0x00,0x00,(byte)0x81,0x00,(byte)0xae,0x0b,0x00,0x00,0x00,0x04,0x01,0x01,0x00,0x03,0x09,0x00,0x16,0x43,0x29,(byte)0x80,0x42,0x2f,0x72,0x00,0x00,0x01,0x00,0x00,0x7a,0x5d};
- verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(buf4)));
-
- byte[] buf5 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,(byte)0xc7,0x07,0x04,0x41,(byte)0xbf,(byte)0x9d,(byte)0xb0,0x0f,(byte)0xff,0x42,0x5a,(byte)0xdb,(byte)0xd7,0x41,(byte)0xca,0x6e,0x1e,0x00,(byte)0x9e,0x12,0x05,0x07,0x00,0x01,0x03,0x0b,0x16,0x00,0x00,0x60,0x1a,0x02,0x01,0x5e,0x02,0x00,0x03,0x14,0x00,0x66,0x15,0x00,0x0a,0x16,0x00,0x67,0x01,0x05,0x00,0x00,0x0c,(byte)0xe4,0x41,(byte)0xbf,(byte)0x9d,(byte)0x92,0x0f,(byte)0xff,0x42,0x5a,(byte)0xdb,(byte)0xb1,0x41,(byte)0xca,0x6f,(byte)0xc9,0x00,(byte)0xa2,(byte)0xb2,0x18,0x07,0x00,0x01,0x03,0x0b,0x16,0x00,0x00,0x60,0x1a,0x02,0x01,0x5e,0x02,0x00,0x03,0x14,0x00,0x66,0x15,0x00,0x0a,0x16,0x00,0x67,0x01,0x05,0x00,0x00,0x0c,(byte)0xc6,0x41,(byte)0xbf,(byte)0x9d,0x74,0x0f,(byte)0xff,0x42,0x5a,(byte)0xdb,(byte)0xee,0x41,(byte)0xca,0x73,(byte)0x92,0x00,(byte)0xb6,(byte)0xc9,0x1e,0x07,0x00,0x01,0x03,0x0b,0x1f,0x00,0x00,0x60,0x1a,0x02,0x01,0x5f,0x02,0x00,0x03,0x14,0x00,0x66,0x15,0x00,0x0a,0x16,0x00,0x66,0x01,0x05,0x00,0x00,0x0c,(byte)0xa8,0x41,(byte)0xbf,(byte)0x9c,(byte)0xfc,0x0f,(byte)0xff,0x42,0x5a,(byte)0xdb,(byte)0xa0,0x41,(byte)0xca,0x70,(byte)0xc1,0x00,(byte)0xb9,0x38,0x13,0x07,0x00,0x01,0x03,0x0b,0x1f,0x00,0x00,0x60,0x1a,0x02,0x01,0x5f,0x02,0x00,0x03,0x14,0x00,0x23,0x15,0x00,0x0a,0x16,0x00,0x25,0x01,0x05,0x00,0x00,0x0c,0x30,0x04,0x00,0x00,0x00};
- verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(buf5)));
-
- byte[] buf6 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x07,0x02,0x4c,0x61,0x41,0x0b,0x01,0x3f,0x42,0x31,(byte)0xc2,(byte)0xc1,0x41,(byte)0xd0,(byte)0xbe,(byte)0xb9,0x00,0x3d,0x00,0x00,0x05,0x00,0x64,(byte)0x83,(byte)0xff,0x4c,0x61,0x40,(byte)0xeb,0x01,0x3f,0x42,0x31,(byte)0xc2,(byte)0xc1,0x41,(byte)0xd0,(byte)0xbe,(byte)0xb9,0x00,0x3d,0x00,0x00,0x05,0x00,0x64,(byte)0x83,(byte)0xff,0x02,0x00,0x00,0x41,(byte)0xdf};
- verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(buf6)));*/
+ int[] buf2 = {0x00,0x92,0x00,0x00,0x0c,0x07,0xa6,0xba,0xcd,0x47,0x01,0x00,0x05,0x52,0xdb,0x5c,0xc2,0x00,0x00,0x18,0x7b,0x8b,0x25,0x1a,0xce,0x47,0x8e,0x08,0x7c,0x04,0x4c,0x0a,0x00,0x00,0x09,0x07,0x00,0x00,0x00,0x00,0x52,0xdb,0x5c,0xfe,0x00,0x00,0x18,0x7b,0x8a,0xb0,0x1a,0xce,0x47,0x19,0x08,0x79,0x04,0x4c,0x09,0x00,0x00,0x0b,0x07,0x00,0x00,0x00,0x00,0x52,0xdb,0x5d,0x3a,0x00,0x00,0x18,0x7b,0x8b,0x25,0x1a,0xce,0x47,0x4b,0x08,0x9d,0x04,0x4c,0x09,0x00,0x00,0x09,0x07,0x00,0x00,0x00,0x00,0x52,0xdb,0x5d,0x76,0x00,0x00,0x18,0x7b,0x8b,0x9a,0x1a,0xce,0x47,0x5c,0x08,0xcd,0x04,0x4c,0x08,0x00,0x00,0x09,0x07,0x00,0x00,0x00,0x00,0x52,0xdb,0x5d,0xb2,0x00,0x00,0x18,0x7b,0x8b,0x14,0x1a,0xce,0x46,0xe7,0x08,0xb3,0x04,0x4c,0x08,0x00,0x00,0x09,0x07,0x00,0x00,0x00,0x00,0x41,0xcb};
+ verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf2))));
}