aboutsummaryrefslogtreecommitdiff
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
parentb61dee3d8474d5431dc2b085ec0ed92f7ee918c6 (diff)
downloadtraccar-server-6611056f9fdf7c97e6e9e5429b21aba65f6c3561.tar.gz
traccar-server-6611056f9fdf7c97e6e9e5429b21aba65f6c3561.tar.bz2
traccar-server-6611056f9fdf7c97e6e9e5429b21aba65f6c3561.zip
Support MT80 Megastek watch
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java47
-rw-r--r--test/org/traccar/protocol/MegastekProtocolDecoderTest.java6
2 files changed, 43 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++) {
diff --git a/test/org/traccar/protocol/MegastekProtocolDecoderTest.java b/test/org/traccar/protocol/MegastekProtocolDecoderTest.java
index d10432b38..fab5df11b 100644
--- a/test/org/traccar/protocol/MegastekProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/MegastekProtocolDecoderTest.java
@@ -11,6 +11,12 @@ public class MegastekProtocolDecoderTest extends ProtocolTest {
MegastekProtocolDecoder decoder = new MegastekProtocolDecoder(new MegastekProtocol());
verifyPosition(decoder, text(
+ "0132$MGV002,869152024261561,,S,310818,133945,V,3814.35442,N,02144.50662,E,00,00,00,99.9,,,44.2,,202,10,,,13,0,0,0,0,90,,,,11,100,Timer;!"));
+
+ verifyPosition(decoder, text(
+ "0151$MGV002,869152024261561,ID,S,070918,155544,V,3814.35419,N,02144.52113,E,00,00,00,99.9,0.062,,12.3,,202,01,0898,D1BE,8,34,1055,0,0,600,,,,11,010,Timer;!"));
+
+ verifyPosition(decoder, text(
"0174$MGV002,014682001957744,014682001957744,R,260318,042537,A,3853.77301,N,07728.66673,W,00,09,00,1.06,0.147,329.51,123.3,,310,26,B46C,5E69375,5,0000,0000,0,,,,,,10,019,Timer,,;!"));
verifyNull(decoder, text(