aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-12-02 03:43:46 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-12-02 03:43:46 +1300
commit6782f2ee534494aa24dc73299f71e4227077e037 (patch)
treee1b5582037ded1319cf3fae90bc1fcdd75bfcc30
parentf63658504320cb96501cf83d698ba932840e315b (diff)
downloadtraccar-server-6782f2ee534494aa24dc73299f71e4227077e037.tar.gz
traccar-server-6782f2ee534494aa24dc73299f71e4227077e037.tar.bz2
traccar-server-6782f2ee534494aa24dc73299f71e4227077e037.zip
Decode H02 cell info
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java19
-rw-r--r--test/org/traccar/protocol/H02ProtocolDecoderTest.java3
2 files changed, 22 insertions, 0 deletions
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index 2b7d00969..2c7852d16 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -167,6 +167,12 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
.number("(?:(dd)(dd)(dd))?,") // date (ddmmyy)
.any()
.number("(x{8})") // status
+ .groupBegin()
+ .number(", *(x+),") // mcc
+ .number(" *(x+),") // mnc
+ .number(" *(x+),") // lac
+ .number(" *(x+)") // cid
+ .groupEnd("?")
.any()
.compile();
@@ -237,6 +243,19 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
processStatus(position, parser.nextLong(16));
+ if (parser.hasNext(4)) {
+ int mcc = parser.nextInt(16);
+ int mnc = parser.nextInt(16);
+ int lac = parser.nextInt(16);
+ int cid = parser.nextInt(16);
+ if (mcc != 0 && mnc != 0 && lac != 0 && cid != 0) {
+ position.set(Position.KEY_MCC, mcc);
+ position.set(Position.KEY_MNC, mnc);
+ position.set(Position.KEY_LAC, lac);
+ position.set(Position.KEY_CID, cid);
+ }
+ }
+
return position;
}
diff --git a/test/org/traccar/protocol/H02ProtocolDecoderTest.java b/test/org/traccar/protocol/H02ProtocolDecoderTest.java
index b2e336076..d1b2d3198 100644
--- a/test/org/traccar/protocol/H02ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/H02ProtocolDecoderTest.java
@@ -10,6 +10,9 @@ public class H02ProtocolDecoderTest extends ProtocolTest {
H02ProtocolDecoder decoder = new H02ProtocolDecoder(new H02Protocol());
+ verifyPosition(decoder, buffer(
+ "*HQ,353588020068342,V1,084436,A,3257.01525,N,00655.03865,W,57.78,40,011216,FFFBFFFF,25c,a, 154,b04c#"));
+
verifyNothing(decoder, buffer(
"*HQ,356803210091319,BS,,2d4,a,1b63,1969,26,1b63,10b2,31,0,0,25,,ffffffff,60#"));