aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/MegastekProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/MegastekProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java
index a58e57703..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
@@ -171,9 +173,12 @@ 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.nextInt(16));
+ position.set(Event.KEY_CID, parser.nextInt(16));
+ }
} else {
@@ -194,9 +199,10 @@ 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_LAC, parser.next());
+ position.set(Event.KEY_MCC, parser.nextInt());
+ position.set(Event.KEY_MNC, parser.nextInt());
+ 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()));
@@ -236,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
@@ -295,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) {