mirror of
https://github.com/traccar/traccar.git
synced 2025-01-09 04:07:38 +08:00
Fix Wialon 2.0 UDP decoding
This commit is contained in:
parent
c1d6ef7dcb
commit
c5f56b4cb2
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 - 2022 Anton Tananaev (anton@traccar.org)
|
||||
* Copyright 2013 - 2024 Anton Tananaev (anton@traccar.org)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -39,6 +39,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
|
||||
}
|
||||
|
||||
private static final Pattern PATTERN_ANY = new PatternBuilder()
|
||||
.number("d.d;").optional()
|
||||
.expression("([^#]+)?") // imei
|
||||
.text("#") // start byte
|
||||
.expression("([^#]+)") // type
|
||||
@ -175,12 +176,15 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
|
||||
String type = parser.next();
|
||||
String data = parser.next();
|
||||
|
||||
DeviceSession deviceSession;
|
||||
Position position;
|
||||
|
||||
switch (type) {
|
||||
|
||||
case "L":
|
||||
String[] values = data.split(";");
|
||||
String imei = values[0].indexOf('.') >= 0 ? values[1] : values[0];
|
||||
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
|
||||
deviceSession = getDeviceSession(channel, remoteAddress, imei);
|
||||
if (deviceSession != null) {
|
||||
sendResponse(channel, remoteAddress, type, 1);
|
||||
}
|
||||
@ -192,7 +196,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
|
||||
|
||||
case "D":
|
||||
case "SD":
|
||||
Position position = decodePosition(channel, remoteAddress, id, data);
|
||||
position = decodePosition(channel, remoteAddress, id, data);
|
||||
if (position != null) {
|
||||
sendResponse(channel, remoteAddress, "D", 1);
|
||||
return position;
|
||||
|
@ -36,7 +36,7 @@ public class WialonProtocolDecoderTest extends ProtocolTest {
|
||||
"#D#101118;061143;0756.0930;N;12338.6403;E;18.223;99.766;-4.000;10;0.800;NA;NA;NA;NA;101_521347:1:521249,101_521126:1:6593598,101_521127:1:774780,101_521072_21.1:1:0,101_521072_21.2:1:71353;F24A"));
|
||||
|
||||
verifyPosition(decoder, text(
|
||||
"99999999#D#101118;061143;0756.0930;N;12338.6403;E;18.223;99.766;-4.000;10;0.800;NA;NA;NA;NA;101_521347:1:521249,101_521126:1:6593598,101_521127:1:774780,101_521072_21.1:1:0,101_521072_21.2:1:71353;F24A"));
|
||||
"2.0;99999999#D#101118;061143;0756.0930;N;12338.6403;E;18.223;99.766;-4.000;10;0.800;NA;NA;NA;NA;101_521347:1:521249,101_521126:1:6593598,101_521127:1:774780,101_521072_21.1:1:0,101_521072_21.2:1:71353;F24A"));
|
||||
|
||||
verifyPosition(decoder, text(
|
||||
"#D#151216;135910;5321.1466;N;04441.7929;E;87;156;265.000000;12;1.000000;241;NA;NA;NA;odo:2:0.000000,total_fuel:1:430087,can_fls:1:201,can_taho:1:11623,can_mileage:1:140367515"));
|
||||
@ -82,6 +82,7 @@ public class WialonProtocolDecoderTest extends ProtocolTest {
|
||||
verifyAttribute(decoder, text(
|
||||
"#D#120319;112003;NA;NA;NA;NA;0.000;NA;NA;0;NA;NA;NA;NA;NA;motion:3:false"),
|
||||
"motion", false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user