aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/T800xProtocolDecoder.java12
-rw-r--r--test/org/traccar/ProtocolDecoderTest.java16
4 files changed, 34 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java
index a58e57703..b2db50fd4 100644
--- a/src/org/traccar/protocol/MegastekProtocolDecoder.java
+++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java
@@ -171,9 +171,11 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_CHARGE, Integer.parseInt(charger) == 1);
}
- position.set(Event.KEY_MCC, parser.next());
- position.set(Event.KEY_MNC, parser.next());
- position.set(Event.KEY_LAC, parser.next());
+ if (parser.hasNext(3)) {
+ position.set(Event.KEY_MCC, parser.nextInt());
+ position.set(Event.KEY_MNC, parser.nextInt());
+ position.set(Event.KEY_LAC, parser.next());
+ }
} else {
@@ -194,8 +196,8 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(getDeviceId());
- position.set(Event.KEY_MCC, parser.next());
- position.set(Event.KEY_MNC, parser.next());
+ position.set(Event.KEY_MCC, parser.nextInt());
+ position.set(Event.KEY_MNC, parser.nextInt());
position.set(Event.KEY_LAC, parser.next());
position.set(Event.KEY_GSM, parser.next());
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 2b8460fc7..475329c5d 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -119,8 +119,8 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_ODOMETER, parser.next());
position.set("runtime", parser.next());
- position.set(Event.KEY_MCC, parser.next());
- position.set(Event.KEY_MCC, parser.next());
+ position.set(Event.KEY_MCC, parser.nextInt());
+ position.set(Event.KEY_MNC, parser.nextInt());
position.set(Event.KEY_LAC, parser.next());
position.set(Event.KEY_CID, parser.next());
position.set(Event.KEY_STATUS, parser.next());
@@ -196,7 +196,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_ODOMETER, buf.readUnsignedInt());
position.set("runtime", buf.readUnsignedInt());
position.set(Event.KEY_MCC, buf.readUnsignedShort());
- position.set(Event.KEY_MCC, buf.readUnsignedShort());
+ position.set(Event.KEY_MNC, buf.readUnsignedShort());
position.set(Event.KEY_LAC, buf.readUnsignedShort());
position.set(Event.KEY_CID, buf.readUnsignedShort());
position.set(Event.KEY_STATUS, buf.readUnsignedShort());
diff --git a/src/org/traccar/protocol/T800xProtocolDecoder.java b/src/org/traccar/protocol/T800xProtocolDecoder.java
index 2127be331..83d815e0f 100644
--- a/src/org/traccar/protocol/T800xProtocolDecoder.java
+++ b/src/org/traccar/protocol/T800xProtocolDecoder.java
@@ -143,10 +143,14 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, dateBuilder.getDate());
- position.set(Event.KEY_MCC, buf.readUnsignedShort());
- position.set(Event.KEY_MNC, buf.readUnsignedShort());
- position.set(Event.KEY_LAC, buf.readUnsignedShort());
- position.set(Event.KEY_CID, buf.readUnsignedShort());
+ byte[] array = new byte[16];
+ buf.readBytes(array);
+ ChannelBuffer swapped = ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, array);
+
+ position.set(Event.KEY_MCC, swapped.readUnsignedShort());
+ position.set(Event.KEY_MNC, swapped.readUnsignedShort());
+ position.set(Event.KEY_LAC, swapped.readUnsignedShort());
+ position.set(Event.KEY_CID, swapped.readUnsignedShort());
// two more cell towers
diff --git a/test/org/traccar/ProtocolDecoderTest.java b/test/org/traccar/ProtocolDecoderTest.java
index 5292bd32d..7aea23f1b 100644
--- a/test/org/traccar/ProtocolDecoderTest.java
+++ b/test/org/traccar/ProtocolDecoderTest.java
@@ -187,6 +187,22 @@ public class ProtocolDecoderTest {
Assert.assertFalse("no attributes", attributes.isEmpty());
}
+ if (attributes.containsKey(Event.KEY_MCC)) {
+ checkInteger(attributes.get(Event.KEY_MCC), 100, 999);
+ }
+
+ if (attributes.containsKey(Event.KEY_MNC)) {
+ checkInteger(attributes.get(Event.KEY_MNC), 0, 999);
+ }
+
+ /*if (attributes.containsKey(Event.KEY_LAC)) {
+ checkInteger(attributes.get(Event.KEY_LAC), 1, 65535);
+ }
+
+ if (attributes.containsKey(Event.KEY_CID)) {
+ checkInteger(attributes.get(Event.KEY_CID), 1, 268435455);
+ }*/
+
/*if (attributes.containsKey(Event.KEY_MCC) || attributes.containsKey(Event.KEY_MNC)) {
checkInteger(attributes.get(Event.KEY_MCC), 100, 999);
checkInteger(attributes.get(Event.KEY_MNC), 0, 999);