aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-08 15:05:44 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-08 15:05:44 +1300
commit9feb2168fda27b89b20f5c1cac68547107a8589d (patch)
tree2ec633a74b38b725187a643ef2847c6f7c8c4714 /src/org/traccar/protocol
parent38134454c55b4a36f7c82686e3a29a9610050e6e (diff)
downloadtraccar-server-9feb2168fda27b89b20f5c1cac68547107a8589d.tar.gz
traccar-server-9feb2168fda27b89b20f5c1cac68547107a8589d.tar.bz2
traccar-server-9feb2168fda27b89b20f5c1cac68547107a8589d.zip
Clean up Java code formatting
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/BceProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/BlackKiteProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/CalAmpProtocolDecoder.java56
-rw-r--r--src/org/traccar/protocol/EelinkProtocolDecoder.java9
-rw-r--r--src/org/traccar/protocol/EnforaProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/FreedomProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/GalileoProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/GlobalSatProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/GpsGateProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/Mta6ProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/MxtProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/NavigilProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/OsmAndProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/PiligrimProtocolDecoder.java23
-rw-r--r--src/org/traccar/protocol/RuptelaProtocolDecoder.java11
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolDecoder.java3
18 files changed, 44 insertions, 105 deletions
diff --git a/src/org/traccar/protocol/BceProtocolDecoder.java b/src/org/traccar/protocol/BceProtocolDecoder.java
index 31e0868fd..ef70f93d4 100644
--- a/src/org/traccar/protocol/BceProtocolDecoder.java
+++ b/src/org/traccar/protocol/BceProtocolDecoder.java
@@ -44,8 +44,7 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ChannelBuffer buf = (ChannelBuffer) msg;
diff --git a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java
index 6b7a8a971..3a32a1dc2 100644
--- a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java
+++ b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java
@@ -66,8 +66,7 @@ public class BlackKiteProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ChannelBuffer buf = (ChannelBuffer) msg;
diff --git a/src/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
index 6b959ea82..bd648b0f9 100644
--- a/src/org/traccar/protocol/CalAmpProtocolDecoder.java
+++ b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
@@ -21,6 +21,7 @@ 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;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -68,7 +69,6 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(getDeviceId());
position.setProtocol(getProtocolName());
- // Location data
position.setTime(new Date(buf.readUnsignedInt() * 1000));
if (type != MSG_MINI_EVENT_REPORT) {
buf.readUnsignedInt(); // fix time
@@ -84,7 +84,6 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
}
- // Fix status
if (type == MSG_MINI_EVENT_REPORT) {
position.set(Event.KEY_SATELLITES, buf.getUnsignedByte(buf.readerIndex()) & 0xf);
position.setValid((buf.readUnsignedByte() & 0x20) == 0);
@@ -94,32 +93,22 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
}
if (type != MSG_MINI_EVENT_REPORT) {
-
- // Carrier
position.set("carrier", buf.readUnsignedShort());
-
- // Cell signal
position.set(Event.KEY_GSM, buf.readShort());
-
}
- // Modem state
position.set("modem", buf.readUnsignedByte());
- // HDOP
if (type != MSG_MINI_EVENT_REPORT) {
position.set(Event.KEY_HDOP, buf.readUnsignedByte());
}
- // Inputs
position.set(Event.KEY_INPUT, buf.readUnsignedByte());
- // Unit status
if (type != MSG_MINI_EVENT_REPORT) {
position.set(Event.KEY_STATUS, buf.readUnsignedByte());
}
- // Event code
if (type == MSG_EVENT_REPORT || type == MSG_MINI_EVENT_REPORT) {
if (type != MSG_MINI_EVENT_REPORT) {
buf.readUnsignedByte(); // event index
@@ -127,10 +116,8 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_EVENT, buf.readUnsignedByte());
}
- // Accumulators
- int accCount = buf.readUnsignedByte();
- int accType = accCount >> 6;
- accCount &= 0x3f;
+ int accType = BitUtil.from(buf.getUnsignedByte(buf.readerIndex()), 6);
+ int accCount = BitUtil.to(buf.readUnsignedByte(), 6);
if (type != MSG_MINI_EVENT_REPORT) {
buf.readUnsignedByte(); // reserved
@@ -150,20 +137,16 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ChannelBuffer buf = (ChannelBuffer) msg;
- // Check options header
- if ((buf.getByte(buf.readerIndex()) & 0x80) != 0) {
+ if (BitUtil.check(buf.getByte(buf.readerIndex()), 7)) {
int content = buf.readUnsignedByte();
- // Identifier
- if ((content & 0x01) != 0) {
+ if (BitUtil.check(content, 0)) {
- // Read identifier
int length = buf.readUnsignedByte();
long id = 0;
for (int i = 0; i < length; i++) {
@@ -177,34 +160,28 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
identify(String.valueOf(id), channel, remoteAddress);
}
- // Identifier type
- if ((content & 0x02) != 0) {
- buf.skipBytes(buf.readUnsignedByte());
+ if (BitUtil.check(content, 1)) {
+ buf.skipBytes(buf.readUnsignedByte()); // identifier type
}
- // Authentication
- if ((content & 0x04) != 0) {
- buf.skipBytes(buf.readUnsignedByte());
+ if (BitUtil.check(content, 2)) {
+ buf.skipBytes(buf.readUnsignedByte()); // authentication
}
- // Routing
- if ((content & 0x08) != 0) {
- buf.skipBytes(buf.readUnsignedByte());
+ if (BitUtil.check(content, 3)) {
+ buf.skipBytes(buf.readUnsignedByte()); // routing
}
- // Forwarding
- if ((content & 0x10) != 0) {
- buf.skipBytes(buf.readUnsignedByte());
+ if (BitUtil.check(content, 4)) {
+ buf.skipBytes(buf.readUnsignedByte()); // forwarding
}
- // Responce redirection
- if ((content & 0x20) != 0) {
- buf.skipBytes(buf.readUnsignedByte());
+ if (BitUtil.check(content, 5)) {
+ buf.skipBytes(buf.readUnsignedByte()); // response redirection
}
}
- // Unidentified device
if (!hasDeviceId()) {
return null;
}
@@ -213,7 +190,6 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
int type = buf.readUnsignedByte();
int index = buf.readUnsignedShort();
- // Send acknowledgement
if (service == SERVICE_ACKNOWLEDGED) {
sendResponse(channel, remoteAddress, type, index, 0);
}
diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java
index 0106e6049..6d77abc1b 100644
--- a/src/org/traccar/protocol/EelinkProtocolDecoder.java
+++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java
@@ -54,8 +54,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ChannelBuffer buf = (ChannelBuffer) msg;
@@ -75,24 +74,20 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
} else if (hasDeviceId()
&& (type == MSG_GPS || type == MSG_ALARM || type == MSG_STATE || type == MSG_SMS)) {
- // Create new position
Position position = new Position();
position.setDeviceId(getDeviceId());
position.setProtocol(getProtocolName());
position.set(Event.KEY_INDEX, index);
- // Location
position.setTime(new Date(buf.readUnsignedInt() * 1000));
position.setLatitude(buf.readInt() / 1800000.0);
position.setLongitude(buf.readInt() / 1800000.0);
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
position.setCourse(buf.readUnsignedShort());
- // Cell
position.set(Event.KEY_CELL, ChannelBuffers.hexDump(buf.readBytes(9)));
- // Validity
position.setValid((buf.readUnsignedByte() & 0x01) != 0);
if (type == MSG_ALARM) {
@@ -102,7 +97,9 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_STATE) {
position.set(Event.KEY_STATUS, buf.readUnsignedByte());
}
+
return position;
+
}
return null;
diff --git a/src/org/traccar/protocol/EnforaProtocolDecoder.java b/src/org/traccar/protocol/EnforaProtocolDecoder.java
index 4a30b9af2..424182da9 100644
--- a/src/org/traccar/protocol/EnforaProtocolDecoder.java
+++ b/src/org/traccar/protocol/EnforaProtocolDecoder.java
@@ -52,8 +52,7 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ChannelBuffer buf = (ChannelBuffer) msg;
diff --git a/src/org/traccar/protocol/FreedomProtocolDecoder.java b/src/org/traccar/protocol/FreedomProtocolDecoder.java
index c5ef5a146..e5f0dceee 100644
--- a/src/org/traccar/protocol/FreedomProtocolDecoder.java
+++ b/src/org/traccar/protocol/FreedomProtocolDecoder.java
@@ -45,8 +45,7 @@ public class FreedomProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
Parser parser = new Parser(PATTERN, (String) msg);
if (!parser.matches()) {
diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java
index ea8ac08e7..7c7de307d 100644
--- a/src/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -112,8 +112,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ChannelBuffer buf = (ChannelBuffer) msg;
diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
index b4c64f750..2643b6375 100644
--- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
+++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
@@ -53,7 +53,6 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
channel.write("ACK\r");
}
- // Message type
String format;
if (sentence.startsWith("GSr")) {
format = format0;
@@ -230,8 +229,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
String sentence = (String) msg;
diff --git a/src/org/traccar/protocol/GpsGateProtocolDecoder.java b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
index d4991b221..6c0d663d4 100644
--- a/src/org/traccar/protocol/GpsGateProtocolDecoder.java
+++ b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
@@ -53,8 +53,7 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
String sentence = (String) msg;
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index 4cb197c3d..d245fbdc8 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -170,8 +170,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ChannelBuffer buf = (ChannelBuffer) msg;
String marker = buf.toString(0, 1, Charset.defaultCharset());
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java
index 2de63b15a..3deff20a8 100644
--- a/src/org/traccar/protocol/MegastekProtocolDecoder.java
+++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java
@@ -330,8 +330,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
String sentence = (String) msg;
diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
index 03fa2fc88..f0349a2ef 100644
--- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
@@ -275,8 +275,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
HttpRequest request = (HttpRequest) msg;
ChannelBuffer buf = request.getContent();
diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java
index dc1a95d32..3ff127d5d 100644
--- a/src/org/traccar/protocol/MxtProtocolDecoder.java
+++ b/src/org/traccar/protocol/MxtProtocolDecoder.java
@@ -37,8 +37,7 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ChannelBuffer buf = (ChannelBuffer) msg;
diff --git a/src/org/traccar/protocol/NavigilProtocolDecoder.java b/src/org/traccar/protocol/NavigilProtocolDecoder.java
index 5ce5d08cb..60aaab345 100644
--- a/src/org/traccar/protocol/NavigilProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavigilProtocolDecoder.java
@@ -261,8 +261,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ChannelBuffer buf = (ChannelBuffer) msg;
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
index f128c6414..529a2940e 100644
--- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java
+++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2013 - 2015 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,8 +42,7 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
HttpRequest request = (HttpRequest) msg;
QueryStringDecoder decoder = new QueryStringDecoder(request.getUri());
@@ -54,11 +53,9 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
params = decoder.getParameters();
}
- // Create new position
Position position = new Position();
position.setProtocol(getProtocolName());
- // Identification
String id;
if (params.containsKey("id")) {
id = params.get("id").get(0);
@@ -70,7 +67,6 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(getDeviceId());
- // Decode position
position.setValid(true);
if (params.containsKey("timestamp")) {
try {
@@ -89,7 +85,6 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(Double.parseDouble(params.get("lat").get(0)));
position.setLongitude(Double.parseDouble(params.get("lon").get(0)));
- // Optional parameters
if (params.containsKey("speed")) {
position.setSpeed(Double.parseDouble(params.get("speed").get(0)));
}
@@ -124,7 +119,6 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
position.set("description", params.get("desc").get(0));
}
- // Send response
if (channel != null) {
HttpResponse response = new DefaultHttpResponse(
HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
diff --git a/src/org/traccar/protocol/PiligrimProtocolDecoder.java b/src/org/traccar/protocol/PiligrimProtocolDecoder.java
index a1808a3d8..4f194605d 100644
--- a/src/org/traccar/protocol/PiligrimProtocolDecoder.java
+++ b/src/org/traccar/protocol/PiligrimProtocolDecoder.java
@@ -32,6 +32,7 @@ import org.jboss.netty.handler.codec.http.HttpVersion;
import org.jboss.netty.handler.codec.http.QueryStringDecoder;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -58,8 +59,7 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
HttpRequest request = (HttpRequest) msg;
String uri = request.getUri();
@@ -80,7 +80,6 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder {
sendResponse(channel, "BINGPS: OK");
- // Identification
QueryStringDecoder decoder = new QueryStringDecoder(request.getUri());
if (!identify(decoder.getParameters().get("imei").get(0), channel)) {
return null;
@@ -118,47 +117,39 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder {
longitude += buf.readUnsignedByte() / 6000.0;
longitude += buf.readUnsignedByte() / 600000.0;
- // Hemisphere
int flags = buf.readUnsignedByte();
- if ((flags & 0x01) != 0) {
+ if (BitUtil.check(flags, 0)) {
latitude = -latitude;
}
- if ((flags & 0x02) != 0) {
+ if (BitUtil.check(flags, 1)) {
longitude = -longitude;
}
position.setLatitude(latitude);
position.setLongitude(longitude);
- // Satellites
int satellites = buf.readUnsignedByte();
position.set(Event.KEY_SATELLITES, satellites);
position.setValid(satellites >= 3);
- // Speed
position.setSpeed(buf.readUnsignedByte());
- // Course
double course = buf.readUnsignedByte() << 1;
course += (flags >> 2) & 1;
course += buf.readUnsignedByte() / 100.0;
position.setCourse(course);
- // Sensors
if (type == MSG_GPS_SENSORS) {
-
- // External power
double power = buf.readUnsignedByte();
power += buf.readUnsignedByte() << 8;
- position.set(Event.KEY_POWER, power / 100);
+ position.set(Event.KEY_POWER, power * 0.01);
- // Battery
double battery = buf.readUnsignedByte();
battery += buf.readUnsignedByte() << 8;
- position.set(Event.KEY_BATTERY, battery / 100);
+ position.set(Event.KEY_BATTERY, battery * 0.01);
buf.skipBytes(6);
-
}
+
positions.add(position);
} else if (type == MSG_EVENTS) {
diff --git a/src/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/org/traccar/protocol/RuptelaProtocolDecoder.java
index 45925d5d1..ede92d837 100644
--- a/src/org/traccar/protocol/RuptelaProtocolDecoder.java
+++ b/src/org/traccar/protocol/RuptelaProtocolDecoder.java
@@ -37,14 +37,12 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ChannelBuffer buf = (ChannelBuffer) msg;
buf.readUnsignedShort(); // data length
- // Identify device
String imei = String.format("%015d", buf.readLong());
if (!identify(imei, channel)) {
return null;
@@ -63,19 +61,16 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
- // Time
position.setTime(new Date(buf.readUnsignedInt() * 1000));
buf.readUnsignedByte(); // timestamp extension
buf.readUnsignedByte(); // priority (reserved)
- // Location
position.setLongitude(buf.readInt() / 10000000.0);
position.setLatitude(buf.readInt() / 10000000.0);
position.setAltitude(buf.readUnsignedShort() / 10.0);
position.setCourse(buf.readUnsignedShort() / 100.0);
- // Validity
int satellites = buf.readUnsignedByte();
position.set(Event.KEY_SATELLITES, satellites);
position.setValid(satellites >= 3);
@@ -109,13 +104,13 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
for (int j = 0; j < cnt; j++) {
position.set(Event.PREFIX_IO + buf.readUnsignedByte(), buf.readLong());
}
+
positions.add(position);
}
- // Acknowledgement
if (channel != null) {
byte[] response = {0x00, 0x02, 0x64, 0x01, 0x13, (byte) 0xbc};
- channel.write(ChannelBuffers.wrappedBuffer(response));
+ channel.write(ChannelBuffers.wrappedBuffer(response)); // acknowledgement
}
return positions;
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
index d3bca57ce..830df2b96 100644
--- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -200,8 +200,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ChannelBuffer buf = (ChannelBuffer) msg;