aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-10-13 17:32:51 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-10-13 17:32:51 +1300
commit6611056f9fdf7c97e6e9e5429b21aba65f6c3561 (patch)
treec90111cee2119facbacf67ae4ed52d622bbdb680 /src
parentb61dee3d8474d5431dc2b085ec0ed92f7ee918c6 (diff)
downloadtraccar-server-6611056f9fdf7c97e6e9e5429b21aba65f6c3561.tar.gz
traccar-server-6611056f9fdf7c97e6e9e5429b21aba65f6c3561.tar.bz2
traccar-server-6611056f9fdf7c97e6e9e5429b21aba65f6c3561.zip
Support MT80 Megastek watch
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java47
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++) {