aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <atananaev@lyft.com>2020-12-29 13:05:07 -0800
committerAnton Tananaev <atananaev@lyft.com>2020-12-29 13:05:07 -0800
commitf94951e7e78956b2bbd438665ff290a472afde76 (patch)
tree21ae964507b4e4e3a3c7f657e9057375c35701d1 /src/main/java/org/traccar/protocol
parent152d8fe43e4e7c15308ea39a19ac6c10da871ef7 (diff)
downloadtrackermap-server-f94951e7e78956b2bbd438665ff290a472afde76.tar.gz
trackermap-server-f94951e7e78956b2bbd438665ff290a472afde76.tar.bz2
trackermap-server-f94951e7e78956b2bbd438665ff290a472afde76.zip
Migrate more boolean keys
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java3
-rw-r--r--src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java21
-rw-r--r--src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java6
-rw-r--r--src/main/java/org/traccar/protocol/H02ProtocolDecoder.java3
-rw-r--r--src/main/java/org/traccar/protocol/Mta6Protocol.java5
-rw-r--r--src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java3
-rw-r--r--src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java3
-rw-r--r--src/main/java/org/traccar/protocol/WialonProtocol.java8
-rw-r--r--src/main/java/org/traccar/protocol/XexunProtocol.java5
9 files changed, 35 insertions, 22 deletions
diff --git a/src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java b/src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java
index 5aaacf5a1..f11312428 100644
--- a/src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java
@@ -24,6 +24,7 @@ import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.Protocol;
+import org.traccar.config.Keys;
import org.traccar.helper.Checksum;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -302,7 +303,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
decodeEventData(position, buf, event);
}
- if (Context.getConfig().getBoolean(getProtocolName() + ".can")
+ if (Context.getConfig().getBoolean(Keys.PROTOCOL_CAN.withPrefix(getProtocolName()))
&& buf.isReadable() && (selector & 0x1000) != 0 && event == EVENT_DATA) {
decodeCanData(buf, position);
}
diff --git a/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java
index 56c00c7c1..ff7ef6c4a 100644
--- a/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java
@@ -23,6 +23,7 @@ import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.config.Keys;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -61,19 +62,23 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
public AtrackProtocolDecoder(Protocol protocol) {
super(protocol);
- longDate = Context.getConfig().getBoolean(getProtocolName() + ".longDate");
- decimalFuel = Context.getConfig().getBoolean(getProtocolName() + ".decimalFuel");
+ longDate = Context.getConfig().getBoolean(Keys.PROTOCOL_LONG_DATE.withPrefix(getProtocolName()));
+ decimalFuel = Context.getConfig().getBoolean(Keys.PROTOCOL_DECIMAL_FUEL.withPrefix(getProtocolName()));
- custom = Context.getConfig().getBoolean(getProtocolName() + ".custom");
- form = Context.getConfig().getString(getProtocolName() + ".form");
+ custom = Context.getConfig().getBoolean(Keys.PROTOCOL_CUSTOM.withPrefix(getProtocolName()));
+ form = Context.getConfig().getString(Keys.PROTOCOL_FORM.withPrefix(getProtocolName()));
if (form != null) {
custom = true;
}
- for (String pair : Context.getConfig().getString(getProtocolName() + ".alarmMap", "").split(",")) {
- if (!pair.isEmpty()) {
- alarmMap.put(
- Integer.parseInt(pair.substring(0, pair.indexOf('='))), pair.substring(pair.indexOf('=') + 1));
+ String alarmMapString = Context.getConfig().getString(Keys.PROTOCOL_ALARM_MAP.withPrefix(getProtocolName()));
+ if (alarmMapString != null) {
+ for (String pair : alarmMapString.split(",")) {
+ if (!pair.isEmpty()) {
+ alarmMap.put(
+ Integer.parseInt(pair.substring(0, pair.indexOf('='))),
+ pair.substring(pair.indexOf('=') + 1));
+ }
}
}
}
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
index ec569b71b..d438aa33d 100644
--- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -20,6 +20,7 @@ import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.config.Keys;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -49,8 +50,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
public Gl200TextProtocolDecoder(Protocol protocol) {
super(protocol);
-
- ignoreFixTime = Context.getConfig().getBoolean(getProtocolName() + ".ignoreFixTime");
+ ignoreFixTime = Context.getConfig().getBoolean(Keys.PROTOCOL_IGNORE_FIX_TIME.withPrefix(getProtocolName()));
}
private static final Pattern PATTERN_ACK = new PatternBuilder()
@@ -1147,7 +1147,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
decodeDeviceTime(position, parser);
- if (Context.getConfig().getBoolean(getProtocolName() + ".ack") && channel != null) {
+ if (channel != null && Context.getConfig().getBoolean(Keys.PROTOCOL_ACK.withPrefix(getProtocolName()))) {
channel.writeAndFlush(new NetworkMessage("+SACK:" + parser.next() + "$", remoteAddress));
}
diff --git a/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java b/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
index a5dc1860a..3f8611b85 100644
--- a/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
@@ -23,6 +23,7 @@ import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.config.Keys;
import org.traccar.helper.BcdUtil;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
@@ -331,7 +332,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
if (parser.hasNext() && parser.next().equals("V1")) {
sendResponse(channel, remoteAddress, id, "V1");
- } else if (Context.getConfig().getBoolean(getProtocolName() + ".ack")) {
+ } else if (Context.getConfig().getBoolean(Keys.PROTOCOL_ACK.withPrefix(getProtocolName()))) {
sendResponse(channel, remoteAddress, id, "R12");
}
diff --git a/src/main/java/org/traccar/protocol/Mta6Protocol.java b/src/main/java/org/traccar/protocol/Mta6Protocol.java
index 632a7df80..14a66ce5c 100644
--- a/src/main/java/org/traccar/protocol/Mta6Protocol.java
+++ b/src/main/java/org/traccar/protocol/Mta6Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2020 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.
@@ -22,6 +22,7 @@ import org.traccar.BaseProtocol;
import org.traccar.Context;
import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
+import org.traccar.config.Keys;
public class Mta6Protocol extends BaseProtocol {
@@ -33,7 +34,7 @@ public class Mta6Protocol extends BaseProtocol {
pipeline.addLast(new HttpRequestDecoder());
pipeline.addLast(new HttpObjectAggregator(65535));
pipeline.addLast(new Mta6ProtocolDecoder(
- Mta6Protocol.this, !Context.getConfig().getBoolean(getName() + ".can")));
+ Mta6Protocol.this, !Context.getConfig().getBoolean(Keys.PROTOCOL_CAN.withPrefix(getName()))));
}
});
}
diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 78bd33fa0..da60cf5d6 100644
--- a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -24,6 +24,7 @@ import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.config.Keys;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
import org.traccar.helper.UnitsConverter;
@@ -54,7 +55,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
public TeltonikaProtocolDecoder(Protocol protocol, boolean connectionless) {
super(protocol);
this.connectionless = connectionless;
- this.extended = Context.getConfig().getBoolean(getProtocolName() + ".extended");
+ this.extended = Context.getConfig().getBoolean(Keys.PROTOCOL_EXTENDED.withPrefix(getProtocolName()));
}
private void parseIdentification(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
diff --git a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
index 1a45fbf75..69fff5310 100644
--- a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -21,6 +21,7 @@ import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.config.Keys;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
@@ -39,7 +40,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
public Tk103ProtocolDecoder(Protocol protocol) {
super(protocol);
- decodeLow = Context.getConfig().getBoolean(getProtocolName() + ".decodeLow");
+ decodeLow = Context.getConfig().getBoolean(Keys.PROTOCOL_DECODE_LOW.withPrefix(getProtocolName()));
}
private static final Pattern PATTERN = new PatternBuilder()
diff --git a/src/main/java/org/traccar/protocol/WialonProtocol.java b/src/main/java/org/traccar/protocol/WialonProtocol.java
index fd183dd2c..cb6ea5319 100644
--- a/src/main/java/org/traccar/protocol/WialonProtocol.java
+++ b/src/main/java/org/traccar/protocol/WialonProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2020 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.
@@ -19,6 +19,7 @@ import org.traccar.BaseProtocol;
import org.traccar.Context;
import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
+import org.traccar.config.Keys;
import org.traccar.model.Command;
import io.netty.handler.codec.LineBasedFrameDecoder;
@@ -26,6 +27,7 @@ import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import java.nio.charset.StandardCharsets;
+
public class WialonProtocol extends BaseProtocol {
public WialonProtocol() {
@@ -38,7 +40,7 @@ public class WialonProtocol extends BaseProtocol {
@Override
protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast(new LineBasedFrameDecoder(4 * 1024));
- boolean utf8 = Context.getConfig().getBoolean(getName() + ".utf8");
+ boolean utf8 = Context.getConfig().getBoolean(Keys.PROTOCOL_UTF8.withPrefix(getName()));
if (utf8) {
pipeline.addLast(new StringEncoder(StandardCharsets.UTF_8));
pipeline.addLast(new StringDecoder(StandardCharsets.UTF_8));
@@ -54,7 +56,7 @@ public class WialonProtocol extends BaseProtocol {
@Override
protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast(new LineBasedFrameDecoder(4 * 1024));
- boolean utf8 = Context.getConfig().getBoolean(getName() + ".utf8");
+ boolean utf8 = Context.getConfig().getBoolean(Keys.PROTOCOL_UTF8.withPrefix(getName()));
if (utf8) {
pipeline.addLast(new StringEncoder(StandardCharsets.UTF_8));
pipeline.addLast(new StringDecoder(StandardCharsets.UTF_8));
diff --git a/src/main/java/org/traccar/protocol/XexunProtocol.java b/src/main/java/org/traccar/protocol/XexunProtocol.java
index 401844e7b..b83c4e445 100644
--- a/src/main/java/org/traccar/protocol/XexunProtocol.java
+++ b/src/main/java/org/traccar/protocol/XexunProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2020 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.
@@ -19,6 +19,7 @@ import org.traccar.BaseProtocol;
import org.traccar.Context;
import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
+import org.traccar.config.Keys;
import org.traccar.model.Command;
import io.netty.handler.codec.LineBasedFrameDecoder;
@@ -34,7 +35,7 @@ public class XexunProtocol extends BaseProtocol {
addServer(new TrackerServer(false, getName()) {
@Override
protected void addProtocolHandlers(PipelineBuilder pipeline) {
- boolean full = Context.getConfig().getBoolean(getName() + ".extended");
+ boolean full = Context.getConfig().getBoolean(Keys.PROTOCOL_EXTENDED.withPrefix(getName()));
if (full) {
pipeline.addLast(new LineBasedFrameDecoder(1024)); // tracker bug \n\r
} else {