aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-10-01 20:22:21 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-10-01 20:22:21 -0700
commiteafe26117e9cc52c58f4ce220f8ac0d5e1d9bf36 (patch)
tree348aae1f8a6aae1930b6953d2875ab1aeef9941b
parentc1b406b6fcc442f96f9698774f5544ec9a0588e9 (diff)
downloadtraccar-server-eafe26117e9cc52c58f4ce220f8ac0d5e1d9bf36.tar.gz
traccar-server-eafe26117e9cc52c58f4ce220f8ac0d5e1d9bf36.tar.bz2
traccar-server-eafe26117e9cc52c58f4ce220f8ac0d5e1d9bf36.zip
Fix Bluetooth decoding
-rw-r--r--src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java5
-rw-r--r--src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java5
2 files changed, 7 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
index bee21982e..0e829e7f7 100644
--- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -461,9 +461,11 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
position.set(Position.KEY_TYPE, type);
- int mask = Integer.parseInt(values[index++], 16);
+ int mask;
if (type.equals("BLE")) {
mask = 0b1100000110110;
+ } else {
+ mask = Integer.parseInt(values[index++], 16);
}
if (BitUtil.check(mask, 1)) {
@@ -518,7 +520,6 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
position.setValid(true);
int count = Integer.parseInt(values[index++]);
- index += 1;
for (int i = 1; i <= count; i++) {
position.set("tag" + i + "Rssi", Integer.parseInt(values[index++]));
diff --git a/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java
index 7f0700728..a9720f437 100644
--- a/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java
@@ -83,7 +83,10 @@ public class SuntechProtocolDecoderTest extends ProtocolTest {
var decoder = new SuntechProtocolDecoder(null);
verifyPosition(decoder, buffer(
- "BLE;0820012345;001FFF;82;1.0.0;20191203;17:00:51;+32.691615;-117.297160;2;2;-32;-100;33;AABBCCDDEEFF;12;18;52;1;-44;44;112233445566;32;69;101"));
+ "BLE;1140000053;114;1.0.1;20211001;17:27:09;+28.433465;-82.565891;1;-43;-46;-41;ACB89523EF68;247;0;0"));
+
+ verifyPosition(decoder, buffer(
+ "BLE;0820012345;82;1.0.0;20191203;17:00:51;+32.691615;-117.297160;2;-32;-100;33;AABBCCDDEEFF;12;18;52;1;-44;44;112233445566;32;69;101"));
verifyNull(decoder, buffer(
"BSA;0820012345;001FFF;82;1.0.0;1;20191203;17:00:51;+32.691615;-117.297160;1;-55;68:11:6A:FD:1A:A7;6AA5;1DE8"));