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/AutoFon45FrameDecoder.java5
-rw-r--r--src/org/traccar/protocol/AutoFon45ProtocolDecoder.java1
-rw-r--r--src/org/traccar/protocol/AutoFonFrameDecoder.java5
-rw-r--r--src/org/traccar/protocol/AutoFonProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Avl301ProtocolDecoder.java1
-rw-r--r--src/org/traccar/protocol/CellocatorFrameDecoder.java3
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolEncoder.java4
-rw-r--r--src/org/traccar/protocol/IntellitracFrameDecoder.java7
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/MeitrackFrameDecoder.java3
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/Mta6ProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/NavigilProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/NavisProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/NoranProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/Stl060FrameDecoder.java7
-rw-r--r--src/org/traccar/protocol/T55ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/TopflytechProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/WialonProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/YwtProtocolDecoder.java2
21 files changed, 37 insertions, 32 deletions
diff --git a/src/org/traccar/protocol/AutoFon45FrameDecoder.java b/src/org/traccar/protocol/AutoFon45FrameDecoder.java
index 8a96ceb4e..f382f4784 100644
--- a/src/org/traccar/protocol/AutoFon45FrameDecoder.java
+++ b/src/org/traccar/protocol/AutoFon45FrameDecoder.java
@@ -36,7 +36,7 @@ public class AutoFon45FrameDecoder extends FrameDecoder {
return null;
}
- int length = 0;
+ int length;
switch (buf.getUnsignedByte(buf.readerIndex())) {
case MSG_LOGIN:
length = 19;
@@ -44,6 +44,9 @@ public class AutoFon45FrameDecoder extends FrameDecoder {
case MSG_LOCATION:
length = 34;
break;
+ default:
+ length = 0;
+ break;
}
// Check length and return buffer
diff --git a/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java b/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java
index 67438613c..8df23f27f 100644
--- a/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java
+++ b/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java
@@ -129,4 +129,5 @@ public class AutoFon45ProtocolDecoder extends BaseProtocolDecoder {
}
return GPRS_CRC;
}
+
}
diff --git a/src/org/traccar/protocol/AutoFonFrameDecoder.java b/src/org/traccar/protocol/AutoFonFrameDecoder.java
index 55a28c081..1ad9e6d3b 100644
--- a/src/org/traccar/protocol/AutoFonFrameDecoder.java
+++ b/src/org/traccar/protocol/AutoFonFrameDecoder.java
@@ -37,7 +37,7 @@ public class AutoFonFrameDecoder extends FrameDecoder {
return null;
}
- int length = 0;
+ int length;
switch (buf.getUnsignedByte(buf.readerIndex())) {
case MSG_LOGIN:
length = 12;
@@ -48,6 +48,9 @@ public class AutoFonFrameDecoder extends FrameDecoder {
case MSG_HISTORY:
length = 257;
break;
+ default:
+ length = 0;
+ break;
}
// Check length and return buffer
diff --git a/src/org/traccar/protocol/AutoFonProtocolDecoder.java b/src/org/traccar/protocol/AutoFonProtocolDecoder.java
index 04b0025a4..322ebd06e 100644
--- a/src/org/traccar/protocol/AutoFonProtocolDecoder.java
+++ b/src/org/traccar/protocol/AutoFonProtocolDecoder.java
@@ -129,7 +129,7 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder {
// Send response
if (channel != null) {
- channel.write(ChannelBuffers.wrappedBuffer(new byte[] { buf.readByte() }));
+ channel.write(ChannelBuffers.wrappedBuffer(new byte[] {buf.readByte()}));
}
} else if (type == MSG_LOCATION) {
diff --git a/src/org/traccar/protocol/Avl301ProtocolDecoder.java b/src/org/traccar/protocol/Avl301ProtocolDecoder.java
index 1eb2cc4ad..1f1fdd6f8 100644
--- a/src/org/traccar/protocol/Avl301ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Avl301ProtocolDecoder.java
@@ -101,7 +101,6 @@ public class Avl301ProtocolDecoder extends BaseProtocolDecoder {
// GPS length and Satellites count
int gpsLength = buf.readUnsignedByte();
position.set(Event.KEY_SATELLITES, gpsLength & 0xf);
- gpsLength >>= 4;
//Skip Satellite numbers
buf.skipBytes(1);
diff --git a/src/org/traccar/protocol/CellocatorFrameDecoder.java b/src/org/traccar/protocol/CellocatorFrameDecoder.java
index 7fd542c0b..3be0f5dfe 100644
--- a/src/org/traccar/protocol/CellocatorFrameDecoder.java
+++ b/src/org/traccar/protocol/CellocatorFrameDecoder.java
@@ -38,8 +38,7 @@ public class CellocatorFrameDecoder extends FrameDecoder {
// Size depending on message type
int length = 0;
- switch (buf.getUnsignedByte(4))
- {
+ switch (buf.getUnsignedByte(4)) {
case CellocatorProtocolDecoder.MSG_CLIENT_STATUS:
length = 70;
break;
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 912a981b9..5738b5eda 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -196,7 +196,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_MCC, buf.readUnsignedShort());
position.set(Event.KEY_MNC, buf.readUnsignedByte());
position.set(Event.KEY_LAC, buf.readUnsignedShort());
- position.set(Event.KEY_CELL, buf.readUnsignedShort() << 8 + buf.readUnsignedByte());
+ position.set(Event.KEY_CELL, (buf.readUnsignedShort() << 8) + buf.readUnsignedByte());
if (lbsLength > 0) {
buf.skipBytes(lbsLength - 9);
}
diff --git a/src/org/traccar/protocol/Gt06ProtocolEncoder.java b/src/org/traccar/protocol/Gt06ProtocolEncoder.java
index f5b914b1c..f518d422d 100644
--- a/src/org/traccar/protocol/Gt06ProtocolEncoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolEncoder.java
@@ -21,6 +21,8 @@ import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.Checksum;
import org.traccar.model.Command;
+import java.nio.charset.Charset;
+
public class Gt06ProtocolEncoder extends BaseProtocolEncoder {
private ChannelBuffer encodeContent(String content) {
@@ -36,7 +38,7 @@ public class Gt06ProtocolEncoder extends BaseProtocolEncoder {
buf.writeByte(4 + content.length()); // command length
buf.writeInt(0);
- buf.writeBytes(content.getBytes()); // command
+ buf.writeBytes(content.getBytes(Charset.defaultCharset())); // command
buf.writeShort(0); // message index
diff --git a/src/org/traccar/protocol/IntellitracFrameDecoder.java b/src/org/traccar/protocol/IntellitracFrameDecoder.java
index a2e3499c4..43a102f09 100644
--- a/src/org/traccar/protocol/IntellitracFrameDecoder.java
+++ b/src/org/traccar/protocol/IntellitracFrameDecoder.java
@@ -25,7 +25,7 @@ public class IntellitracFrameDecoder extends DelimiterBasedFrameDecoder {
private static final int MESSAGE_MINIMUM_LENGTH = 0;
- private static final byte delimiter[] = { (byte) '\r', (byte) '\n' };
+ private static final byte delimiter[] = {(byte) '\r', (byte) '\n'};
public IntellitracFrameDecoder(int maxFrameLength) {
super(maxFrameLength, ChannelBuffers.wrappedBuffer(delimiter));
@@ -34,10 +34,7 @@ public class IntellitracFrameDecoder extends DelimiterBasedFrameDecoder {
// example of sync header: 0xFA 0xF8 0x1B 0x01 0x81 0x60 0x33 0x3C
@Override
- protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
// Check minimum length
if (buf.readableBytes() < MESSAGE_MINIMUM_LENGTH) {
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index 4584c1862..6acdef406 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -81,7 +81,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_RFID = 0x9966;
private boolean identify(ChannelBuffer buf, Channel channel) {
- String id = "";
+ StringBuilder builder = new StringBuilder();
for (int i = 0; i < 7; i++) {
int b = buf.readUnsignedByte();
@@ -89,14 +89,16 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
// First digit
int d1 = (b & 0xf0) >> 4;
if (d1 == 0xf) break;
- id += d1;
+ builder.append(d1);
// Second digit
int d2 = b & 0x0f;
if (d2 == 0xf) break;
- id += d2;
+ builder.append(d2);
}
+ String id = builder.toString();
+
// Try to recreate full IMEI number
// Sometimes first digit is cut, so this won't work
if (id.length() == 14 && identify(id + Checksum.luhn(Long.parseLong(id)), channel, null, false)) {
diff --git a/src/org/traccar/protocol/MeitrackFrameDecoder.java b/src/org/traccar/protocol/MeitrackFrameDecoder.java
index 584b558d0..63b018deb 100644
--- a/src/org/traccar/protocol/MeitrackFrameDecoder.java
+++ b/src/org/traccar/protocol/MeitrackFrameDecoder.java
@@ -35,8 +35,7 @@ public class MeitrackFrameDecoder extends FrameDecoder {
}
Integer index = ChannelBufferTools.find(buf, buf.readerIndex(), buf.writerIndex(), ",");
- if (index != null)
- {
+ if (index != null) {
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/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 220a0c552..82cba08a5 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -161,6 +161,9 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
case 37:
position.set(Event.KEY_RFID, data);
break;
+ default:
+ position.set("event-data", data);
+ break;
}
}
diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
index 055e4278c..5e9bb5174 100644
--- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
@@ -72,8 +72,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
private int previousFloat;
public float readFloat(ChannelBuffer buf) {
- switch (buf.getUnsignedByte(buf.readerIndex()) >> 6)
- {
+ switch (buf.getUnsignedByte(buf.readerIndex()) >> 6) {
case 0:
previousFloat = buf.readInt() << 2;
break;
diff --git a/src/org/traccar/protocol/NavigilProtocolDecoder.java b/src/org/traccar/protocol/NavigilProtocolDecoder.java
index d361d20a1..b8d5910f5 100644
--- a/src/org/traccar/protocol/NavigilProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavigilProtocolDecoder.java
@@ -90,7 +90,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(buf.readInt() * 0.0000001);
position.setLongitude(buf.readInt() * 0.0000001);
- position.setAltitude( buf.readUnsignedShort());
+ position.setAltitude(buf.readUnsignedShort());
buf.readUnsignedShort(); // satellites in fix
buf.readUnsignedShort(); // satellites in track
diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java
index 8d00ce9e0..a4b900f96 100644
--- a/src/org/traccar/protocol/NavisProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavisProtocolDecoder.java
@@ -58,7 +58,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
return false;
}
- private class ParseResult {
+ private static class ParseResult {
private final long id;
private final Position position;
diff --git a/src/org/traccar/protocol/NoranProtocolDecoder.java b/src/org/traccar/protocol/NoranProtocolDecoder.java
index 62f0b4219..a5a7d75a4 100644
--- a/src/org/traccar/protocol/NoranProtocolDecoder.java
+++ b/src/org/traccar/protocol/NoranProtocolDecoder.java
@@ -35,8 +35,6 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- private static final DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
-
public static final int MSG_UPLOAD_POSITION = 0x0008;
public static final int MSG_UPLOAD_POSITION_NEW = 0x0032;
public static final int MSG_CONTROL_RESPONSE = 0x8009;
@@ -133,6 +131,7 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
// Time
if (newFormat) {
+ DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
position.setTime(dateFormat.parse(buf.readBytes(17).toString(Charset.defaultCharset())));
buf.readByte();
}
diff --git a/src/org/traccar/protocol/Stl060FrameDecoder.java b/src/org/traccar/protocol/Stl060FrameDecoder.java
index 9eee11a02..0c271b243 100644
--- a/src/org/traccar/protocol/Stl060FrameDecoder.java
+++ b/src/org/traccar/protocol/Stl060FrameDecoder.java
@@ -20,14 +20,13 @@ import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
+import org.traccar.CharacterDelimiterFrameDecoder;
import org.traccar.helper.ChannelBufferTools;
-public class Stl060FrameDecoder extends DelimiterBasedFrameDecoder {
-
- private static final byte delimiter[] = { (byte) '#' };
+public class Stl060FrameDecoder extends CharacterDelimiterFrameDecoder {
public Stl060FrameDecoder(int maxFrameLength) {
- super(maxFrameLength, ChannelBuffers.wrappedBuffer(delimiter));
+ super('#');
}
@Override
diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java
index ec3919ebe..da379ef58 100644
--- a/src/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/org/traccar/protocol/T55ProtocolDecoder.java
@@ -115,7 +115,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
}
// Identification
- else if (Character.isDigit(sentence.charAt(0)) & sentence.length() == 15) {
+ else if (Character.isDigit(sentence.charAt(0)) && sentence.length() == 15) {
identify(sentence, channel);
}
diff --git a/src/org/traccar/protocol/TopflytechProtocolDecoder.java b/src/org/traccar/protocol/TopflytechProtocolDecoder.java
index 29a31cef1..5ea431709 100644
--- a/src/org/traccar/protocol/TopflytechProtocolDecoder.java
+++ b/src/org/traccar/protocol/TopflytechProtocolDecoder.java
@@ -32,7 +32,7 @@ public class TopflytechProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- static private final Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"\\(" +
"(\\d+)" + // IMEI
".*" +
diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java
index 5df26229a..09e766e56 100644
--- a/src/org/traccar/protocol/WialonProtocolDecoder.java
+++ b/src/org/traccar/protocol/WialonProtocolDecoder.java
@@ -152,7 +152,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
if (params != null) {
String[] values = params.split(",");
for (String param : values) {
- Matcher paramParser = Pattern.compile( "(.*):[1-3]:(.*)").matcher(param);
+ Matcher paramParser = Pattern.compile("(.*):[1-3]:(.*)").matcher(param);
if (paramParser.matches()) {
position.set(paramParser.group(1).toLowerCase(), paramParser.group(2));
}
diff --git a/src/org/traccar/protocol/YwtProtocolDecoder.java b/src/org/traccar/protocol/YwtProtocolDecoder.java
index d4e402185..0801f45fe 100644
--- a/src/org/traccar/protocol/YwtProtocolDecoder.java
+++ b/src/org/traccar/protocol/YwtProtocolDecoder.java
@@ -136,7 +136,7 @@ public class YwtProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_STATUS, parser.group(index++));
// Send response
- if ((type.equals("KP") || type.equals("EP") || type.equals("EP")) && channel != null) {
+ if ((type.equals("KP") || type.equals("EP")) && channel != null) {
channel.write("%AT+" + type + "=" + reportId + "\r\n");
}