From 0bf22eb231e3eb9ecf912f41dcc8f5e7f7fa8865 Mon Sep 17 00:00:00 2001 From: jcardus Date: Fri, 29 Mar 2024 01:10:06 +0000 Subject: Fix INF message on GV310LAU --- .../traccar/protocol/Gl200TextProtocolDecoder.java | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index 7a8d67cf9..b998f718e 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -122,12 +122,12 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN_INF = new PatternBuilder() .text("+").expression("(?:RESP|BUFF):GTINF,") - .expression("(?:.{6}|.{10})?,") // protocol version + .expression("(.{6}|.{10})?,") // protocol version .number("(d{15}|x{14}),") // imei .expression("(?:[0-9A-Z]{17},)?") // vin .expression("(?:[^,]+)?,") // device name .number("(xx),") // state - .expression("(?:[0-9Ff]{20})?,") // iccid + .expression("([0-9Ff]{20})?,") // iccid .number("(d{1,2}),") // rssi .number("d{1,2},") .expression("[01]{1,2},") // external power @@ -148,6 +148,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { .expression("(?:[01])?,").optional() // pin15 mode .number("(d+)?,") // adc1 .number("(d+)?,").optional() // adc2 + .number("(d+)?,").optional() // adc3 .number("(xx)?,") // digital input .number("(xx)?,") // digital output .number("[-+]dddd,") // timezone @@ -163,10 +164,17 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { private Object decodeInf(Channel channel, SocketAddress remoteAddress, String sentence) { Parser parser = new Parser(PATTERN_INF, sentence); - Position position = initPosition(parser, channel, remoteAddress); - if (position == null) { + if (!parser.matches()) { return null; } + String protocolVersion = parser.next(); + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); + if (deviceSession == null) { + return null; + } + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); switch (parser.nextHexInt()) { case 0x16: @@ -197,9 +205,14 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { break; } + position.set(Position.KEY_ICCID, parser.next()); position.set(Position.KEY_RSSI, parser.nextInt()); - - parser.next(); // odometer or external power + + if (protocolVersion.startsWith("6E")) { // GV310LAU + position.set(Position.KEY_POWER, parser.nextDouble() / 1000); // odometer or external power + } else { + parser.next(); // odometer or external power + } position.set(Position.KEY_BATTERY, parser.nextDouble()); position.set(Position.KEY_CHARGE, parser.nextInt() == 1); @@ -210,6 +223,9 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_ADC + 1, parser.next()); position.set(Position.PREFIX_ADC + 2, parser.next()); + if (protocolVersion.startsWith("6E")) { + position.set(Position.PREFIX_ADC + 3, parser.next()); + } position.set(Position.KEY_INPUT, parser.next()); position.set(Position.KEY_OUTPUT, parser.next()); -- cgit v1.2.3 From 2a57c25829fc11c2fcf4d55aa6b866f8fc6305f7 Mon Sep 17 00:00:00 2001 From: jcardus Date: Fri, 29 Mar 2024 01:17:59 +0000 Subject: fix trailing spaces --- src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index b998f718e..c0a2a2ea0 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -207,7 +207,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ICCID, parser.next()); position.set(Position.KEY_RSSI, parser.nextInt()); - + if (protocolVersion.startsWith("6E")) { // GV310LAU position.set(Position.KEY_POWER, parser.nextDouble() / 1000); // odometer or external power } else { -- cgit v1.2.3 From 97b61ee431d8384ad2c233adcd9e478b074bc41d Mon Sep 17 00:00:00 2001 From: jcardus Date: Fri, 29 Mar 2024 19:15:38 +0000 Subject: start refactoring --- .../traccar/protocol/Gl200TextProtocolDecoder.java | 52 +++++++++++++++++++--- 1 file changed, 45 insertions(+), 7 deletions(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index c0a2a2ea0..0e08066ab 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -42,6 +42,7 @@ import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.TimeZone; +import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -51,6 +52,37 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { private final DateFormat dateFormat; + private static final HashMap devices = new HashMap() {{ + put("52", "GL50"); + put("55", "GL50B"); + put("02", "GL200"); + put("04", "GV200"); + put("06", "GV300"); + put("08", "GMT100"); + put("09", "GV50P"); // GV50 Plus + put("0F", "GV55"); + put("50", "GV55W"); + put("10", "GV55 LITE"); + put("11", "GL500"); + put("1A", "GL300"); + put("1F", "GV500"); + put("5E", "GV500MAP"); + put("25", "GV300"); // New Version + put("35", "GV200"); // New Version + put("27", "GV300W"); + put("2F", "GV55"); // New Version + put("30", "GL300"); // New Version + put("36", "GV500"); // New Version + put("2C", "GL300W"); // New version + put("3F", "GMT100"); // New version + put("F8", "GV800W"); + put("41", "GV75W"); + put("FC", "GV600W"); + put("6E", "GV310LAU"); + put("802004", "GV58LAU"); + put("802005", "GV355CEU"); + }}; + public Gl200TextProtocolDecoder(Protocol protocol) { super(protocol); dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); @@ -62,9 +94,14 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { ignoreFixTime = getConfig().getBoolean(Keys.PROTOCOL_IGNORE_FIX_TIME.withPrefix(getProtocolName())); } - private String getDeviceModel(DeviceSession deviceSession, String value) { - String model = value.isEmpty() ? getDeviceModel(deviceSession) : value; - return model != null ? model.toUpperCase() : ""; + private String getDeviceModel(String protocolVersion) { + if (devices.containsKey(protocolVersion.substring(0, 2))) { + return devices.get(protocolVersion.substring(0, 2)); + } + if (devices.containsKey(protocolVersion.substring(0, 6))) { + return devices.get(protocolVersion.substring(0, 6)); + } + return ""; } private Position initPosition(Parser parser, Channel channel, SocketAddress remoteAddress) { @@ -471,7 +508,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { private Object decodeCan(Channel channel, SocketAddress remoteAddress, String[] v) throws ParseException { int index = 0; index += 1; // header - index += 1; // protocol version + String protocolVersion = v[index++]; // protocol version DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, v[index++]); if (deviceSession == null) { return null; @@ -480,7 +517,8 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - String model = getDeviceModel(deviceSession, v[index++]); + String model = getDeviceModel(protocolVersion); + index += 1; // device name index += 1; // report type index += 1; // can bus state long reportMask = Long.parseLong(v[index++], 16); @@ -888,13 +926,13 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { private Object decodeEri(Channel channel, SocketAddress remoteAddress, String[] v) throws ParseException { int index = 0; index += 1; // header - index += 1; // protocol version + String protocolVersion = v[index++]; // protocol version DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, v[index++]); if (deviceSession == null) { return null; } - String model = getDeviceModel(deviceSession, v[index++]); + String model = getDeviceModel(protocolVersion); long mask = Long.parseLong(v[index++], 16); Double power = v[index++].isEmpty() ? null : Integer.parseInt(v[index - 1]) * 0.001; index += 1; // report type -- cgit v1.2.3 From b95fa6a433fe9fc464aa59256d0b33da46809d0b Mon Sep 17 00:00:00 2001 From: jcardus Date: Fri, 29 Mar 2024 19:43:06 +0000 Subject: C2 and F1 fallback to device name and attribute --- .../java/org/traccar/protocol/Gl200TextProtocolDecoder.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index 0e08066ab..817e03f67 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -79,6 +79,8 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { put("41", "GV75W"); put("FC", "GV600W"); put("6E", "GV310LAU"); + put("C2", "GV600M"); + put("F1", "GV350M"); put("802004", "GV58LAU"); put("802005", "GV355CEU"); }}; @@ -94,14 +96,15 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { ignoreFixTime = getConfig().getBoolean(Keys.PROTOCOL_IGNORE_FIX_TIME.withPrefix(getProtocolName())); } - private String getDeviceModel(String protocolVersion) { + private String getDeviceModel(DeviceSession deviceSession, String value, String protocolVersion) { if (devices.containsKey(protocolVersion.substring(0, 2))) { return devices.get(protocolVersion.substring(0, 2)); } if (devices.containsKey(protocolVersion.substring(0, 6))) { return devices.get(protocolVersion.substring(0, 6)); } - return ""; + String model = value.isEmpty() ? getDeviceModel(deviceSession) : value; + return model != null ? model.toUpperCase() : ""; } private Position initPosition(Parser parser, Channel channel, SocketAddress remoteAddress) { @@ -517,8 +520,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - String model = getDeviceModel(protocolVersion); - index += 1; // device name + String model = getDeviceModel(deviceSession, v[index++], protocolVersion); index += 1; // report type index += 1; // can bus state long reportMask = Long.parseLong(v[index++], 16); @@ -932,7 +934,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { return null; } - String model = getDeviceModel(protocolVersion); + String model = getDeviceModel(deviceSession, v[index++], protocolVersion); long mask = Long.parseLong(v[index++], 16); Double power = v[index++].isEmpty() ? null : Integer.parseInt(v[index - 1]) * 0.001; index += 1; // report type -- cgit v1.2.3 From 7ed2a8b54d9e269b0b5d180dc976d38926cd5bac Mon Sep 17 00:00:00 2001 From: jcardus Date: Fri, 29 Mar 2024 19:58:44 +0000 Subject: order device models by id use getDeviceModel --- .../traccar/protocol/Gl200TextProtocolDecoder.java | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index 817e03f67..16098bc05 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -52,35 +52,35 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { private final DateFormat dateFormat; - private static final HashMap devices = new HashMap() {{ - put("52", "GL50"); - put("55", "GL50B"); + private static final HashMap devices = new HashMap() {{ put("02", "GL200"); put("04", "GV200"); put("06", "GV300"); put("08", "GMT100"); put("09", "GV50P"); // GV50 Plus put("0F", "GV55"); - put("50", "GV55W"); put("10", "GV55 LITE"); put("11", "GL500"); put("1A", "GL300"); put("1F", "GV500"); - put("5E", "GV500MAP"); put("25", "GV300"); // New Version - put("35", "GV200"); // New Version put("27", "GV300W"); + put("2C", "GL300W"); // New version put("2F", "GV55"); // New Version put("30", "GL300"); // New Version + put("35", "GV200"); // New Version put("36", "GV500"); // New Version - put("2C", "GL300W"); // New version put("3F", "GMT100"); // New version - put("F8", "GV800W"); put("41", "GV75W"); - put("FC", "GV600W"); + put("50", "GV55W"); + put("52", "GL50"); + put("55", "GL50B"); + put("5E", "GV500MAP"); put("6E", "GV310LAU"); put("C2", "GV600M"); put("F1", "GV350M"); + put("F8", "GV800W"); + put("FC", "GV600W"); put("802004", "GV58LAU"); put("802005", "GV355CEU"); }}; @@ -248,7 +248,8 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ICCID, parser.next()); position.set(Position.KEY_RSSI, parser.nextInt()); - if (protocolVersion.startsWith("6E")) { // GV310LAU + String model = getDeviceModel(deviceSession, "", protocolVersion); + if (model.equals("GV310LAU")) { position.set(Position.KEY_POWER, parser.nextDouble() / 1000); // odometer or external power } else { parser.next(); // odometer or external power @@ -263,7 +264,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_ADC + 1, parser.next()); position.set(Position.PREFIX_ADC + 2, parser.next()); - if (protocolVersion.startsWith("6E")) { + if (model.equals("GV310LAU")) { position.set(Position.PREFIX_ADC + 3, parser.next()); } -- cgit v1.2.3 From 1450fc6a6cb3d56eefff7d0f222a868b3568c592 Mon Sep 17 00:00:00 2001 From: jcardus Date: Fri, 29 Mar 2024 20:04:18 +0000 Subject: fix trailing spaces fix naming convention --- .../java/org/traccar/protocol/Gl200TextProtocolDecoder.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index 16098bc05..9b7737b36 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -52,7 +52,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { private final DateFormat dateFormat; - private static final HashMap devices = new HashMap() {{ + private static final HashMap DEVICE_MODELS = new HashMap() {{ put("02", "GL200"); put("04", "GV200"); put("06", "GV300"); @@ -97,11 +97,11 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { } private String getDeviceModel(DeviceSession deviceSession, String value, String protocolVersion) { - if (devices.containsKey(protocolVersion.substring(0, 2))) { - return devices.get(protocolVersion.substring(0, 2)); + if (DEVICE_MODELS.containsKey(protocolVersion.substring(0, 2))) { + return DEVICE_MODELS.get(protocolVersion.substring(0, 2)); } - if (devices.containsKey(protocolVersion.substring(0, 6))) { - return devices.get(protocolVersion.substring(0, 6)); + if (DEVICE_MODELS.containsKey(protocolVersion.substring(0, 6))) { + return DEVICE_MODELS.get(protocolVersion.substring(0, 6)); } String model = value.isEmpty() ? getDeviceModel(deviceSession) : value; return model != null ? model.toUpperCase() : ""; -- cgit v1.2.3 From 078ddb342c7af83d22767224a7d5b7c7e8ab4fe7 Mon Sep 17 00:00:00 2001 From: jcardus Date: Fri, 29 Mar 2024 21:57:07 +0000 Subject: Statics should be above instance variables. remove comments --- .../traccar/protocol/Gl200TextProtocolDecoder.java | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index 9b7737b36..e30fafcaf 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -47,30 +47,26 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { - - private boolean ignoreFixTime; - - private final DateFormat dateFormat; - + private static final HashMap DEVICE_MODELS = new HashMap() {{ put("02", "GL200"); put("04", "GV200"); put("06", "GV300"); put("08", "GMT100"); - put("09", "GV50P"); // GV50 Plus + put("09", "GV50P"); put("0F", "GV55"); put("10", "GV55 LITE"); put("11", "GL500"); put("1A", "GL300"); put("1F", "GV500"); - put("25", "GV300"); // New Version + put("25", "GV300"); put("27", "GV300W"); - put("2C", "GL300W"); // New version - put("2F", "GV55"); // New Version - put("30", "GL300"); // New Version - put("35", "GV200"); // New Version - put("36", "GV500"); // New Version - put("3F", "GMT100"); // New version + put("2C", "GL300W"); + put("2F", "GV55"); + put("30", "GL300"); + put("35", "GV200"); + put("36", "GV500"); + put("3F", "GMT100"); put("41", "GV75W"); put("50", "GV55W"); put("52", "GL50"); @@ -85,6 +81,10 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { put("802005", "GV355CEU"); }}; + private boolean ignoreFixTime; + + private final DateFormat dateFormat; + public Gl200TextProtocolDecoder(Protocol protocol) { super(protocol); dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); @@ -108,13 +108,13 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { } private Position initPosition(Parser parser, Channel channel, SocketAddress remoteAddress) { - if (parser.matches()) { - DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); - if (deviceSession != null) { - Position position = new Position(getProtocolName()); - position.setDeviceId(deviceSession.getDeviceId()); - return position; - } +if (parser.matches()) { + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); + if (deviceSession != null) { + Position position = new Position(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + return position; +} } return null; } @@ -294,7 +294,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { private Object decodeVer(Channel channel, SocketAddress remoteAddress, String sentence) { Parser parser = new Parser(PATTERN_VER, sentence); - Position position = initPosition(parser, channel, remoteAddress); + Position position = initPosition(parser, channel, remoteAddress); if (position == null) { return null; } -- cgit v1.2.3 From b0b1257473b8895ba4e8b867442c13f5b7c048f7 Mon Sep 17 00:00:00 2001 From: jcardus Date: Fri, 29 Mar 2024 21:59:13 +0000 Subject: fix identation --- .../org/traccar/protocol/Gl200TextProtocolDecoder.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index e30fafcaf..bf8644033 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -108,13 +108,13 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { } private Position initPosition(Parser parser, Channel channel, SocketAddress remoteAddress) { -if (parser.matches()) { - DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); - if (deviceSession != null) { - Position position = new Position(getProtocolName()); - position.setDeviceId(deviceSession.getDeviceId()); - return position; -} + if (parser.matches()) { + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); + if (deviceSession != null) { + Position position = new Position(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + return position; + } } return null; } -- cgit v1.2.3 From 51dd3b44a6e81f523f37aacb23ad5b39de1d9eca Mon Sep 17 00:00:00 2001 From: jcardus Date: Fri, 29 Mar 2024 22:00:32 +0000 Subject: remove trailing spaces --- src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index bf8644033..b953aa8ca 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -83,7 +83,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { private boolean ignoreFixTime; - private final DateFormat dateFormat; + private final DateFormat dateFormat; public Gl200TextProtocolDecoder(Protocol protocol) { super(protocol); -- cgit v1.2.3 From 432a59c8e15e0ce5ed0cb472864f627e3eadea6e Mon Sep 17 00:00:00 2001 From: jcardus Date: Fri, 29 Mar 2024 22:26:21 +0000 Subject: 50: Line has trailing spaces --- src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index b953aa8ca..1d4688e69 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -47,7 +47,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { - + private static final HashMap DEVICE_MODELS = new HashMap() {{ put("02", "GL200"); put("04", "GV200"); -- cgit v1.2.3 From 829387a48e278ea7428ee719cf6973ecf36271b9 Mon Sep 17 00:00:00 2001 From: jcardus Date: Fri, 29 Mar 2024 22:32:00 +0000 Subject: weird --- src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index 1d4688e69..623352106 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -294,7 +294,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { private Object decodeVer(Channel channel, SocketAddress remoteAddress, String sentence) { Parser parser = new Parser(PATTERN_VER, sentence); - Position position = initPosition(parser, channel, remoteAddress); + Position position = initPosition(parser, channel, remoteAddress); if (position == null) { return null; } -- cgit v1.2.3 From 9e750264dd9a1cbfbd7e1aadfdeedbcdbb5d0a0d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 30 Mar 2024 07:19:43 -0700 Subject: Refactor and add more models --- .../traccar/protocol/Gl200TextProtocolDecoder.java | 104 ++++++++++++--------- .../protocol/Gl200TextProtocolDecoderTest.java | 16 ++-- 2 files changed, 65 insertions(+), 55 deletions(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index 623352106..5ac7b2417 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -41,45 +41,52 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.TimeZone; -import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { - private static final HashMap DEVICE_MODELS = new HashMap() {{ - put("02", "GL200"); - put("04", "GV200"); - put("06", "GV300"); - put("08", "GMT100"); - put("09", "GV50P"); - put("0F", "GV55"); - put("10", "GV55 LITE"); - put("11", "GL500"); - put("1A", "GL300"); - put("1F", "GV500"); - put("25", "GV300"); - put("27", "GV300W"); - put("2C", "GL300W"); - put("2F", "GV55"); - put("30", "GL300"); - put("35", "GV200"); - put("36", "GV500"); - put("3F", "GMT100"); - put("41", "GV75W"); - put("50", "GV55W"); - put("52", "GL50"); - put("55", "GL50B"); - put("5E", "GV500MAP"); - put("6E", "GV310LAU"); - put("C2", "GV600M"); - put("F1", "GV350M"); - put("F8", "GV800W"); - put("FC", "GV600W"); - put("802004", "GV58LAU"); - put("802005", "GV355CEU"); - }}; + private static final Map PROTOCOL_MODELS = Map.ofEntries( + Map.entry("02", "GL200"), + Map.entry("04", "GV200"), + Map.entry("06", "GV300"), + Map.entry("08", "GMT100"), + Map.entry("09", "GV50P"), + Map.entry("0F", "GV55"), + Map.entry("10", "GV55 LITE"), + Map.entry("11", "GL500"), + Map.entry("1A", "GL300"), + Map.entry("1F", "GV500"), + Map.entry("25", "GV300"), + Map.entry("27", "GV300W"), + Map.entry("28", "GL300VC"), + Map.entry("2C", "GL300W"), + Map.entry("2F", "GV55"), + Map.entry("30", "GL300"), + Map.entry("31", "GV65"), + Map.entry("35", "GV200"), + Map.entry("36", "GV500"), + Map.entry("3F", "GMT100"), + Map.entry("40", "GL500"), + Map.entry("41", "GV75W"), + Map.entry("42", "GT501"), + Map.entry("44", "GL530"), + Map.entry("45", "GB100"), + Map.entry("50", "GV55W"), + Map.entry("52", "GL50"), + Map.entry("55", "GL50B"), + Map.entry("5E", "GV500MAP"), + Map.entry("6E", "GV310LAU"), + Map.entry("C2", "GV600M"), + Map.entry("DC", "GV600MG"), + Map.entry("DE", "GL500M"), + Map.entry("F1", "GV350M"), + Map.entry("F8", "GV800W"), + Map.entry("FC", "GV600W"), + Map.entry("802004", "GV58LAU"), + Map.entry("802005", "GV355CEU")); private boolean ignoreFixTime; @@ -96,15 +103,18 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { ignoreFixTime = getConfig().getBoolean(Keys.PROTOCOL_IGNORE_FIX_TIME.withPrefix(getProtocolName())); } - private String getDeviceModel(DeviceSession deviceSession, String value, String protocolVersion) { - if (DEVICE_MODELS.containsKey(protocolVersion.substring(0, 2))) { - return DEVICE_MODELS.get(protocolVersion.substring(0, 2)); + private String getDeviceModel(DeviceSession deviceSession, String protocolVersion) { + String declaredModel = getDeviceModel(deviceSession); + if (declaredModel != null) { + return declaredModel.toUpperCase(); } - if (DEVICE_MODELS.containsKey(protocolVersion.substring(0, 6))) { - return DEVICE_MODELS.get(protocolVersion.substring(0, 6)); + if (PROTOCOL_MODELS.containsKey(protocolVersion.substring(0, 2))) { + return PROTOCOL_MODELS.get(protocolVersion.substring(0, 2)); } - String model = value.isEmpty() ? getDeviceModel(deviceSession) : value; - return model != null ? model.toUpperCase() : ""; + if (PROTOCOL_MODELS.containsKey(protocolVersion.substring(0, 6))) { + return PROTOCOL_MODELS.get(protocolVersion.substring(0, 6)); + } + return ""; } private Position initPosition(Parser parser, Channel channel, SocketAddress remoteAddress) { @@ -162,12 +172,12 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN_INF = new PatternBuilder() .text("+").expression("(?:RESP|BUFF):GTINF,") - .expression("(.{6}|.{10})?,") // protocol version + .expression("(.{6}|.{10})?,") // protocol version .number("(d{15}|x{14}),") // imei .expression("(?:[0-9A-Z]{17},)?") // vin .expression("(?:[^,]+)?,") // device name .number("(xx),") // state - .expression("([0-9Ff]{20})?,") // iccid + .expression("([0-9Ff]{20})?,") // iccid .number("(d{1,2}),") // rssi .number("d{1,2},") .expression("[01]{1,2},") // external power @@ -248,9 +258,9 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ICCID, parser.next()); position.set(Position.KEY_RSSI, parser.nextInt()); - String model = getDeviceModel(deviceSession, "", protocolVersion); + String model = getDeviceModel(deviceSession, protocolVersion); if (model.equals("GV310LAU")) { - position.set(Position.KEY_POWER, parser.nextDouble() / 1000); // odometer or external power + position.set(Position.KEY_POWER, parser.nextDouble() / 1000); } else { parser.next(); // odometer or external power } @@ -521,7 +531,8 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - String model = getDeviceModel(deviceSession, v[index++], protocolVersion); + String model = getDeviceModel(deviceSession, protocolVersion); + index += 1; // device name index += 1; // report type index += 1; // can bus state long reportMask = Long.parseLong(v[index++], 16); @@ -935,7 +946,8 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { return null; } - String model = getDeviceModel(deviceSession, v[index++], protocolVersion); + String model = getDeviceModel(deviceSession, protocolVersion); + index += 1; // device name long mask = Long.parseLong(v[index++], 16); Double power = v[index++].isEmpty() ? null : Integer.parseInt(v[index - 1]) * 0.001; index += 1; // report type diff --git a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java index 768704b68..bc1bee229 100644 --- a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java @@ -52,14 +52,14 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { "+RESP:GTFRI,5E0100,862061048023666,,,12940,10,1,1,0.0,97,179.8,-90.366478,38.735379,20230616183231,0310,0410,6709,03ADF710,00,6223.7,,,,,110000,,,,202306161834$")); verifyAttribute(decoder, buffer( - "+BUFF:GTERI,410502,864802030794634,GV75W,00000001,,10,1,1,0.0,0,3027.8,-78.706612,-0.955699,20230418170736,0740,0002,A08C,2AB72D,00,0.0,,,,100,110000,1,0099,20230418171004,8B98$"), + "+BUFF:GTERI,410502,864802030794634,,00000001,,10,1,1,0.0,0,3027.8,-78.706612,-0.955699,20230418170736,0740,0002,A08C,2AB72D,00,0.0,,,,100,110000,1,0099,20230418171004,8B98$"), Position.KEY_FUEL_LEVEL, 153); verifyPositions(decoder, false, buffer( "+BUFF:GTFRI,2E0503,861106050005423,,,0,1,,,,,,,,,,,,0,0,,98,1,0,,,20200101000001,0083$")); verifyAttribute(decoder, buffer( - "+RESP:GTERI,271002,863457051562823,GV300,00000002,,10,1,1,0.0,15,28.2,-58.695253,-34.625413,20230119193305,0722,0007,1168,16B3BB,00,0.0,,,,99,210100,2,1,28F8A149F69A3C25,1,0190,20230119193314,07C7$"), + "+RESP:GTERI,271002,863457051562823,,00000002,,10,1,1,0.0,15,28.2,-58.695253,-34.625413,20230119193305,0722,0007,1168,16B3BB,00,0.0,,,,99,210100,2,1,28F8A149F69A3C25,1,0190,20230119193314,07C7$"), Position.PREFIX_TEMP + 1, 25.0); verifyAttribute(decoder, buffer( @@ -176,7 +176,7 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { "+RESP:GTERI,310603,863286023345490,,00000002,,10,1,2,0.3,0,155.7,8.000000,52.000000,20171215213040,0262,0002,1450,9F13,00,1130.3,00539:27:19,,,110000,2,1,28FFD5239115034E,1,,20171215213041,27C7$")); verifyPositions(decoder, buffer( - "+RESP:GTERI,250C02,868789023691057,GV300,00000019,,10,1,1,0.0,196,2258.0,-99.201807,19.559242,20180214002957,0334,0003,235B,7F8D,00,6786.7,,,,100,110000,1,0394,1,4,100.0,100.0,20180214003006,C72B$")); + "+RESP:GTERI,250C02,868789023691057,,00000019,,10,1,1,0.0,196,2258.0,-99.201807,19.559242,20180214002957,0334,0003,235B,7F8D,00,6786.7,,,,100,110000,1,0394,1,4,100.0,100.0,20180214003006,C72B$")); verifyAttributes(decoder, buffer( "+RESP:GTCAN,310603,863286023335723,gv65,00,1,C03FFFFF,,0,,719601.00,,,,,,,,274.99,179.02,95.98,84761.00,,,0,,0,,,0,0.0,216,29.8,-2.155296,51.899400,20180209172714,0234,0010,53F3,8D38,00,20180211002128,E94E$")); @@ -203,7 +203,7 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { "+RESP:GTOBD,360701,864251020253807,LSGTC58UX7Y067312,GV500,0,70FFFF,LSGTC58UX7Y067312,1,12309,983A8140,0,0,33,nan,,0,0,0,,10,0,,0,4.4,0,83.7,36.235142,49.967324,20170829112348,0255,0001,2760,9017,00,690.1,20170829112400,3456$")); verifyPositions(decoder, buffer( - "+RESP:GTERI,060502,861074023620928,GV300,00000002,27822,10,1,1,0.0,84,2870.9,-78.531796,-0.277329,20170825045344,,,,,,0.0,01138:30:24,,,83,220104,2,1,28FF2776A2150308,1,FFAD,0,20170825045348,A88C$")); + "+RESP:GTERI,060502,861074023620928,,00000002,27822,10,1,1,0.0,84,2870.9,-78.531796,-0.277329,20170825045344,,,,,,0.0,01138:30:24,,,83,220104,2,1,28FF2776A2150308,1,FFAD,0,20170825045348,A88C$")); verifyAttributes(decoder, buffer( "+RESP:GTINF,280500,A1000043D20139,GL300VC,41,,31,0,0,,,3.87,0,1,1,,,20170802150751,70,,48.0,,,20170802112145,03AC$")); @@ -218,7 +218,7 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { "+RESP:GTTRI,862370030005908,1,0,99,1,0.0,354,18.5,18.821100,-34.084002,20170607152024,0655,0001,00DD,1CAE,00,0103010100,20170607172115,3E7D$")); verifyPositions(decoder, buffer( - "+RESP:GTERI,060800,861074023677175,GV300,00000002,12351,10,1,1,0.0,0,2862.4,-78.467273,-0.164998,20170529181717,,,,,,0.0,00259:11:50,,,0,210104,2,1,28E17436060000E2,1,015F,0,20170529181723,2824$")); + "+RESP:GTERI,060800,861074023677175,,00000002,12351,10,1,1,0.0,0,2862.4,-78.467273,-0.164998,20170529181717,,,,,,0.0,00259:11:50,,,0,210104,2,1,28E17436060000E2,1,015F,0,20170529181723,2824$")); verifyPosition(decoder, buffer( "+RESP:GTSWG,110100,358688000000158,,1,0,2.1,0,27.1,121.390717,31.164424,20110901073917,0460,0000,1878,0873,,20110901154653,0015$")); @@ -239,7 +239,7 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { "+RESP:GTFRI,060228,862894020180553,,14827,10,1,1,3.4,199,409.6,-63.174466,-17.739317,20170407121823,0000,0000,0000,0000,00,15989.5,01070:43:13,13,180,0,220101,,,,20170407081824,9607$")); verifyPositions(decoder, buffer( - "+RESP:GTERI,060502,861074023376992,GV300,00000002,27239,10,1,1,0.2,312,183.3,-79.320820,-2.499110,20170401212005,0740,0000,EE4E,C98F,00,0.0,02114:36:35,,,90,220504,2,0,0,20170401212007,9E3D$")); + "+RESP:GTERI,060502,861074023376992,,00000002,27239,10,1,1,0.2,312,183.3,-79.320820,-2.499110,20170401212005,0740,0000,EE4E,C98F,00,0.0,02114:36:35,,,90,220504,2,0,0,20170401212007,9E3D$")); verifyPositions(decoder, buffer( "+RESP:GTFRI,060502,861074023689626,,25202,10,1,1,0.0,0,2744.1,-78.261047,0.023452,20170401211940,,,,,,0.0,00079:19:15,,,51,110000,,,,20170401212003,4DA7$")); @@ -251,7 +251,7 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { "+RESP:GTERI,06020B,862170010196747,,00000000,,10,1,2,1.8,0,-2.5,117.198440,31.845219,20120802061037,0460,0000,5663,0358,00,0.0,,,,0,410000,20120802061040,0012$")); verifyPositions(decoder, buffer( - "+RESP:GTERI,060502,861074023692562,GV300,00000002,14197,10,1,1,0.2,220,491.8,-79.064212,-2.159754,20170401212007,0740,0000,EE49,CE25,00,0.0,01509:10:58,,,87,220104,2,0,0,20170401212010,D14D$")); + "+RESP:GTERI,060502,861074023692562,,00000002,14197,10,1,1,0.2,220,491.8,-79.064212,-2.159754,20170401212007,0740,0000,EE49,CE25,00,0.0,01509:10:58,,,87,220104,2,0,0,20170401212010,D14D$")); verifyPositions(decoder, buffer( "+RESP:GTFRI,210102,354524044925825,,1,1,1,29,2.8,0,133.7,-90.203063,32.265473,20170318005208,,,,,10800,4,20170318005208,0002$")); @@ -498,8 +498,6 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { "+RESP:GTINF,6E0202,868589060187625,RA82,11,89883030000091225018,41,0,1,12349,,4.15,0,1,0,0,20240328231013,0,0,0,0,00,00,+0000,0,20240328231015,7D4F"), Position.PREFIX_ADC + 3, "0"); - decoder.setModelOverride("GV355CEU"); - verifyAttributes(decoder, buffer( "+RESP:GTCAN,8020050605,867488060270575,,00,1,FFFFFFFF,8LBETF3W4N0001613,,,22.54,0,,,,,,,7.84,4.61,3.24,3.33,,8080,,,00,0.00,0.00,1,14,14,2371,0,001FFFFF,,,,,,,,,7158,9998,0,7.84,0.00,0.00,558,,,,,,,C0,,,,,0,0.0,346,2848.5,-78.592371,-0.968132,20240202083437,0740,0002,526C,00AE7907,00,20240202083440,3F6D$")); -- cgit v1.2.3 From 3066f3ccfa2a674fae27922f9f94b5e16eb68f9b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 30 Mar 2024 07:29:04 -0700 Subject: Model detection optimization --- .../org/traccar/protocol/Gl200TextProtocolDecoder.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index 5ac7b2417..b14f64f4a 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -79,6 +79,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { Map.entry("55", "GL50B"), Map.entry("5E", "GV500MAP"), Map.entry("6E", "GV310LAU"), + Map.entry("BD", "CV200"), Map.entry("C2", "GV600M"), Map.entry("DC", "GV600MG"), Map.entry("DE", "GL500M"), @@ -108,13 +109,14 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { if (declaredModel != null) { return declaredModel.toUpperCase(); } - if (PROTOCOL_MODELS.containsKey(protocolVersion.substring(0, 2))) { - return PROTOCOL_MODELS.get(protocolVersion.substring(0, 2)); - } - if (PROTOCOL_MODELS.containsKey(protocolVersion.substring(0, 6))) { - return PROTOCOL_MODELS.get(protocolVersion.substring(0, 6)); + String versionPrefix; + if (protocolVersion.length() > 6) { + versionPrefix = protocolVersion.substring(0, 6); + } else { + versionPrefix = protocolVersion.substring(0, 2); } - return ""; + String model = PROTOCOL_MODELS.get(versionPrefix); + return model != null ? model : ""; } private Position initPosition(Parser parser, Channel channel, SocketAddress remoteAddress) { -- cgit v1.2.3 From 8fe2d697064c88f5dadf5ca3aeca51ba7e925fd9 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 30 Mar 2024 07:38:13 -0700 Subject: Support virtual ignition messages --- src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java | 6 ++++-- .../java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java index b14f64f4a..775e98401 100644 --- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -1031,7 +1031,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { } private static final Pattern PATTERN_IGN = new PatternBuilder() - .text("+").expression("(?:RESP|BUFF):GTIG[NF],") + .text("+").expression("(?:RESP|BUFF):GT[IV]G[NF],") .expression("(?:.{6}|.{10})?,") // protocol version .number("(d{15}|x{14}),") // imei .expression("[^,]*,") // device name @@ -1055,7 +1055,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { decodeLocation(position, parser); - position.set(Position.KEY_IGNITION, sentence.contains("IGN")); + position.set(Position.KEY_IGNITION, sentence.contains("GN")); position.set(Position.KEY_HOURS, parseHours(parser.next())); position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); @@ -1677,6 +1677,8 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { break; case "IGN": case "IGF": + case "VGN": + case "VGF": result = decodeIgn(channel, remoteAddress, sentence); break; case "LSW": diff --git a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java index bc1bee229..4cccf8fa2 100644 --- a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java @@ -11,6 +11,14 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { var decoder = inject(new Gl200TextProtocolDecoder(null)); + verifyAttribute(decoder, buffer( + "+RESP:GTVGN,C2010D,869653060009939,GV600M,453966,0,0.0,0,163.9,10.239379,45.931389,20231210233723,0222,0010,2F31,006D7621,,,0.0,20240107182623,143F$"), + Position.KEY_IGNITION, true); + + verifyAttribute(decoder, buffer( + "+RESP:GTIGF,8020050502,867488060278727,,509,1,0.0,184,32.6,14.003446,42.654554,20240219124629,0222,0001,0FAD,0497F715,00,,0.0,20240219124630,FD2F$"), + Position.KEY_IGNITION, false); + verifyPositions(decoder, buffer( "+RESP:GTERI,C2010D,869653060009939,GV600M,00000100,,10,1,0,0.0,0,163.9,10.239379,45.931389,20231210233723,0222,0010,2F31,006D7621,,0.0,,,,3,410000,,1,0,6,4,0,,01BF,Sondaporte,EA7D0A3882F6,1,3484,21.81,43,00,00,0,0,0,20240114221802,1875$")); -- cgit v1.2.3 From 5606f054244fc1ea2d5929152dd5c997d04f66fa Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 1 Apr 2024 20:46:28 -0700 Subject: Support binary Atrack motion --- src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java | 5 ++++- src/test/java/org/traccar/protocol/AtrackProtocolDecoderTest.java | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java index 8896dcfb0..834f4f16c 100644 --- a/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2021 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. @@ -325,6 +325,9 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { case "SA": position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); break; + case "MT": + position.set(Position.KEY_MOTION, buf.readUnsignedByte() > 0); + break; case "MV": position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.1); break; diff --git a/src/test/java/org/traccar/protocol/AtrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AtrackProtocolDecoderTest.java index be6fb5c45..7115e0ea6 100644 --- a/src/test/java/org/traccar/protocol/AtrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AtrackProtocolDecoderTest.java @@ -43,6 +43,9 @@ public class AtrackProtocolDecoderTest extends ProtocolTest { decoder.setCustom(true); + verifyPositions(decoder, binary( + "405064e503092d8600000000000f54ab660786b0660786b0660a12c4fa2e202d01cfd32a005a02000022b700070000000000000007d007d000254349254d56254256254d5400007f002800660786ec660786ec660a12c4fa2e202d01cfd32a005a02000022b700070000000000000007d007d000254349254d56254256254d5400007f0028006607872866078728660a12c4fa2e202d01cfd32a005a02000022b700070000000000000007d007d000254349254d56254256254d5400007f0028006607876466078764660a12c4fa2e202d01cfd32a005a02000022b700070000000000000007d007d000254349254d56254256254d5400007f002800660787a0660787a0660a12c4fa2e202d01cfd32a005a02000022b700060000000000000007d007d000254349254d56254256254d5400007f002800660787dc660787dc660a12c4fa2e202d01cfd32a005a02000022b700060000000000000007d007d000254349254d56254256254d5400007f0028006607881866078818660a12c4fa2e202d01cfd32a005a02000022b700060000000000000007d007d000254349254d56254256254d5400007f0028006607885466078854660a12c4fa2e202d01cfd32a005a02000022b700060000000000000007d007d000254349254d56254256254d5400007f0028006607889066078890660a12c4fa2e202d01cfd32a005a02000022b700060000000000000007d007d000254349254d56254256254d5400007f002800660788cc660788cc660a12c4fa2e202d01cfd32a005a02000022b700060000000000000007d007d000254349254d56254256254d5400007f0028006607890866078908660a12c4fa2e202d01cfd32a005a02000022b700070000000000000007d007d000254349254d56254256254d5400007f0028006607894466078944660a12c4fa2e202d01cfd32a005a02000022b700070000000000000007d007d000254349254d56254256254d5400007f0028006607898066078980660a12c4fa2e202d01cfd32a005a02000022b700070000000000000007d007d000254349254d56254256254d5400007f002800")); + verifyPositions(decoder, binary( "4050d78502e01d29000312fa45441d6d647d8e67647d8e67647eef190205437c021846e6001a020002d7f000070000000000000007d007d000254349254d5625525025564e254d4625454c25545225455425464c254d4c25464325534d25494e3025484125484225484325415400010c0000000000000000000000000000000000000000000000000e647d8e85647d8e86647eef190205437c021846e60019020002d7f000070000000000000007d007d000254349254d5625525025564e254d4625454c25545225455425464c254d4c25464325534d25494e3025484125484225484325415400010c0000000000000000000000000000000000000000000000000e647d8ea3647d8ea4647eef190205437c021846e60019020002d7f000070000000000000007d007d000254349254d5625525025564e254d4625454c25545225455425464c254d4c25464325534d25494e3025484125484225484325415400010b0000000000000000000000000000000000000000000000000e647d8ec1647d8ec2647eef190205437c021846e60019020002d7f000070000000000000007d007d000254349254d5625525025564e254d4625454c25545225455425464c254d4c25464325534d25494e3025484125484225484325415400010a0000000000000000000000000000000000000000000000000e647d8edf647d8ee0647eef190205437c021846e60019020002d7f000070000000000000007d007d000254349254d5625525025564e254d4625454c25545225455425464c254d4c25464325534d25494e3025484125484225484325415400010a0000000000000000000000000000000000000000000000000e647d8efd647d8efe647eef190205437c021846e60019020002d7f000070000000000000007d007d000254349254d5625525025564e254d4625454c25545225455425464c254d4c25464325534d25494e3025484125484225484325415400010a0000000000000000000000000000000000000000000000000e")); -- cgit v1.2.3 From 5d571897e0d60c574cbb9ed85a04acfb40ce7f3c Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 5 Apr 2024 17:39:48 -0700 Subject: Decode additional VL502 data --- .../traccar/protocol/HuabaoProtocolDecoder.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index 2186fb91f..648c5fb42 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -979,6 +979,12 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { case 0x0103: position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedInt() * 0.01); break; + case 0x0111: + position.set("fuelTemp", buf.readUnsignedByte() - 40); + break; + case 0x012E: + position.set("oilLevel", buf.readUnsignedShort() * 0.1); + break; case 0x052A: position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedShort() * 0.01); break; @@ -1113,6 +1119,30 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { } getLastLocation(position, time); break; + case 0x15: + int event = buf.readInt(); + switch (event) { + case 51: + position.set(Position.KEY_ALARM, Position.ALARM_ACCELERATION); + break; + case 52: + position.set(Position.KEY_ALARM, Position.ALARM_BRAKING); + break; + case 53: + position.set(Position.KEY_ALARM, Position.ALARM_CORNERING); + break; + case 54: + position.set(Position.KEY_ALARM, Position.ALARM_LANE_CHANGE); + break; + case 56: + position.set(Position.KEY_ALARM, Position.ALARM_ACCIDENT); + break; + default: + position.set(Position.KEY_EVENT, event); + break; + } + getLastLocation(position, time); + break; default: return null; } -- cgit v1.2.3