From a3b03c7744a6767cede6725ba7089823e11b983a Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Wed, 21 Jun 2023 00:18:46 +0200 Subject: Ruptela Decoder - implement Extended protocol extended messages merging --- .../java/org/traccar/protocol/RuptelaProtocolDecoder.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java index 1755ba8a8..294768860 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -236,7 +236,18 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // timestamp extension if (type == MSG_EXTENDED_RECORDS) { - buf.readUnsignedByte(); // record extension + int b = buf.readUnsignedByte(); // record extension + int noRecordsToMerge = (b & 0xf0) >> 4; + int currentRecord = b & 0x0f; + + if (currentRecord > 0 && noRecordsToMerge >= currentRecord) { + if (!positions.isEmpty() + && positions.get(positions.size() - 1).getDeviceTime() + .compareTo(position.getDeviceTime()) == 0) { + position = positions.remove(positions.size() - 1); + } + } + } buf.readUnsignedByte(); // priority (reserved) -- cgit v1.2.3 From b8e9d39d711c0d9f2af26aa90bfb167af364a8d3 Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Wed, 21 Jun 2023 12:00:52 +0200 Subject: Ruptela Decoder use Bitutil for record extension merging --- src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java index 294768860..ecb5c4204 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -22,6 +22,7 @@ import org.traccar.BaseProtocolDecoder; import org.traccar.session.DeviceSession; import org.traccar.NetworkMessage; import org.traccar.Protocol; +import org.traccar.helper.BitUtil; import org.traccar.helper.DataConverter; import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; @@ -236,9 +237,9 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // timestamp extension if (type == MSG_EXTENDED_RECORDS) { - int b = buf.readUnsignedByte(); // record extension - int noRecordsToMerge = (b & 0xf0) >> 4; - int currentRecord = b & 0x0f; + int recordExtension = buf.readUnsignedByte(); // record extension + int noRecordsToMerge = BitUtil.between(recordExtension, 4, 8); + int currentRecord = BitUtil.to(recordExtension, 4); if (currentRecord > 0 && noRecordsToMerge >= currentRecord) { if (!positions.isEmpty() @@ -247,7 +248,6 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { position = positions.remove(positions.size() - 1); } } - } buf.readUnsignedByte(); // priority (reserved) -- cgit v1.2.3 From 149db397ce7bbf60834260a7585366e515c8de24 Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Wed, 21 Jun 2023 12:08:23 +0200 Subject: Ruptela Decoder - power factor standardization --- src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java index ecb5c4204..1d627c5f3 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -124,7 +124,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_ADC + 2, readValue(buf, length, false)); break; case 29: - position.set(Position.KEY_POWER, readValue(buf, length, false)); + position.set(Position.KEY_POWER, readValue(buf, length, false) * 0.001); break; case 30: position.set(Position.KEY_BATTERY, readValue(buf, length, false) * 0.001); -- cgit v1.2.3 From 5ee370870401ae2e18a477d01f22128c6109f015 Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Wed, 21 Jun 2023 19:11:40 +0200 Subject: Update src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java Co-authored-by: Anton Tananaev --- src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java index 1d627c5f3..79e8e1091 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -241,7 +241,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { int noRecordsToMerge = BitUtil.between(recordExtension, 4, 8); int currentRecord = BitUtil.to(recordExtension, 4); - if (currentRecord > 0 && noRecordsToMerge >= currentRecord) { + if (currentRecord > 0 && currentRecord <= noRecordsToMerge) { if (!positions.isEmpty() && positions.get(positions.size() - 1).getDeviceTime() .compareTo(position.getDeviceTime()) == 0) { -- cgit v1.2.3 From 648e7f652a5ca1024813864b2dea2572c9f5e3f0 Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Wed, 21 Jun 2023 19:12:09 +0200 Subject: Update src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java Co-authored-by: Anton Tananaev --- src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java index 79e8e1091..a8296771a 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -237,7 +237,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // timestamp extension if (type == MSG_EXTENDED_RECORDS) { - int recordExtension = buf.readUnsignedByte(); // record extension + int recordExtension = buf.readUnsignedByte(); int noRecordsToMerge = BitUtil.between(recordExtension, 4, 8); int currentRecord = BitUtil.to(recordExtension, 4); -- cgit v1.2.3 From e43d353b7cc0f2bf34a77d58529c1360683d81c1 Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Wed, 21 Jun 2023 19:15:44 +0200 Subject: Ruptela Decoder - extended records merging, remove redudant checks and better variable naming --- src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java index a8296771a..d067d2ddc 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -238,15 +238,11 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { if (type == MSG_EXTENDED_RECORDS) { int recordExtension = buf.readUnsignedByte(); - int noRecordsToMerge = BitUtil.between(recordExtension, 4, 8); + int mergeRecordCount = BitUtil.between(recordExtension, 4, 8); int currentRecord = BitUtil.to(recordExtension, 4); - if (currentRecord > 0 && currentRecord <= noRecordsToMerge) { - if (!positions.isEmpty() - && positions.get(positions.size() - 1).getDeviceTime() - .compareTo(position.getDeviceTime()) == 0) { - position = positions.remove(positions.size() - 1); - } + if (currentRecord > 0 && currentRecord <= mergeRecordCount) { + position = positions.remove(positions.size() - 1); } } -- cgit v1.2.3 From eccbcfdd6906979763d0825f2b112a3050343381 Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Wed, 21 Jun 2023 19:48:25 +0200 Subject: Update src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java Co-authored-by: Anton Tananaev --- src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java index d067d2ddc..2122d5081 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -238,7 +238,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { if (type == MSG_EXTENDED_RECORDS) { int recordExtension = buf.readUnsignedByte(); - int mergeRecordCount = BitUtil.between(recordExtension, 4, 8); + int mergeRecordCount = BitUtil.from(recordExtension, 4); int currentRecord = BitUtil.to(recordExtension, 4); if (currentRecord > 0 && currentRecord <= mergeRecordCount) { -- cgit v1.2.3