diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-10-17 12:04:18 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-10-17 12:04:18 -0700 |
commit | 7c04066ff6444790acd8b28d1abffd46bd8243da (patch) | |
tree | 360269f1fd244d1076066e1880d5eb93d8da01c8 | |
parent | a31c75e93ea9ff6b42f54a1869ab87a88222e28a (diff) | |
download | trackermap-server-7c04066ff6444790acd8b28d1abffd46bd8243da.tar.gz trackermap-server-7c04066ff6444790acd8b28d1abffd46bd8243da.tar.bz2 trackermap-server-7c04066ff6444790acd8b28d1abffd46bd8243da.zip |
Decode counter values
-rw-r--r-- | src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java b/src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java index cffc1f3eb..8283ab643 100644 --- a/src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java @@ -184,6 +184,25 @@ public class DmtHttpProtocolDecoder extends BaseHttpProtocolDecoder { position.set(Position.KEY_OUTPUT, root.getInt("outputs")); position.set(Position.KEY_STATUS, root.getInt("status")); + if (root.containsKey("counters")) { + JsonArray counters = root.getJsonArray("counters"); + for (int i = 0; i < counters.size(); i++) { + JsonObject counter = counters.getJsonObject(i); + switch (counter.getInt("id")) { + case 0: + position.set(Position.KEY_BATTERY, counter.getInt("val") * 0.001); + break; + case 1: + position.set(Position.KEY_BATTERY_LEVEL, counter.getInt("val") * 0.01); + break; + default: + position.set("counter" + counter.getInt("id"), counter.getInt("val")); + break; + } + + } + } + return position; } |