aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorMatjaž Črnko <m.crnko@txt.si>2023-06-13 15:57:27 +0200
committerMatjaž Črnko <m.crnko@txt.si>2023-06-13 15:57:27 +0200
commit262f8df7724966862482a5b1837462dad77ce074 (patch)
treea0f257c639c4ba459f0022ec26ed7adf34f65a88 /src/main/java/org
parentcbfc5e524c98115ae0b1a4fb0754e9841a4fb915 (diff)
downloadtrackermap-server-262f8df7724966862482a5b1837462dad77ce074.tar.gz
trackermap-server-262f8df7724966862482a5b1837462dad77ce074.tar.bz2
trackermap-server-262f8df7724966862482a5b1837462dad77ce074.zip
Ruptela restructure driver decoding
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java
index 1f2887859..2f127c70c 100644
--- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java
@@ -92,6 +92,16 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private void decodeDriver(Position position, String part1, String part2) {
+ Long driverIdPart1 = (Long) position.getAttributes().remove(part1);
+ Long driverIdPart2 = (Long) position.getAttributes().remove(part2);
+ if (driverIdPart1 != null && driverIdPart2 != null) {
+ ByteBuf driverId = Unpooled.copyLong(driverIdPart1, driverIdPart2);
+ position.set(Position.KEY_DRIVER_UNIQUE_ID, driverId.toString(StandardCharsets.US_ASCII));
+ driverId.release();
+ }
+ }
+
private void decodeParameter(Position position, int id, ByteBuf buf, int length) {
switch (id) {
case 2:
@@ -277,21 +287,11 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
decodeParameter(position, id, buf, 8);
}
- Long driverIdPart1 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 126);
- Long driverIdPart2 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 127);
- if (driverIdPart1 != null && driverIdPart2 != null) {
- ByteBuf driverId = Unpooled.copyLong(driverIdPart1, driverIdPart2);
- position.set(Position.KEY_DRIVER_UNIQUE_ID, driverId.toString(StandardCharsets.US_ASCII));
- driverId.release();
- }
+ // CAN first driver ID
+ decodeDriver(position, Position.PREFIX_IO + 126, Position.PREFIX_IO + 127);
- driverIdPart1 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 155);
- driverIdPart2 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 156);
- if (driverIdPart1 != null && driverIdPart2 != null) {
- ByteBuf driverId = Unpooled.copyLong(driverIdPart1, driverIdPart2);
- position.set(Position.KEY_DRIVER_UNIQUE_ID, driverId.toString(StandardCharsets.US_ASCII));
- driverId.release();
- }
+ // TCO first driver ID
+ decodeDriver(position, Position.PREFIX_IO + 155, Position.PREFIX_IO + 156);
Long tagIdPart1 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 760);
Long tagIdPart2 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 761);