diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2023-06-13 08:28:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-13 08:28:58 -0700 |
commit | 82ecf19d235a50af1475463f7467d9468fa53346 (patch) | |
tree | 7eebb68226ee79285b2852e43ea9e07b71b7a304 | |
parent | f1de2533c3527aefc6f9eb15277128bb8d8ec3cb (diff) | |
parent | ea3ea7f53970817bf5dc2cf6b28f48f0836b3245 (diff) | |
download | trackermap-server-82ecf19d235a50af1475463f7467d9468fa53346.tar.gz trackermap-server-82ecf19d235a50af1475463f7467d9468fa53346.tar.bz2 trackermap-server-82ecf19d235a50af1475463f7467d9468fa53346.zip |
Merge pull request #5118 from jinzo/ruptela-improvements-3
Ruptela Decoder for TCO Driver ID and BLE Beacon ID
-rw-r--r-- | src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java index 737d30f10..1755ba8a8 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,12 +287,13 @@ 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(); + 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); + if (tagIdPart1 != null && tagIdPart2 != null) { + position.set("tagId", Long.toHexString(tagIdPart1) + Long.toHexString(tagIdPart2)); } positions.add(position); |