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(-) 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