From 3ac7982d48bd7b3ed207a1461bc90a1cb7a888c4 Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Mon, 12 Jun 2023 23:22:21 +0200 Subject: Ruptela - decode TCO Driver ID and BLE Beacon ID --- .../org/traccar/protocol/RuptelaProtocolDecoder.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (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 737d30f10..8a9bf21a4 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -285,6 +285,22 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { driverId.release(); } + Long tcoDriverIdPart1 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 155); + Long tcoDriverIdPart2 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 156); + if (tcoDriverIdPart1 != null && tcoDriverIdPart2 != null) { + ByteBuf driverId = Unpooled.copyLong(tcoDriverIdPart1, tcoDriverIdPart2); + position.set(Position.KEY_DRIVER_UNIQUE_ID, driverId.toString(StandardCharsets.US_ASCII)); + driverId.release(); + } + + Long bleBeaconIdPart1 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 760); + Long bleBeaconIdPart2 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 761); + if (bleBeaconIdPart1 != null && bleBeaconIdPart2 != null) { + ByteBuf bleBeaconId = Unpooled.copyLong(bleBeaconIdPart1, bleBeaconIdPart2); + position.set("bleBeaconId", bleBeaconId.toString(StandardCharsets.US_ASCII)); + bleBeaconId.release(); + } + positions.add(position); } -- cgit v1.2.3 From a3a086cfda4219815cba4ea6ca2cb44028c1e091 Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Tue, 13 Jun 2023 13:37:24 +0200 Subject: Ruptela - tested bleBeaconID decoding --- src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 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 8a9bf21a4..2680e56b2 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -293,12 +293,10 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { driverId.release(); } - Long bleBeaconIdPart1 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 760); - Long bleBeaconIdPart2 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 761); - if (bleBeaconIdPart1 != null && bleBeaconIdPart2 != null) { - ByteBuf bleBeaconId = Unpooled.copyLong(bleBeaconIdPart1, bleBeaconIdPart2); - position.set("bleBeaconId", bleBeaconId.toString(StandardCharsets.US_ASCII)); - bleBeaconId.release(); + Long bleBeaconIdP1 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 760); + Long bleBeaconIdP2 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 761); + if (bleBeaconIdP1 != null && bleBeaconIdP2 != null) { + position.set("bleBeaconId", Long.toHexString(bleBeaconIdP1) + Long.toHexString(bleBeaconIdP2)); } positions.add(position); -- cgit v1.2.3 From cbfc5e524c98115ae0b1a4fb0754e9841a4fb915 Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Tue, 13 Jun 2023 15:49:46 +0200 Subject: Ruptela renamed bleBeaconId to tagId --- .../org/traccar/protocol/RuptelaProtocolDecoder.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 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 2680e56b2..1f2887859 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -285,18 +285,18 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { driverId.release(); } - Long tcoDriverIdPart1 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 155); - Long tcoDriverIdPart2 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 156); - if (tcoDriverIdPart1 != null && tcoDriverIdPart2 != null) { - ByteBuf driverId = Unpooled.copyLong(tcoDriverIdPart1, tcoDriverIdPart2); + 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(); } - Long bleBeaconIdP1 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 760); - Long bleBeaconIdP2 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 761); - if (bleBeaconIdP1 != null && bleBeaconIdP2 != null) { - position.set("bleBeaconId", Long.toHexString(bleBeaconIdP1) + Long.toHexString(bleBeaconIdP2)); + Long tagIdPart1 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 760); + Long tagIdPart2 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 761); + if (tagIdPart1 != null && tagIdPart2 != null) { + position.set("tagId", Long.toHexString(tagIdPart1) + Long.toHexString(tagIdPart2)); } positions.add(position); -- cgit v1.2.3 From 262f8df7724966862482a5b1837462dad77ce074 Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Tue, 13 Jun 2023 15:57:27 +0200 Subject: Ruptela restructure driver decoding --- .../traccar/protocol/RuptelaProtocolDecoder.java | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 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 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); -- cgit v1.2.3 From ea3ea7f53970817bf5dc2cf6b28f48f0836b3245 Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Tue, 13 Jun 2023 16:51:30 +0200 Subject: Update src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java Co-authored-by: Anton Tananaev --- src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java | 7 ++----- 1 file changed, 2 insertions(+), 5 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 2f127c70c..1755ba8a8 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -287,11 +287,8 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { decodeParameter(position, id, buf, 8); } - // CAN first driver ID - decodeDriver(position, Position.PREFIX_IO + 126, Position.PREFIX_IO + 127); - - // TCO first driver ID - decodeDriver(position, Position.PREFIX_IO + 155, Position.PREFIX_IO + 156); + decodeDriver(position, Position.PREFIX_IO + 126, Position.PREFIX_IO + 127); // can driver + decodeDriver(position, Position.PREFIX_IO + 155, Position.PREFIX_IO + 156); // tco driver Long tagIdPart1 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 760); Long tagIdPart2 = (Long) position.getAttributes().remove(Position.PREFIX_IO + 761); -- cgit v1.2.3