From 7c04066ff6444790acd8b28d1abffd46bd8243da Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 17 Oct 2021 12:04:18 -0700 Subject: Decode counter values --- .../org/traccar/protocol/DmtHttpProtocolDecoder.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/main/java') 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; } -- cgit v1.2.3