aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/RuptelaProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/RuptelaProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/RuptelaProtocolDecoder.java11
1 files changed, 3 insertions, 8 deletions
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;