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/ApelProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/CalAmpProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/CastelProtocolDecoder.java30
-rw-r--r--src/org/traccar/protocol/CityeasyProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/FlextrackProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/H02FrameDecoder.java6
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/Mta6ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/MxtProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/NoranProtocolDecoder.java11
-rw-r--r--src/org/traccar/protocol/OrionFrameDecoder.java43
-rw-r--r--src/org/traccar/protocol/ProgressProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/XexunProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/YwtProtocolDecoder.java7
16 files changed, 67 insertions, 83 deletions
diff --git a/src/org/traccar/protocol/ApelProtocolDecoder.java b/src/org/traccar/protocol/ApelProtocolDecoder.java
index 3bfed1ebb..865a34e99 100644
--- a/src/org/traccar/protocol/ApelProtocolDecoder.java
+++ b/src/org/traccar/protocol/ApelProtocolDecoder.java
@@ -109,7 +109,7 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder {
}
if (type == MSG_TRACKER_ID_EXT) {
- long id = buf.readUnsignedInt();
+ buf.readUnsignedInt(); // id
int length = buf.readUnsignedShort();
buf.skipBytes(length);
length = buf.readUnsignedShort();
diff --git a/src/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
index 7c6a45f18..0648dd29f 100644
--- a/src/org/traccar/protocol/CalAmpProtocolDecoder.java
+++ b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
@@ -44,9 +44,9 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_MINI_EVENT_REPORT = 10;
public static final int MSG_MINI_USER_DATA = 11;
- private static final int SERVICE_UNACKNOWLEDGED = 0;
- private static final int SERVICE_ACKNOWLEDGED = 1;
- private static final int SERVICE_RESPONSE = 2;
+ public static final int SERVICE_UNACKNOWLEDGED = 0;
+ public static final int SERVICE_ACKNOWLEDGED = 1;
+ public static final int SERVICE_RESPONSE = 2;
private void sendResponse(Channel channel, SocketAddress remoteAddress, int type, int index, int result) {
if (channel != null) {
diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java
index d7c6bbf46..dcfa2868b 100644
--- a/src/org/traccar/protocol/CastelProtocolDecoder.java
+++ b/src/org/traccar/protocol/CastelProtocolDecoder.java
@@ -111,22 +111,20 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
return null;
- } else if (type == MSG_LOGIN) {
-
- if (channel != null) {
- ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 41);
- response.writeByte(0x40); response.writeByte(0x40);
- response.writeShort(response.capacity());
- response.writeByte(version);
- response.writeBytes(id);
- response.writeShort(ChannelBuffers.swapShort(MSG_LOGIN_RESPONSE));
- response.writeInt(0xFFFFFFFF);
- response.writeShort(0);
- response.writeInt((int) (System.currentTimeMillis() / 1000));
- response.writeShort(Checksum.crc16(Checksum.CRC16_X25, response.toByteBuffer(0, response.writerIndex())));
- response.writeByte(0x0D); response.writeByte(0x0A);
- channel.write(response, remoteAddress);
- }
+ } else if (type == MSG_LOGIN && channel != null) {
+
+ ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 41);
+ response.writeByte(0x40); response.writeByte(0x40);
+ response.writeShort(response.capacity());
+ response.writeByte(version);
+ response.writeBytes(id);
+ response.writeShort(ChannelBuffers.swapShort(MSG_LOGIN_RESPONSE));
+ response.writeInt(0xFFFFFFFF);
+ response.writeShort(0);
+ response.writeInt((int) (System.currentTimeMillis() / 1000));
+ response.writeShort(Checksum.crc16(Checksum.CRC16_X25, response.toByteBuffer(0, response.writerIndex())));
+ response.writeByte(0x0D); response.writeByte(0x0A);
+ channel.write(response, remoteAddress);
}
diff --git a/src/org/traccar/protocol/CityeasyProtocolDecoder.java b/src/org/traccar/protocol/CityeasyProtocolDecoder.java
index 158d84ea3..d4235c191 100644
--- a/src/org/traccar/protocol/CityeasyProtocolDecoder.java
+++ b/src/org/traccar/protocol/CityeasyProtocolDecoder.java
@@ -71,10 +71,8 @@ public class CityeasyProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedShort(); // length
String imei = ChannelBufferTools.readHexString(buf, 14);
- if (!identify(imei, channel, null, false)) {
- if (!identify(imei + Checksum.luhn(Long.parseLong(imei)), channel)) {
- return null;
- }
+ if (!identify(imei, channel, null, false) && !identify(imei + Checksum.luhn(Long.parseLong(imei)), channel)) {
+ return null;
}
int type = buf.readUnsignedShort();
diff --git a/src/org/traccar/protocol/FlextrackProtocolDecoder.java b/src/org/traccar/protocol/FlextrackProtocolDecoder.java
index 04eed5734..e89e31aaf 100644
--- a/src/org/traccar/protocol/FlextrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/FlextrackProtocolDecoder.java
@@ -88,10 +88,8 @@ public class FlextrackProtocolDecoder extends BaseProtocolDecoder {
String id = parser.group(index++);
String iccid = parser.group(index++);
- if (!identify(iccid, channel, null, false)) {
- if (!identify(id, channel)) {
- return null;
- }
+ if (!identify(iccid, channel, null, false) && !identify(id, channel)) {
+ return null;
}
} else if (sentence.contains("UNITSTAT") && hasDeviceId()) {
diff --git a/src/org/traccar/protocol/H02FrameDecoder.java b/src/org/traccar/protocol/H02FrameDecoder.java
index 0e3f78737..ce27b406f 100644
--- a/src/org/traccar/protocol/H02FrameDecoder.java
+++ b/src/org/traccar/protocol/H02FrameDecoder.java
@@ -49,12 +49,10 @@ public class H02FrameDecoder extends FrameDecoder {
return buf.readBytes(index + 1 - buf.readerIndex());
}
- } else if (marker.equals("$")) {
+ } else if (marker.equals("$") && buf.readableBytes() >= MESSAGE_LENGTH) {
// Return binary message
- if (buf.readableBytes() >= MESSAGE_LENGTH) {
- return buf.readBytes(MESSAGE_LENGTH);
- }
+ return buf.readBytes(MESSAGE_LENGTH);
}
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index e8cfd8631..6ce282988 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -50,7 +50,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
// Protocol and type
int version = ChannelBufferTools.readHexInteger(buf, 1);
- int type = buf.readUnsignedByte() & 0xf;
+ buf.readUnsignedByte(); // type
buf.readBytes(2); // length
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java
index 37bf5a0d4..17e9dc6d7 100644
--- a/src/org/traccar/protocol/MegastekProtocolDecoder.java
+++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java
@@ -128,7 +128,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
private Position decodeOld(Channel channel, String sentence) {
// Detect type
- boolean simple = (sentence.charAt(3) == ',' || sentence.charAt(6) == ',');
+ boolean simple = sentence.charAt(3) == ',' || sentence.charAt(6) == ',';
// Split message
String id;
@@ -189,10 +189,8 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_ALARM, parser.group(index++));
// IMEI
- if (!identify(parser.group(index++), channel, null, false)) {
- if (!identify(id, channel)) {
- return null;
- }
+ if (!identify(parser.group(index++), channel, null, false) && !identify(id, channel)) {
+ return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index f5ad46885..4584c1862 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -92,17 +92,15 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
id += d1;
// Second digit
- int d2 = (b & 0x0f);
+ int d2 = b & 0x0f;
if (d2 == 0xf) break;
id += d2;
}
- if (id.length() == 14) {
- // Try to recreate full IMEI number
- // Sometimes first digit is cut, so this won't work
- if (identify(id + Checksum.luhn(Long.parseLong(id)), channel, null, false)) {
- return true;
- }
+ // 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)) {
+ return true;
}
return identify(id, channel);
diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
index 8827393dc..055e4278c 100644
--- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
@@ -34,6 +34,7 @@ import org.traccar.BaseProtocolDecoder;
import org.traccar.Protocol;
import org.traccar.helper.BitUtil;
import org.traccar.helper.ChannelBufferTools;
+import org.traccar.helper.Log;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -195,6 +196,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
positions.add(position);
}
} catch (IndexOutOfBoundsException error) {
+ Log.warning(error);
}
return positions;
diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java
index e35973654..9151d9672 100644
--- a/src/org/traccar/protocol/MxtProtocolDecoder.java
+++ b/src/org/traccar/protocol/MxtProtocolDecoder.java
@@ -20,7 +20,6 @@ import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.helper.BitUtil;
@@ -100,7 +99,7 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
- int inputMask = buf.readUnsignedByte();
+ buf.readUnsignedByte(); // input mask
if (BitUtil.check(infoGroups, 0)) {
buf.skipBytes(8); // waypoints
diff --git a/src/org/traccar/protocol/NoranProtocolDecoder.java b/src/org/traccar/protocol/NoranProtocolDecoder.java
index ddfa4cba6..62f0b4219 100644
--- a/src/org/traccar/protocol/NoranProtocolDecoder.java
+++ b/src/org/traccar/protocol/NoranProtocolDecoder.java
@@ -76,13 +76,10 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
type == MSG_ALARM) {
boolean newFormat = false;
- /*if (((type == MSG_UPLOAD_POSITION || type == MSG_ALARM) && buf.readableBytes() == 30) ||
- ((type == MSG_CONTROL_RESPONSE) && buf.readableBytes() == 39)) {
- newFormat = false;
- }*/
- if (((type == MSG_UPLOAD_POSITION || type == MSG_ALARM) && buf.readableBytes() == 48) ||
- ((type == MSG_CONTROL_RESPONSE) && buf.readableBytes() == 57) ||
- ((type == MSG_UPLOAD_POSITION_NEW))) {
+ if (type == MSG_UPLOAD_POSITION && buf.readableBytes() == 48 ||
+ type == MSG_ALARM && buf.readableBytes() == 48 ||
+ type == MSG_CONTROL_RESPONSE && buf.readableBytes() == 57 ||
+ type == MSG_UPLOAD_POSITION_NEW) {
newFormat = true;
}
diff --git a/src/org/traccar/protocol/OrionFrameDecoder.java b/src/org/traccar/protocol/OrionFrameDecoder.java
index 033dbd1d5..3babda175 100644
--- a/src/org/traccar/protocol/OrionFrameDecoder.java
+++ b/src/org/traccar/protocol/OrionFrameDecoder.java
@@ -34,34 +34,33 @@ public class OrionFrameDecoder extends FrameDecoder {
int type = buf.getUnsignedByte(buf.readerIndex() + 2) & 0x0f;
- if (type == OrionProtocolDecoder.MSG_USERLOG) {
- if (buf.readableBytes() >= length + 5) {
+ if (type == OrionProtocolDecoder.MSG_USERLOG && buf.readableBytes() >= length + 5) {
- int index = buf.readerIndex() + 3;
- int count = buf.getUnsignedByte(index) & 0x0f;
- index += 5;
- length += 5;
+ int index = buf.readerIndex() + 3;
+ int count = buf.getUnsignedByte(index) & 0x0f;
+ index += 5;
+ length += 5;
- for (int i = 0; i < count; i++) {
- if (buf.readableBytes() < length) {
- return null;
- }
- int logLength = buf.getUnsignedByte(index + 1);
- index += logLength;
- length += logLength;
+ for (int i = 0; i < count; i++) {
+ if (buf.readableBytes() < length) {
+ return null;
}
+ int logLength = buf.getUnsignedByte(index + 1);
+ index += logLength;
+ length += logLength;
+ }
- if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
- }
+ if (buf.readableBytes() >= length) {
+ return buf.readBytes(length);
}
- } else if (type == OrionProtocolDecoder.MSG_SYSLOG) {
- if (buf.readableBytes() >= length + 12) {
- length += buf.getUnsignedShort(buf.readerIndex() + 8);
- if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
- }
+
+ } else if (type == OrionProtocolDecoder.MSG_SYSLOG && buf.readableBytes() >= length + 12) {
+
+ length += buf.getUnsignedShort(buf.readerIndex() + 8);
+ if (buf.readableBytes() >= length) {
+ return buf.readBytes(length);
}
+
}
}
diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java
index 0eaa66411..fa7b1e3a9 100644
--- a/src/org/traccar/protocol/ProgressProtocolDecoder.java
+++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java
@@ -173,7 +173,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder {
for (int i = buf.readerIndex(); i < buf.readerIndex() + size; i++) {
byte b = buf.getByte(i);
hex.append(HEX_CHARS.charAt((b & 0xf0) >> 4));
- hex.append(HEX_CHARS.charAt((b & 0x0F)));
+ hex.append(HEX_CHARS.charAt(b & 0x0F));
}
position.set("passenger", hex.toString());
diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java
index 32d8eb427..5c719ece7 100644
--- a/src/org/traccar/protocol/XexunProtocolDecoder.java
+++ b/src/org/traccar/protocol/XexunProtocolDecoder.java
@@ -103,8 +103,8 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
Double longitude = Double.parseDouble(parser.group(index++));
longitude += Double.parseDouble(parser.group(index++)) / 60;
String hemisphere = parser.group(index++);
- if (hemisphere != null) {
- if (hemisphere.compareTo("W") == 0) longitude = -longitude;
+ if (hemisphere != null && hemisphere.compareTo("W") == 0) {
+ longitude = -longitude;
}
position.setLongitude(longitude);
diff --git a/src/org/traccar/protocol/YwtProtocolDecoder.java b/src/org/traccar/protocol/YwtProtocolDecoder.java
index be76d1d86..d4e402185 100644
--- a/src/org/traccar/protocol/YwtProtocolDecoder.java
+++ b/src/org/traccar/protocol/YwtProtocolDecoder.java
@@ -136,11 +136,10 @@ 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")) {
- if (channel != null) {
- channel.write("%AT+" + type + "=" + reportId + "\r\n");
- }
+ if ((type.equals("KP") || type.equals("EP") || type.equals("EP")) && channel != null) {
+ channel.write("%AT+" + type + "=" + reportId + "\r\n");
}
+
return position;
}