aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-04-19 11:31:12 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-04-19 11:31:12 +1200
commit4af79323eff0aa57c44e4069bcb46cb8388c9524 (patch)
tree306f28f2d76ec6f092b74c5b80751154e034635b
parentd882668353819880970fa889d89705da2c93c02b (diff)
downloadtraccar-server-4af79323eff0aa57c44e4069bcb46cb8388c9524.tar.gz
traccar-server-4af79323eff0aa57c44e4069bcb46cb8388c9524.tar.bz2
traccar-server-4af79323eff0aa57c44e4069bcb46cb8388c9524.zip
Improve support for Ulbotech protocol
-rw-r--r--src/org/traccar/protocol/UlbotechProtocolDecoder.java23
-rw-r--r--test/org/traccar/ProtocolTest.java4
-rw-r--r--test/org/traccar/protocol/UlbotechProtocolDecoderTest.java23
3 files changed, 39 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
index a5c608dd3..efa63bee2 100644
--- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java
+++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2015 - 2016 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.
@@ -120,7 +120,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
long seconds = buf.readUnsignedInt() & 0x7fffffffL;
seconds += 946684800L; // 2000-01-01 00:00
seconds -= timeZone;
- position.setTime(new Date(seconds * 1000));
+ Date time = new Date(seconds * 1000);
boolean hasLocation = false;
@@ -143,10 +143,17 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
case DATA_LBS:
position.set(Event.KEY_MCC, buf.readUnsignedShort());
- position.set(Event.KEY_MNC, buf.readUnsignedByte());
+ position.set(Event.KEY_MNC, buf.readUnsignedShort());
position.set(Event.KEY_LAC, buf.readUnsignedShort());
- position.set(Event.KEY_CID, buf.readUnsignedShort());
+ if (length == 11) {
+ position.set(Event.KEY_CID, buf.readUnsignedInt());
+ } else {
+ position.set(Event.KEY_CID, buf.readUnsignedShort());
+ }
position.set(Event.KEY_GSM, -buf.readUnsignedByte());
+ if (length > 9 && length != 11) {
+ buf.skipBytes(length - 9);
+ }
break;
case DATA_STATUS:
@@ -218,11 +225,13 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
}
}
- if (hasLocation) {
- return position;
+ if (!hasLocation) {
+ getLastLocation(position, time);
+ } else {
+ position.setTime(time);
}
- return null;
+ return position;
}
}
diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java
index a4dcbf61c..2f5f3962f 100644
--- a/test/org/traccar/ProtocolTest.java
+++ b/test/org/traccar/ProtocolTest.java
@@ -104,6 +104,10 @@ public class ProtocolTest {
return request;
}
+ protected void verifyNotNull(BaseProtocolDecoder decoder, Object object) throws Exception {
+ Assert.assertNotNull(decoder.decode(null, null, object));
+ }
+
protected void verifyNothing(BaseProtocolDecoder decoder, Object object) throws Exception {
Assert.assertNull(decoder.decode(null, null, object));
}
diff --git a/test/org/traccar/protocol/UlbotechProtocolDecoderTest.java b/test/org/traccar/protocol/UlbotechProtocolDecoderTest.java
index bf01baa4a..5036c4a40 100644
--- a/test/org/traccar/protocol/UlbotechProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/UlbotechProtocolDecoderTest.java
@@ -10,8 +10,23 @@ public class UlbotechProtocolDecoderTest extends ProtocolTest {
UlbotechProtocolDecoder decoder = new UlbotechProtocolDecoder(new UlbotechProtocol());
- /*verifyPosition(decoder, binary(
- "f8010108683230211861161e9d8c48020b00de0063eb730128b56161030400010001040400127d0705060174179422021005e000000001db06f8"));*/
+ verifyNotNull(decoder, binary(
+ "F8010108683230231070781EA3676E020BFFFFFFFFFFFFFFFFFFFF780304000000030404000002C20506032A1790220E100101AC72F8"));
+
+ verifyNotNull(decoder, binary(
+ "f8010108683230220996561ea6ce1c020bffffffffffffffffffff78030400000000040400087b710506035519ad2214060800000000000000006220f8"));
+
+ verifyAttributes(decoder, binary(
+ "f8010108683230220996561ea6ce3f020b02cc00114e86000002f153030400000000040400087b710506035619a4221406080000000000000000fbcff8"));
+
+ verifyAttributes(decoder, binary(
+ "f8010108683230211861161e9d8c48020b00de0063eb730128b56161030400010001040400127d0705060174179422021005e000000001db06f8"));
+
+ verifyPosition(decoder, binary(
+ "f8010108683230220996561ea6cdf9010eff47465cfb68d7a000000000270f030400000000040400087b710506035119ba22140608000000000000000022cef8"));
+
+ verifyPosition(decoder, binary(
+ "f8010108683230220996561ea74274010eff47477bfb68d89000000000270f030400000000040400087b710506035419472214060800000000000000006661f8"));
verifyPosition(decoder, binary(
"f8010103515790566431569e5fbb9d010e015ee2b906bde4a000000000009f03040a4000000404000115fe05060340173f22030711310583410c0000310d00312f834131000008040000b78c09077320290082c021100101120af8"));
@@ -43,10 +58,10 @@ public class UlbotechProtocolDecoderTest extends ProtocolTest {
verifyPosition(decoder, binary(
"F8010108621060211481299C4249FA010E015EE27506BDE80900020000008F030402420000040400523CAF05060392173F220706080000000000000000071131058E410C0E40310D48312F8E41310884080402CA60E43872F8"));
- verifyNothing(decoder, binary(
+ verifyNotNull(decoder, binary(
"f8010108653280262660481cdacf830209ffffffffffffffff780304000300000404000000030506017418a021f99697f8"));
- verifyNothing(decoder, binary(
+ verifyNotNull(decoder, binary(
"f801010865328026266048fffeae800209ffffffffffffffff7803040200000004040000000005060375175421f3060800000000000000009c28f8"));
verifyPosition(decoder, binary(