aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-01-16 13:51:40 +0500
committerAbyss777 <abyss@fox5.ru>2017-01-16 13:51:40 +0500
commitb5eb48cbba215ca55c1a5e5ae5fae5b375243247 (patch)
tree64a25006deb6635853c0cc727db201f088566347
parentcffbce4b3bc5ef817c4063a74f148a2a5986d58a (diff)
parent00caa503748a1dad3349bfb8444ef766efd60633 (diff)
downloadtrackermap-server-b5eb48cbba215ca55c1a5e5ae5fae5b375243247.tar.gz
trackermap-server-b5eb48cbba215ca55c1a5e5ae5fae5b375243247.tar.bz2
trackermap-server-b5eb48cbba215ca55c1a5e5ae5fae5b375243247.zip
Merge remote-tracking branch 'upstream/master' into manager
# Conflicts: # setup/default.xml
-rw-r--r--src/org/traccar/protocol/At2000ProtocolDecoder.java57
-rw-r--r--src/org/traccar/protocol/GatorProtocolDecoder.java34
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java55
-rw-r--r--src/org/traccar/protocol/OsmAndProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/WatchProtocolDecoder.java69
-rw-r--r--test/org/traccar/ProtocolTest.java2
-rw-r--r--test/org/traccar/protocol/At2000ProtocolDecoderTest.java20
-rw-r--r--test/org/traccar/protocol/H02ProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/WatchProtocolDecoderTest.java3
-rwxr-xr-xtools/test-generator.py19
10 files changed, 179 insertions, 86 deletions
diff --git a/src/org/traccar/protocol/At2000ProtocolDecoder.java b/src/org/traccar/protocol/At2000ProtocolDecoder.java
index 58b6f44e8..00973f2aa 100644
--- a/src/org/traccar/protocol/At2000ProtocolDecoder.java
+++ b/src/org/traccar/protocol/At2000ProtocolDecoder.java
@@ -31,6 +31,8 @@ import java.net.SocketAddress;
import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
public class At2000ProtocolDecoder extends BaseProtocolDecoder {
@@ -100,28 +102,55 @@ public class At2000ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- Position position = new Position();
- position.setProtocol(getProtocolName());
- position.setDeviceId(deviceSession.getDeviceId());
-
byte[] data = new byte[buf.capacity() - BLOCK_LENGTH];
buf.readBytes(data);
buf = ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, cipher.update(data));
- buf.readUnsignedShort(); // index
- buf.readUnsignedShort(); // reserved
+ List<Position> positions = new LinkedList<>();
+
+ while (buf.readableBytes() >= 63) {
+
+ Position position = new Position();
+ position.setProtocol(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ buf.readUnsignedShort(); // index
+ buf.readUnsignedShort(); // reserved
+
+ position.setValid(true);
+
+ position.setTime(new Date(buf.readLong() * 1000));
- position.setValid(true);
+ position.setLatitude(buf.readFloat());
+ position.setLongitude(buf.readFloat());
+ position.setAltitude(buf.readFloat());
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readFloat()));
+ position.setCourse(buf.readFloat());
- position.setTime(new Date(buf.readLong() * 1000));
+ buf.readUnsignedInt(); // geozone event
+ buf.readUnsignedInt(); // io events
+ buf.readUnsignedInt(); // geozone value
+ buf.readUnsignedInt(); // io values
+ buf.readUnsignedShort(); // operator
- position.setLatitude(buf.readFloat());
- position.setLongitude(buf.readFloat());
- position.setAltitude(buf.readFloat());
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readFloat()));
- position.setCourse(buf.readFloat());
+ position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
+
+ position.set(Position.KEY_POWER, buf.readUnsignedShort() + "mV");
+
+ buf.readUnsignedShort(); // cid
+ buf.readUnsignedByte(); // rssi
+ buf.readUnsignedByte(); // current profile
+
+ position.set(Position.KEY_BATTERY, buf.readUnsignedByte());
+ position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedByte());
+ position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
+
+ positions.add(position);
+
+ }
- return position;
+ return positions;
}
diff --git a/src/org/traccar/protocol/GatorProtocolDecoder.java b/src/org/traccar/protocol/GatorProtocolDecoder.java
index d9c8a086c..f01efb9d8 100644
--- a/src/org/traccar/protocol/GatorProtocolDecoder.java
+++ b/src/org/traccar/protocol/GatorProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,6 +56,21 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder {
return String.format("%02d%02d%02d%02d%02d", d1, d2, d3, d4, d5);
}
+ private void sendResponse(Channel channel, byte calibration) {
+ if (channel != null) {
+ ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ response.writeByte(0x24); response.writeByte(0x24); // header
+ response.writeByte(MSG_HEARTBEAT); // size
+ response.writeShort(5);
+ response.writeByte(calibration);
+ response.writeByte(0); // main order
+ response.writeByte(0); // slave order
+ response.writeByte(1); // calibration
+ response.writeByte(0x0D);
+ channel.write(response);
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -70,22 +85,9 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(), buf.readUnsignedByte(),
buf.readUnsignedByte(), buf.readUnsignedByte());
- if (type == MSG_HEARTBEAT) {
-
- if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
- response.writeByte(0x24); response.writeByte(0x24); // header
- response.writeByte(MSG_HEARTBEAT); // size
- response.writeShort(5);
- response.writeByte(buf.readUnsignedByte());
- response.writeByte(0); // main order
- response.writeByte(0); // slave order
- response.writeByte(1); // calibration
- response.writeByte(0x0D);
- channel.write(response);
- }
+ sendResponse(channel, buf.getByte(buf.writerIndex() - 2));
- } else if (type == MSG_POSITION_DATA || type == MSG_ROLLCALL_RESPONSE
+ if (type == MSG_POSITION_DATA || type == MSG_ROLLCALL_RESPONSE
|| type == MSG_ALARM_DATA || type == MSG_BLIND_AREA) {
Position position = new Position();
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index c2a3b2b09..37f6294be 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -66,19 +66,18 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
}
private void processStatus(Position position, long status) {
- if (!BitUtil.check(status, 0) || !BitUtil.check(status, 1)
- || !BitUtil.check(status, 2)) {
-
- if (!BitUtil.check(status, 0)) {
- position.set(Position.KEY_ALARM, Position.ALARM_VIBRATION);
- } else if (!BitUtil.check(status, 1)) {
- position.set(Position.KEY_ALARM, Position.ALARM_SOS);
- } else if (!BitUtil.check(status, 2)) {
- position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED);
- }
+
+ if (!BitUtil.check(status, 0)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_VIBRATION);
+ } else if (!BitUtil.check(status, 1)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ } else if (!BitUtil.check(status, 2)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED);
}
+
position.set(Position.KEY_IGNITION, !BitUtil.check(status, 10));
position.set(Position.KEY_STATUS, status);
+
}
private String decodeBattery(int value) {
@@ -245,16 +244,6 @@ 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.setNetwork(new Network(CellTower.from(mcc, mnc, lac, cid)));
- }
- }
-
return position;
}
@@ -305,20 +294,20 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
ChannelBuffer buf = (ChannelBuffer) msg;
String marker = buf.toString(0, 1, StandardCharsets.US_ASCII);
- if (marker.equals("*")) {
- String sentence = buf.toString(StandardCharsets.US_ASCII);
- if (sentence.contains(",NBR,")) {
- return decodeLbs(sentence, channel, remoteAddress);
- } else {
- return decodeText(sentence, channel, remoteAddress);
- }
- } else if (marker.equals("$")) {
- return decodeBinary(buf, channel, remoteAddress);
- } else if (marker.equals("X")) {
- return null; // X mode
+ switch (marker) {
+ case "*":
+ String sentence = buf.toString(StandardCharsets.US_ASCII);
+ if (sentence.contains(",NBR,")) {
+ return decodeLbs(sentence, channel, remoteAddress);
+ } else {
+ return decodeText(sentence, channel, remoteAddress);
+ }
+ case "$":
+ return decodeBinary(buf, channel, remoteAddress);
+ case "X":
+ default:
+ return null;
}
-
- return null;
}
}
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
index 5508cad92..382865e8f 100644
--- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java
+++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
@@ -119,6 +119,9 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
case "altitude":
position.setAltitude(Double.parseDouble(value));
break;
+ case "accuracy":
+ position.setAccuracy(Double.parseDouble(value));
+ break;
case "hdop":
position.set(Position.KEY_HDOP, Double.parseDouble(value));
break;
diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java
index 07df2de13..4a48fe7b6 100644
--- a/src/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/org/traccar/protocol/WatchProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,11 +18,15 @@ package org.traccar.protocol;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
+import org.traccar.model.WifiAccessPoint;
import java.net.SocketAddress;
import java.util.Date;
@@ -56,11 +60,13 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.?d*),") // course
.number("(d+.?d*),") // altitude
.number("(d+),") // satellites
- .number("(d+),") // gsm
+ .number("(d+),") // rssi
.number("(d+),") // battery
.number("(d+),") // steps
.number("d+,") // tumbles
- .any()
+ .number("(x+),") // status
+ .expression("([^\\]]*)") // cell and wifi
+ .text("]").optional()
.compile();
private void sendResponse(Channel channel, String manufacturer, String id, String content) {
@@ -70,6 +76,59 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private String decodeAlarm(int status) {
+ if (BitUtil.check(status, 0)) {
+ return Position.ALARM_LOW_BATTERY;
+ } else if (BitUtil.check(status, 1)) {
+ return Position.ALARM_GEOFENCE_EXIT;
+ } else if (BitUtil.check(status, 2)) {
+ return Position.ALARM_GEOFENCE_ENTER;
+ } else if (BitUtil.check(status, 3)) {
+ return Position.ALARM_OVERSPEED;
+ } else if (BitUtil.check(status, 16)) {
+ return Position.ALARM_SOS;
+ } else if (BitUtil.check(status, 17)) {
+ return Position.ALARM_LOW_BATTERY;
+ } else if (BitUtil.check(status, 18)) {
+ return Position.ALARM_GEOFENCE_EXIT;
+ } else if (BitUtil.check(status, 19)) {
+ return Position.ALARM_GEOFENCE_ENTER;
+ }
+ return null;
+ }
+
+ private void decodeTail(Position position, String data) {
+ String[] values = data.split(",");
+ int index = 0;
+
+ Network network = new Network();
+
+ int cellCount = Integer.parseInt(values[index++]);
+ index += 1; // timing advance
+ int mcc = Integer.parseInt(values[index++]);
+ int mnc = Integer.parseInt(values[index++]);
+
+ for (int i = 0; i < cellCount; i++) {
+ network.addCellTower(CellTower.from(mcc, mnc,
+ Integer.parseInt(values[index++]), Integer.parseInt(values[index++]),
+ Integer.parseInt(values[index++])));
+ }
+
+ if (index < values.length && !values[index].isEmpty()) {
+ int wifiCount = Integer.parseInt(values[index++]);
+
+ for (int i = 0; i < wifiCount; i++) {
+ index += 1; // wifi name
+ network.addWifiAccessPoint(WifiAccessPoint.from(
+ values[index++], Integer.parseInt(values[index++])));
+ }
+ }
+
+ if (network.getCellTowers() != null || network.getWifiAccessPoints() != null) {
+ position.setNetwork(network);
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -141,6 +200,10 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
position.set("steps", parser.nextInt());
+ position.set(Position.KEY_ALARM, decodeAlarm(parser.nextInt(16)));
+
+ decodeTail(position, parser.next());
+
return position;
} else if (type.equals("TKQ")) {
diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java
index 20e033e3b..955e0b788 100644
--- a/test/org/traccar/ProtocolTest.java
+++ b/test/org/traccar/ProtocolTest.java
@@ -178,7 +178,7 @@ public class ProtocolTest extends BaseTest {
Assert.assertFalse("no attributes", attributes.isEmpty());
}
- if (position.getNetwork() != null) {
+ if (position.getNetwork() != null && position.getNetwork().getCellTowers() != null) {
for (CellTower cellTower : position.getNetwork().getCellTowers()) {
checkInteger(cellTower.getMobileCountryCode(), 0, 999);
checkInteger(cellTower.getMobileNetworkCode(), 0, 999);
diff --git a/test/org/traccar/protocol/At2000ProtocolDecoderTest.java b/test/org/traccar/protocol/At2000ProtocolDecoderTest.java
index 60485c805..596d2870d 100644
--- a/test/org/traccar/protocol/At2000ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/At2000ProtocolDecoderTest.java
@@ -19,9 +19,17 @@ public class At2000ProtocolDecoderTest extends ProtocolTest {
decoder = new At2000ProtocolDecoder(new At2000Protocol());
verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "01012f0000000000000000000000000000333537343534303731363036313936ddf189075add9a32d97b54073025963e65849a3a59940d05fd8db655fc84bc6d"));
+
+ verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "893b01000000000000000000000000003b40bcdab6387d829146701d8cb53daaa87b84d24b40cb24fd86da5d3f5f02b0f6f603c43c5a513418a0b2bdcaba603dbe737687cfe9082c57668eb6789d2b029a35aeac6a609558b96de5d7ad37917c902efc878ca9aff474f9d5d2417191285b8d5749bd3ffa86cc99096ce24c1f6ac350ae9adf3d5c788f80b4e3d3dc2dbb8abc1414ea1b52fdb55b2bb8af223ec528245f99d451b715e5774c5397db645d9ae441e645f8dae70230b728e81f51240868712d6f426fd694dbad8026fcf487c268939f04593ad86391cc829b1a1bdac8804ff7507544a69dc0b1b3927d7344e8a5b26fa56825283b3e476330b36d15011e1647ebd9f2ef71844ed32c0dc050457bfbd79160e6d1d8cda00a0927c8957631770e98eb20735aa46b0b18502baf4c45d2623ee51a4320cf3018010e7bbf8bc0dd79eb28e88b727ea67e980b8a91"));
+
+ decoder = new At2000ProtocolDecoder(new At2000Protocol());
+
+ verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"01012f000000000000000000000000000033353734353430373136303631393637f5441a9862260117858237fe3160388490f0df7d46c09112ee087235a92101"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"89043203000000000000000000000000d01ff1df1b56ba9185bb741ddc253f3cee093b1f8193100cd95777b5288a6f29d1b343a952f882ce8825679f7e27ad88ed7898bff92f716acadfc3c17fa8c1a6b9d0934e8f042433a183776c06c1acd73efb4b9f19030debb4dceb161fb3e6630757d25c3e995b7cf5f446318dcc1677eb215d1af49f11cd7300598bcdc40cc25466ed2391d836c782e44bc04a332e902b2b34f5597a542af4ca670cdfc18d87ce2a225c3e6f2f32359d4914c6df09aa5ee306c229260d4a56da53f93398bc8a6e77095305ee214cf605de20d3876a993fb810486f75bcd514c12442bf4dc3fbe7963b20d5100b5ecff1c1aef4c4b3736a04e245d50f538327db21d55270b279db5ac5a9658876bae3d9b5026b8975bb2bf4d100b8492760d66ae31f27bf9c525c2d794860eabca9c788b91152dbce79f336daaf6a7a9547bf1dd8e3334c891f4548fd6d112ebf45125c2a8abd3a786ebbcfdd03101b524bbf465f14a9a424305ce7de56ffca85b4657fc8c03e4349c0ca6be64d1cf595ee91f8173678ef2267dae54dd00028450c48d9b74c925af0f245d409d8773238dce5832747587f53a12155869c1d464eb0630f94cf8dceb76aa39995411d4ce7743b1501692425afec498535526067e79f568b7f71ee47d8b4929118d57b13d56cdbfd26582d579dee"));
decoder = new At2000ProtocolDecoder(new At2000Protocol());
@@ -29,23 +37,17 @@ public class At2000ProtocolDecoderTest extends ProtocolTest {
verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"01012f0000000000000000000000000000333537343534303731363035353033dd529a1eb5df9f3b6d320b38250e03306692957e8c2127d8e381a717f639b4c9"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"89898701000000000000000000000000ae99e38f13d44f536769eb4930a6826dfebe5b98a6048941e89b17c9cdcb276be4af7c0d188d07c90d6e94aa9efcb465fe7aeaff4d85caf837483b4e9b32fbbacfbc4e175eebf57a27f552a64fc3419565d2dfbea668511a08d5a526342fad0e93b20c4449ad8defab4a9ac68cf7dad86971eb2cd96810d9d6a9c56e07fd90e4c28cfc53a069b63efe37a0523a69b607a2dc011ba17b177c5332c04be1faeeabed24539b3b790fa8a8610ab3633e0140ed79690fcae9dea43c7daad780d95a511d8f4875e621bcfe7516a03b80eb3c473ffd4bc1eda298dfa7d994a2cfeaa5d24c190d52d72fd90975a2e6f9ed3b95017133952262f91787c46839738a80c333dc53ee4d8afe75315d801efe17bc7309f30cfce64906bf70e6844c835781cbb64b49e9315ca3c2cd39d00a03cc7178a4ebc5df230dcdfd44ec588791d488f96bb6ff4007a753f552bda4d1766632aa3ec5eb38feb23ed6efb8f382a7f22b70adc9cb533c09bf749190c36d63b572c1acfc3a59138d51273835ab13c4689df01e3d2c2dd1829e00aac5c56b5d51e60d6731833f82c7464d88df663ca28a20eedeecb60f3704ae78281838caa116184e414db459768321bbfa1e83ad59fe168eb81f3b41cfe0e39c8aa78cbbe5825620bf053a1cb62e04d4cdf17ca2dc9305d47c"));
decoder = new At2000ProtocolDecoder(new At2000Protocol());
verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN,
- "01012f0000000000000000000000000000333537343534303731363237353938d74dcd195c521a246fb00f16346c7f001919957babc40f84152b60ddeb7ab47a"));
-
- verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"01012f00000000000000000000000000003335363137333036343430373439320fad981997ae8e031fe10c0ea7641903ca32c0331df467233d2a9cd886fbeef8"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"893f0000000000000000000000000000e048b1a31deba3f5dbe8877f574877e6ed4d022b6611a10d80dfc4c0c11fa8aacf4a9de61528327e2b66843dd9c5d3a7cc9ee1d9c71a34bb482145d88b4fda3e"));
- verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN,
- "01012f00000000000000000000000000003335373435343037313632363831345612da3748bede02ea4faf04ac02f420c0ff37719eccf2864fa2b8191abf8242"));
-
}
}
diff --git a/test/org/traccar/protocol/H02ProtocolDecoderTest.java b/test/org/traccar/protocol/H02ProtocolDecoderTest.java
index 91dfbc3ff..3464c5dba 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,4106012736,V1,224434,A,1827.3855,N,06705.7577,W,000.00,000,100117,FFFFFBFF,310,260,49101,1753,5#"));
+
verifyAttributes(decoder, buffer(
"*HQ,4208150188,NBR,210249,260,6,0,7,1014,50675,37,1014,50633,27,1014,17933,18,1014,17231,15,1014,50632,12,1014,13211,11,1014,17031,10,281216,FFFFFBFF,2#"));
diff --git a/test/org/traccar/protocol/WatchProtocolDecoderTest.java b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
index 24d6c0795..653fc3ebc 100644
--- a/test/org/traccar/protocol/WatchProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class WatchProtocolDecoderTest extends ProtocolTest {
WatchProtocolDecoder decoder = new WatchProtocolDecoder(new WatchProtocol());
verifyPosition(decoder, text(
+ "[SG*9051004074*0058*AL,120117,145602,V,40.058413,N,76.336618,W,11.519,188,99,00,01,80,0,50,00000000,0,1,0,0,,10]"));
+
+ verifyPosition(decoder, text(
"[SG*9051000884*009B*UD,030117,161129,V,52.745450,N,0.369512,,0.1481,000,99,00,70,5,0,50,00000000,5,1,234,15,893,3611,135,893,3612,132,893,3993,131,893,30986,129,893,40088,126,,00]"));
verifyPosition(decoder, text(
diff --git a/tools/test-generator.py b/tools/test-generator.py
index a23e2576e..7f8916f4d 100755
--- a/tools/test-generator.py
+++ b/tools/test-generator.py
@@ -33,13 +33,14 @@ for i in range(0, len(waypoints)):
lon = lon1 + (lon2 - lon1) * j / count
points.append((lat, lon))
-def send(conn, lat, lon, course, alarm, ignition, speed):
- params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course))
+def send(conn, lat, lon, course, speed, alarm, ignition, accuracy):
+ params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course), ('speed', speed))
if alarm:
params = params + (('alarm', 'sos'),)
if ignition:
params = params + (('ignition', 'true'),)
- params = params + (('speed', speed),)
+ if accuracy:
+ params = params + (('accuracy', accuracy),)
conn.request('GET', '?' + urllib.urlencode(params))
conn.getresponse().read()
@@ -59,12 +60,10 @@ conn = httplib.HTTPConnection(server)
while True:
(lat1, lon1) = points[index % len(points)]
(lat2, lon2) = points[(index + 1) % len(points)]
- alarm = ((index % 10) == 0)
- ignition = ((index % len(points)) != 0)
- if (index % len(points)) != 0:
- speed = device_speed
- else:
- speed = 0
- send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), alarm, ignition, speed)
+ speed = device_speed if (index % len(points)) != 0 else 0
+ alarm = (index % 10) == 0
+ ignition = (index % len(points)) != 0
+ accuracy = 100 if (index % 10) == 0 else 0
+ send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), speed, alarm, ignition, accuracy)
time.sleep(period)
index += 1