aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-12-13 22:19:47 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2021-12-13 22:19:47 -0800
commit5a2baafba92958c82b81873dae19c5df7e793eea (patch)
tree9ac3f036da53612cfb9aa989c616895418053c3e /src/main
parentf910e56a45a4adc08287b6674d011bd25ea52b27 (diff)
downloadtrackermap-server-5a2baafba92958c82b81873dae19c5df7e793eea.tar.gz
trackermap-server-5a2baafba92958c82b81873dae19c5df7e793eea.tar.bz2
trackermap-server-5a2baafba92958c82b81873dae19c5df7e793eea.zip
Handle missing parameters
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java b/src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java
index 15cf84a5f..815cce987 100644
--- a/src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java
@@ -174,21 +174,25 @@ public class DmtHttpProtocolDecoder extends BaseHttpProtocolDecoder {
position.set(Position.KEY_INDEX, root.getInt("sqn"));
position.set(Position.KEY_EVENT, root.getInt("reason"));
- JsonArray analogues = root.getJsonArray("analogues");
- for (int i = 0; i < analogues.size(); i++) {
- JsonObject adc = analogues.getJsonObject(i);
- position.set(Position.PREFIX_ADC + adc.getInt("id"), adc.getInt("val"));
+ if (root.containsKey("analogues")) {
+ JsonArray analogues = root.getJsonArray("analogues");
+ for (int i = 0; i < analogues.size(); i++) {
+ JsonObject adc = analogues.getJsonObject(i);
+ position.set(Position.PREFIX_ADC + adc.getInt("id"), adc.getInt("val"));
+ }
}
- int input = root.getInt("inputs");
- int output = root.getInt("outputs");
- int status = root.getInt("status");
-
- position.set(Position.KEY_IGNITION, BitUtil.check(input, 0));
-
- position.set(Position.KEY_INPUT, input);
- position.set(Position.KEY_OUTPUT, output);
- position.set(Position.KEY_STATUS, status);
+ if (root.containsKey("inputs")) {
+ int input = root.getInt("inputs");
+ position.set(Position.KEY_IGNITION, BitUtil.check(input, 0));
+ position.set(Position.KEY_INPUT, input);
+ }
+ if (root.containsKey("outputs")) {
+ position.set(Position.KEY_OUTPUT, root.getInt("outputs"));
+ }
+ if (root.containsKey("status")) {
+ position.set(Position.KEY_STATUS, root.getInt("status"));
+ }
if (root.containsKey("counters")) {
JsonArray counters = root.getJsonArray("counters");