aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-15 18:07:03 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-15 18:07:03 +1300
commit3ba58a7d025c33c5f4e5e2d595158ecf9f420008 (patch)
tree34bc7f52059822cbc27e6eac7d3c204fa267f881
parentde46b77e923d3412d74dbf745933bd62acaeca77 (diff)
downloadtrackermap-server-3ba58a7d025c33c5f4e5e2d595158ecf9f420008.tar.gz
trackermap-server-3ba58a7d025c33c5f4e5e2d595158ecf9f420008.tar.bz2
trackermap-server-3ba58a7d025c33c5f4e5e2d595158ecf9f420008.zip
Store LAC and CID in right format
-rw-r--r--src/org/traccar/protocol/EelinkProtocolDecoder.java5
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java9
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java18
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/SuntechProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Tlt2hProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java21
-rw-r--r--test/org/traccar/ProtocolDecoderTest.java4
9 files changed, 48 insertions, 21 deletions
diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java
index b3a062db3..b75587743 100644
--- a/src/org/traccar/protocol/EelinkProtocolDecoder.java
+++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java
@@ -86,7 +86,10 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
position.setCourse(buf.readUnsignedShort());
- position.set(Event.KEY_CID, ChannelBuffers.hexDump(buf.readBytes(9)));
+ 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.setValid((buf.readUnsignedByte() & 0x01) != 0);
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 06c548669..42786d4fe 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -116,7 +116,9 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
.text(",")
.number("(0ddd)?,") // mcc
.number("(0ddd)?,") // mnc
- .number("(xxxx|x{8})?,") // lac
+ .number("(?:xxxx)?")
+ .number("(xxxx)").optional(2) // lac
+ .text(",")
.number("(xxxx)?,") // cell
.groupBegin()
.number("(d+.d)?,") // odometer
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index d9e31fe48..b576b063d 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -94,8 +94,13 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
position.setAltitude(buf.readUnsignedShort());
- position.set(Event.KEY_CID, buf.readUnsignedShort());
- position.set(Event.KEY_LAC, buf.readUnsignedShort());
+ int cid = buf.readUnsignedShort();
+ int lac = buf.readUnsignedShort();
+ if (cid != 0 && lac != 0) {
+ position.set(Event.KEY_CID, cid);
+ position.set(Event.KEY_LAC, lac);
+ }
+
position.set(Event.KEY_GSM, buf.readUnsignedByte());
} else if (version == 2) {
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java
index b2db50fd4..dc9e6056e 100644
--- a/src/org/traccar/protocol/MegastekProtocolDecoder.java
+++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java
@@ -53,14 +53,16 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
.number("(d)?,") // charger
.number("(d+)?,") // mcc
.number("(d+)?,") // mnc
- .number("(xxxx,xxxx);") // location code
+ .number("(xxxx),") // lac
+ .number("(xxxx);") // cid
.any() // checksum
.compile();
private static final Pattern PATTERN_ALTERNATIVE = new PatternBuilder()
.number("(d+),") // mcc
.number("(d+),") // mnc
- .number("(xxxx,xxxx),") // location code
+ .number("(xxxx),") // lac
+ .number("(xxxx),") // cid
.number("(d+),") // gsm signal
.number("(d+),") // battery
.number("(d+),") // flags
@@ -174,7 +176,8 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
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());
+ position.set(Event.KEY_LAC, parser.nextInt(16));
+ position.set(Event.KEY_CID, parser.nextInt(16));
}
} else {
@@ -198,7 +201,8 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
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_LAC, parser.nextInt(16));
+ position.set(Event.KEY_CID, parser.nextInt(16));
position.set(Event.KEY_GSM, parser.next());
position.set(Event.KEY_BATTERY, Double.parseDouble(parser.next()));
@@ -238,7 +242,8 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.d+),") // odometer
.number("(d+),") // mcc
.number("(d+),") // mnc
- .number("(xxxx,xxxx),") // cell
+ .number("(xxxx),") // lac
+ .number("(xxxx),") // cid
.number("(d+)?,") // gsm
.expression("([01]+),") // input
.expression("([01]+),") // output
@@ -297,7 +302,8 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_ODOMETER, parser.nextDouble());
position.set(Event.KEY_MCC, parser.nextInt());
position.set(Event.KEY_MNC, parser.nextInt());
- position.set(Event.KEY_CID, parser.next());
+ position.set(Event.KEY_LAC, parser.nextInt(16));
+ position.set(Event.KEY_CID, parser.nextInt(16));
String gsm = parser.next();
if (gsm != null) {
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 475329c5d..4bde5cf75 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -121,8 +121,8 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.set("runtime", 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_LAC, parser.nextInt(16));
+ position.set(Event.KEY_CID, parser.nextInt(16));
position.set(Event.KEY_STATUS, parser.next());
for (int i = 1; i <= 3; i++) {
diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java
index b0d85b101..38f771eec 100644
--- a/src/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -83,7 +83,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
position.setTime(dateBuilder.getDate());
- position.set(Event.KEY_CID, parser.next());
+ parser.next(); // location code + bsic
position.setValid(true);
position.setLatitude(parser.nextDouble());
diff --git a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
index d9d50947e..24e9893bb 100644
--- a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
@@ -86,7 +86,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
- position.set(Event.KEY_CID, parser.next());
+ parser.next(); // base station info
DateBuilder dateBuilder = new DateBuilder()
.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index 321b78b7c..88eecab70 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -55,7 +55,8 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
.number("(ddd)") // battery
.number("(dddd)|") // power
.number("(d+)|").optional() // adc
- .number("(x+)|") // location code
+ .number("x*(xxxx)") // lac
+ .number("(xxxx)|") // cid
.number("(d+)|") // temperature
.number("(d+.d+)|") // odometer
.number("d+|") // serial number
@@ -84,7 +85,8 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
.number("(dd)") // battery
.number("(dd)|") // external power
.number("(d+)|") // adc
- .number("(x{8})|") // location code
+ .number("(xxxx)") // lac
+ .number("(xxxx)|") // cid
.number("(d+)|") // temperature
.number("(d+.d+)|") // odometer
.number("d+|") // serial number
@@ -107,7 +109,8 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
.number("(dddd)") // adc 2
.number("(ddd)") // temperature 1
.number("(ddd)") // temperature 2
- .number("(x{8})") // location code
+ .number("(xxxx)") // lac
+ .number("(xxxx)") // cid
.expression("([AV])") // validity
.number("(dd)") // satellites
.number("(ddd)") // course
@@ -185,7 +188,14 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_BATTERY, parser.next());
position.set(Event.KEY_POWER, parser.nextDouble());
position.set(Event.PREFIX_ADC + 1, parser.next());
- position.set(Event.KEY_LAC, parser.next());
+
+ int lac = parser.nextInt(16);
+ int cid = parser.nextInt(16);
+ if (lac != 0 && cid != 0) {
+ position.set(Event.KEY_LAC, lac);
+ position.set(Event.KEY_CID, cid);
+ }
+
position.set(Event.PREFIX_TEMP + 1, parser.next());
position.set(Event.KEY_ODOMETER, parser.next());
@@ -203,7 +213,8 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.PREFIX_ADC + 2, parser.next());
position.set(Event.PREFIX_TEMP + 1, parser.next());
position.set(Event.PREFIX_TEMP + 2, parser.next());
- position.set(Event.KEY_LAC, parser.next());
+ position.set(Event.KEY_LAC, parser.nextInt(16));
+ position.set(Event.KEY_CID, parser.nextInt(16));
position.setValid(parser.next().equals("A"));
position.set(Event.KEY_SATELLITES, parser.next());
diff --git a/test/org/traccar/ProtocolDecoderTest.java b/test/org/traccar/ProtocolDecoderTest.java
index 7aea23f1b..dbb11965b 100644
--- a/test/org/traccar/ProtocolDecoderTest.java
+++ b/test/org/traccar/ProtocolDecoderTest.java
@@ -195,13 +195,13 @@ public class ProtocolDecoderTest {
checkInteger(attributes.get(Event.KEY_MNC), 0, 999);
}
- /*if (attributes.containsKey(Event.KEY_LAC)) {
+ 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);