aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-09-24 14:45:14 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-09-24 14:45:14 +1300
commit62e2696c2d8e619d90cb978fa60f714312649866 (patch)
tree997ca54628736202cd0a0051c4687e020b61dd16
parentfd59d77dbd6037c7b72eb6f4d132db4bde6877a0 (diff)
downloadtrackermap-server-62e2696c2d8e619d90cb978fa60f714312649866.tar.gz
trackermap-server-62e2696c2d8e619d90cb978fa60f714312649866.tar.bz2
trackermap-server-62e2696c2d8e619d90cb978fa60f714312649866.zip
Support additional eeLink parameters
-rw-r--r--src/org/traccar/model/Position.java1
-rw-r--r--src/org/traccar/protocol/EelinkProtocolDecoder.java41
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/WatchProtocolDecoder.java2
-rw-r--r--test/org/traccar/protocol/EelinkProtocolDecoderTest.java3
5 files changed, 47 insertions, 2 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java
index c188124af..31af3d38a 100644
--- a/src/org/traccar/model/Position.java
+++ b/src/org/traccar/model/Position.java
@@ -37,6 +37,7 @@ public class Position extends Message {
public static final String KEY_ODOMETER_SERVICE = "serviceOdometer"; // meters
public static final String KEY_ODOMETER_TRIP = "tripOdometer"; // meters
public static final String KEY_HOURS = "hours";
+ public static final String KEY_STEPS = "steps";
public static final String KEY_INPUT = "input";
public static final String KEY_OUTPUT = "output";
public static final String KEY_IMAGE = "image";
diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java
index 2526282b1..8d0f8016a 100644
--- a/src/org/traccar/protocol/EelinkProtocolDecoder.java
+++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java
@@ -217,6 +217,45 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(7); // bss2
}
+ if (buf.readableBytes() >= 2) {
+ int status = buf.readUnsignedShort();
+ position.setValid(BitUtil.check(status, 0));
+ if (BitUtil.check(status, 1)) {
+ position.set(Position.KEY_IGNITION, BitUtil.check(status, 2));
+ }
+ position.set(Position.KEY_STATUS, status);
+ }
+
+ if (buf.readableBytes() >= 2) {
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001);
+ }
+
+ if (buf.readableBytes() >= 4) {
+ position.set(Position.PREFIX_ADC + 0, buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
+ }
+
+ if (buf.readableBytes() >= 4) {
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ }
+
+ if (buf.readableBytes() >= 4) {
+ buf.readUnsignedShort(); // gsm counter
+ buf.readUnsignedShort(); // gps counter
+ }
+
+ if (buf.readableBytes() >= 4) {
+ position.set(Position.KEY_STEPS, buf.readUnsignedShort());
+ buf.readUnsignedShort(); // walking time
+ }
+
+ if (buf.readableBytes() >= 12) {
+ position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedShort() / 256.0);
+ position.set("humidity", buf.readUnsignedShort() * 0.1);
+ position.set("illuminance", buf.readUnsignedInt() / 256.0);
+ position.set("co2", buf.readUnsignedInt());
+ }
+
return position;
}
@@ -240,6 +279,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
getDeviceSession(channel, remoteAddress, ChannelBuffers.hexDump(buf.readBytes(8)).substring(1));
} else {
+
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
if (deviceSession == null) {
return null;
@@ -262,6 +302,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+
}
return null;
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index aea8f0b3b..e4b18e277 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -392,7 +392,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_RSSI, parser.nextInt());
position.set(Position.KEY_SATELLITES, parser.nextInt());
position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt());
- position.set("steps", parser.nextInt());
+ position.set(Position.KEY_STEPS, parser.nextInt());
position.set("turnovers", parser.nextInt());
dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java
index adab65245..86dc9456d 100644
--- a/src/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/org/traccar/protocol/WatchProtocolDecoder.java
@@ -205,7 +205,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_RSSI, parser.nextInt(0));
position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt(0));
- position.set("steps", parser.nextInt(0));
+ position.set(Position.KEY_STEPS, parser.nextInt(0));
int status = parser.nextHexInt(0);
position.set(Position.KEY_ALARM, decodeAlarm(status));
diff --git a/test/org/traccar/protocol/EelinkProtocolDecoderTest.java b/test/org/traccar/protocol/EelinkProtocolDecoderTest.java
index ca2bb463e..115eef1a3 100644
--- a/test/org/traccar/protocol/EelinkProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/EelinkProtocolDecoderTest.java
@@ -14,6 +14,9 @@ public class EelinkProtocolDecoderTest extends ProtocolTest {
"676701000c007b03525440717505180104"));
verifyPosition(decoder, binary(
+ "6767120048000559c1829213059a7400008e277d000c000000000800cc00080d2a000034df3cf0b429dd82cad3048910320000000000007b7320d005ba0000000019a000000000000000000000"));
+
+ verifyPosition(decoder, binary(
"6767050020213b59c6aecdff41dce70b8b977d00000001fe000a36e30078fe010159c6aecd"));
verifyPosition(decoder, binary(