diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/protocol/MegastekProtocolDecoder.java | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java index 15f7be582..c57d755c7 100644 --- a/src/org/traccar/protocol/MegastekProtocolDecoder.java +++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java @@ -249,14 +249,22 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { .number("(d+.d+)?,") // odometer .number("(d+),") // mcc .number("(d+),") // mnc - .number("(xxxx),") // lac - .number("(x+),") // cid + .number("(xxxx)?,") // lac + .number("(x+)?,") // cid .number("(d+)?,") // gsm - .expression("([01]+)?,") // input - .expression("([01]+)?,") // output + .groupBegin() + .number("([01]{4})?,") // input + .number("([01]{4})?,") // output .number("(d+)?,") // adc1 .number("(d+)?,") // adc2 .number("(d+)?,") // adc3 + .or() + .number("(d+),") // input + .number("(d+),") // output + .number("(d+),") // adc1 + .number("(d+),") // adc2 + .number("(d+),") // adc3 + .groupEnd() .groupBegin() .number("(-?d+.?d*)") // temperature 1 .or().text(" ") @@ -308,14 +316,33 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000); } - position.setNetwork(new Network(CellTower.from( - parser.nextInt(0), parser.nextInt(0), parser.nextHexInt(0), parser.nextHexInt(0), parser.nextInt(0)))); + int mcc = parser.nextInt(); + int mnc = parser.nextInt(); + Integer lac = parser.nextHexInt(); + Integer cid = parser.nextHexInt(); + Integer rssi = parser.nextInt(); + if (lac != null && cid != null) { + CellTower tower = CellTower.from(mcc, mnc, lac, cid); + if (rssi != null) { + tower.setSignalStrength(rssi); + } + position.setNetwork(new Network(tower)); + } - position.set(Position.KEY_INPUT, parser.nextBinInt(0)); - position.set(Position.KEY_OUTPUT, parser.nextBinInt(0)); + if (parser.hasNext(5)) { + position.set(Position.KEY_INPUT, parser.nextBinInt(0)); + position.set(Position.KEY_OUTPUT, parser.nextBinInt(0)); + for (int i = 1; i <= 3; i++) { + position.set(Position.PREFIX_ADC + i, parser.nextInt(0)); + } + } - for (int i = 1; i <= 3; i++) { - position.set(Position.PREFIX_ADC + i, parser.nextInt(0)); + if (parser.hasNext(5)) { + position.set(Position.KEY_HEART_RATE, parser.nextInt()); + position.set(Position.KEY_STEPS, parser.nextInt()); + position.set("activityTime", parser.nextInt()); + position.set("lightSleepTime", parser.nextInt()); + position.set("deepSleepTime", parser.nextInt()); } for (int i = 1; i <= 2; i++) { |