aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/AtrackFrameDecoder.java8
-rw-r--r--src/org/traccar/protocol/CalAmpProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/GalileoProtocolDecoder.java20
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolEncoder.java3
-rw-r--r--src/org/traccar/protocol/KhdProtocolEncoder.java4
-rw-r--r--src/org/traccar/protocol/MeitrackFrameDecoder.java3
-rw-r--r--src/org/traccar/protocol/OsmAndProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/ProgressProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/SuntechProtocolEncoder.java4
-rw-r--r--src/org/traccar/protocol/TotemProtocolEncoder.java4
-rw-r--r--src/org/traccar/protocol/TramigoFrameDecoder.java2
11 files changed, 38 insertions, 21 deletions
diff --git a/src/org/traccar/protocol/AtrackFrameDecoder.java b/src/org/traccar/protocol/AtrackFrameDecoder.java
index cda1ebb2b..d1010daeb 100644
--- a/src/org/traccar/protocol/AtrackFrameDecoder.java
+++ b/src/org/traccar/protocol/AtrackFrameDecoder.java
@@ -30,13 +30,11 @@ public class AtrackFrameDecoder extends LengthFieldBasedFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
// Keep alive message
- if (buf.readableBytes() >= KEEPALIVE_LENGTH &&
- buf.getUnsignedShort(buf.readerIndex()) == 0xfe02) {
+ if (buf.readableBytes() >= KEEPALIVE_LENGTH
+ && buf.getUnsignedShort(buf.readerIndex()) == 0xfe02) {
return buf.readBytes(KEEPALIVE_LENGTH);
}
diff --git a/src/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
index daa8d093b..6b959ea82 100644
--- a/src/org/traccar/protocol/CalAmpProtocolDecoder.java
+++ b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
@@ -61,7 +61,7 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
channel.write(response, remoteAddress);
}
}
-
+
private Position decodePosition(int type, ChannelBuffer buf) {
Position position = new Position();
diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java
index cc05a525b..ea8ac08e7 100644
--- a/src/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -51,7 +51,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
private static final int TAG_REFRIGERATOR = 0x5b;
private static final int TAG_PRESSURE = 0x5c;
- private static final Map<Integer, Integer> tagLengthMap = new HashMap<>();
+ private static final Map<Integer, Integer> TAG_LENGTH_MAP = new HashMap<>();
static {
int[] l1 = {
@@ -80,25 +80,25 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
0xf6, 0xf7, 0xf8
};
for (int i : l1) {
- tagLengthMap.put(i, 1);
+ TAG_LENGTH_MAP.put(i, 1);
}
for (int i : l2) {
- tagLengthMap.put(i, 2);
+ TAG_LENGTH_MAP.put(i, 2);
}
for (int i : l3) {
- tagLengthMap.put(i, 3);
+ TAG_LENGTH_MAP.put(i, 3);
}
for (int i : l4) {
- tagLengthMap.put(i, 4);
+ TAG_LENGTH_MAP.put(i, 4);
}
- tagLengthMap.put(TAG_COORDINATES, 9);
- tagLengthMap.put(TAG_IMEI, 15);
- tagLengthMap.put(TAG_REFRIGERATOR, 7); // variable length
- tagLengthMap.put(TAG_PRESSURE, 68);
+ TAG_LENGTH_MAP.put(TAG_COORDINATES, 9);
+ TAG_LENGTH_MAP.put(TAG_IMEI, 15);
+ TAG_LENGTH_MAP.put(TAG_REFRIGERATOR, 7); // variable length
+ TAG_LENGTH_MAP.put(TAG_PRESSURE, 68);
}
private static int getTagLength(int tag) {
- return tagLengthMap.get(tag);
+ return TAG_LENGTH_MAP.get(tag);
}
private void sendReply(Channel channel, int checksum) {
diff --git a/src/org/traccar/protocol/Gps103ProtocolEncoder.java b/src/org/traccar/protocol/Gps103ProtocolEncoder.java
index b9fb1126e..cb1050be3 100644
--- a/src/org/traccar/protocol/Gps103ProtocolEncoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolEncoder.java
@@ -47,7 +47,8 @@ public class Gps103ProtocolEncoder extends StringProtocolEncoder implements Stri
case Command.TYPE_POSITION_SINGLE:
return formatCommand(command, "**,imei:{%s},B", Command.KEY_UNIQUE_ID);
case Command.TYPE_POSITION_PERIODIC:
- return formatCommand(command, "**,imei:{%s},C,{%s}", this, Command.KEY_UNIQUE_ID, Command.KEY_FREQUENCY);
+ return formatCommand(
+ command, "**,imei:{%s},C,{%s}", this, Command.KEY_UNIQUE_ID, Command.KEY_FREQUENCY);
case Command.TYPE_ENGINE_STOP:
return formatCommand(command, "**,imei:{%s},J", Command.KEY_UNIQUE_ID);
case Command.TYPE_ENGINE_RESUME:
diff --git a/src/org/traccar/protocol/KhdProtocolEncoder.java b/src/org/traccar/protocol/KhdProtocolEncoder.java
index 0caf58eb0..a056fdf05 100644
--- a/src/org/traccar/protocol/KhdProtocolEncoder.java
+++ b/src/org/traccar/protocol/KhdProtocolEncoder.java
@@ -19,6 +19,7 @@ import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.Checksum;
+import org.traccar.helper.Log;
import org.traccar.model.Command;
public class KhdProtocolEncoder extends BaseProtocolEncoder {
@@ -52,6 +53,9 @@ public class KhdProtocolEncoder extends BaseProtocolEncoder {
return encodeCommand(MSG_CUT_OIL);
case Command.TYPE_ENGINE_RESUME:
return encodeCommand(MSG_RESUME_OIL);
+ default:
+ Log.warning(new UnsupportedOperationException(command.getType()));
+ break;
}
return null;
diff --git a/src/org/traccar/protocol/MeitrackFrameDecoder.java b/src/org/traccar/protocol/MeitrackFrameDecoder.java
index 63b018deb..e96359104 100644
--- a/src/org/traccar/protocol/MeitrackFrameDecoder.java
+++ b/src/org/traccar/protocol/MeitrackFrameDecoder.java
@@ -36,7 +36,8 @@ public class MeitrackFrameDecoder extends FrameDecoder {
Integer index = ChannelBufferTools.find(buf, buf.readerIndex(), buf.writerIndex(), ",");
if (index != null) {
- int length = index - buf.readerIndex() + Integer.parseInt(buf.toString(buf.readerIndex() + 3, index - buf.readerIndex() - 3, Charset.defaultCharset()));
+ int length = index - buf.readerIndex() + Integer.parseInt(
+ buf.toString(buf.readerIndex() + 3, index - buf.readerIndex() - 3, Charset.defaultCharset()));
if (buf.readableBytes() >= length) {
return buf.readBytes(length);
}
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
index e7ee74a30..f128c6414 100644
--- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java
+++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
@@ -59,7 +59,12 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
// Identification
- String id = params.get(params.containsKey("id") ? "id" : "deviceid").get(0);
+ String id;
+ if (params.containsKey("id")) {
+ id = params.get("id").get(0);
+ } else {
+ id = params.get("deviceid").get(0);
+ }
if (!identify(id, channel)) {
return null;
}
diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java
index 51cf6951c..9fbd601d5 100644
--- a/src/org/traccar/protocol/ProgressProtocolDecoder.java
+++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java
@@ -138,7 +138,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_SATELLITES, satellitesNumber);
// Validity
- position.setValid(satellitesNumber >= 3); // TODO: probably wrong
+ position.setValid(satellitesNumber >= 3);
// Cell signal
position.set(Event.KEY_GSM, buf.readUnsignedByte());
diff --git a/src/org/traccar/protocol/SuntechProtocolEncoder.java b/src/org/traccar/protocol/SuntechProtocolEncoder.java
index 271718643..d988f97be 100644
--- a/src/org/traccar/protocol/SuntechProtocolEncoder.java
+++ b/src/org/traccar/protocol/SuntechProtocolEncoder.java
@@ -16,6 +16,7 @@
package org.traccar.protocol;
import org.traccar.StringProtocolEncoder;
+import org.traccar.helper.Log;
import org.traccar.model.Command;
public class SuntechProtocolEncoder extends StringProtocolEncoder {
@@ -28,6 +29,9 @@ public class SuntechProtocolEncoder extends StringProtocolEncoder {
return formatCommand(command, "SA200CMD;{%s};02;Enable1\r", Command.KEY_UNIQUE_ID);
case Command.TYPE_ENGINE_RESUME:
return formatCommand(command, "SA200CMD;{%s};02;Disable1\r", Command.KEY_UNIQUE_ID);
+ default:
+ Log.warning(new UnsupportedOperationException(command.getType()));
+ break;
}
return null;
diff --git a/src/org/traccar/protocol/TotemProtocolEncoder.java b/src/org/traccar/protocol/TotemProtocolEncoder.java
index c44d55788..51d6fec1e 100644
--- a/src/org/traccar/protocol/TotemProtocolEncoder.java
+++ b/src/org/traccar/protocol/TotemProtocolEncoder.java
@@ -17,6 +17,7 @@
package org.traccar.protocol;
import org.traccar.StringProtocolEncoder;
+import org.traccar.helper.Log;
import org.traccar.model.Command;
public class TotemProtocolEncoder extends StringProtocolEncoder {
@@ -33,6 +34,9 @@ public class TotemProtocolEncoder extends StringProtocolEncoder {
return formatCommand(command, "*{%s},025,C,1#", Command.KEY_DEVICE_PASSWORD);
case Command.TYPE_ENGINE_RESUME:
return formatCommand(command, "*{%s},025,C,0#", Command.KEY_DEVICE_PASSWORD);
+ default:
+ Log.warning(new UnsupportedOperationException(command.getType()));
+ break;
}
return null;
diff --git a/src/org/traccar/protocol/TramigoFrameDecoder.java b/src/org/traccar/protocol/TramigoFrameDecoder.java
index ff2109136..aeeb4152c 100644
--- a/src/org/traccar/protocol/TramigoFrameDecoder.java
+++ b/src/org/traccar/protocol/TramigoFrameDecoder.java
@@ -41,7 +41,7 @@ public class TramigoFrameDecoder extends LengthFieldBasedFrameDecoder {
// Swap byte order for legacy protocol
if (buf.getUnsignedByte(buf.readerIndex()) == 0x80) {
int length = buf.readableBytes();
- byte bytes[] = new byte[length];
+ byte[] bytes = new byte[length];
buf.getBytes(buf.readerIndex(), bytes);
ChannelBuffer result = (ChannelBuffer) super.decode(