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