diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-02-09 22:11:38 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-02-09 22:11:38 -0800 |
commit | cdad129c3c1f335a870d6395a645c454236b3d8f (patch) | |
tree | 8d05c9f5bbd18a9ff753f5258b1275376e9dd194 | |
parent | ef45ad3dc840cef5ded156095ea8b2a70faf15d6 (diff) | |
download | trackermap-server-cdad129c3c1f335a870d6395a645c454236b3d8f.tar.gz trackermap-server-cdad129c3c1f335a870d6395a645c454236b3d8f.tar.bz2 trackermap-server-cdad129c3c1f335a870d6395a645c454236b3d8f.zip |
Decode other analogue attributes
-rw-r--r-- | src/main/java/org/traccar/protocol/DmtProtocolDecoder.java | 7 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/DmtProtocolDecoderTest.java | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/DmtProtocolDecoder.java b/src/main/java/org/traccar/protocol/DmtProtocolDecoder.java index 75fdc3253..96b06557a 100644 --- a/src/main/java/org/traccar/protocol/DmtProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/DmtProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 - 2019 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2021 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. @@ -197,7 +197,8 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder { } else if (fieldId == 6) { while (buf.readerIndex() < fieldEnd) { - switch (buf.readUnsignedByte()) { + int number = buf.readUnsignedByte(); + switch (number) { case 1: position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE() * 0.001); break; @@ -214,7 +215,7 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder { position.set("solarPower", buf.readUnsignedShortLE() * 0.001); break; default: - buf.readUnsignedShortLE(); // other + position.set(Position.PREFIX_IO + number, buf.readUnsignedShortLE()); break; } } diff --git a/src/test/java/org/traccar/protocol/DmtProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/DmtProtocolDecoderTest.java index 8977cf194..efcd06218 100644 --- a/src/test/java/org/traccar/protocol/DmtProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/DmtProtocolDecoderTest.java @@ -13,6 +13,9 @@ public class DmtProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "0255003300001b00003335333232393032373533393235310038393931353030303030303030313330343539340000000403041910780603")); + verifyPositions(decoder, binary( + "0255047a003d0035020000fbb53a0f030015fbb53a0f3c210e2145deeb051e001a0901940c070302080300000000000300060f011d1003400804180005e80f062e1c3d003602000086b93a0f03001586b93a0fe5421c21bbe1be051700c30901a50d070302080300000000000300060f011d1003bb0804180005e80f062e1c")); + verifyPositions(decoder, false, binary( "025504ab013d00c21a00004829900c0300154929900cbd163617b08a94c7fa003c07032c131a0302080300000000000300060f019b14037e0e0463000558140607213d00c31a0000ca29900c030015ca29900ca3033817bbb895c71401be0603b310190302080300000000000300060f019b14036d0e0463000558140607213d00c41a0000472a900c030015472a900c8d453817423e96c7fa000200040013270302080300000000000300060f019b1403840e0463000546140606213d00c51a0000c52a900c030015c52a900c184c3817c35296c724010400050016180302080300000000000300060f019b1403750e0463000547140606213d00c61a0000462b900c030015462b900cbd8a361703b495c710018c07085a10210302080300000000000300060f019b1403630e0463000546140606213d00c71a0000c52b900c030015c52b900cf6d63517455a94c7e9004c05035a10240302080300000000000300060f019b14036e0e0463000545140606213d00c81a00004b2c900c0300154b2c900c766d3517ddf093c7320107000d00102e0302080300000000000300060f019b1403750e046300054314060521")); |