aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/model/User.java5
-rw-r--r--src/org/traccar/protocol/H02FrameDecoder.java16
-rw-r--r--src/org/traccar/protocol/H02Protocol.java2
-rw-r--r--src/org/traccar/protocol/RuptelaProtocolDecoder.java32
-rw-r--r--test/org/traccar/protocol/H02FrameDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/RuptelaProtocolDecoderTest.java6
6 files changed, 48 insertions, 19 deletions
diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java
index 59951718e..860c91629 100644
--- a/src/org/traccar/model/User.java
+++ b/src/org/traccar/model/User.java
@@ -140,14 +140,11 @@ public class User extends Extensible {
this.coordinateFormat = coordinateFormat;
}
- private String password;
-
public String getPassword() {
- return password;
+ return null;
}
public void setPassword(String password) {
- this.password = password;
if (password != null && !password.isEmpty()) {
Hashing.HashingResult hashingResult = Hashing.createHash(password);
hashedPassword = hashingResult.getHash();
diff --git a/src/org/traccar/protocol/H02FrameDecoder.java b/src/org/traccar/protocol/H02FrameDecoder.java
index feba8033d..2a005e760 100644
--- a/src/org/traccar/protocol/H02FrameDecoder.java
+++ b/src/org/traccar/protocol/H02FrameDecoder.java
@@ -22,6 +22,9 @@ import org.jboss.netty.handler.codec.frame.FrameDecoder;
public class H02FrameDecoder extends FrameDecoder {
+ private static final int MESSAGE_SHORT = 32;
+ private static final int MESSAGE_LONG = 45;
+
private int messageLength;
public H02FrameDecoder(int messageLength) {
@@ -49,10 +52,17 @@ public class H02FrameDecoder extends FrameDecoder {
return buf.readBytes(index + 1 - buf.readerIndex());
}
- } else if (marker == '$' && buf.readableBytes() >= messageLength) {
+ } else if (marker == '$') {
- // Return binary message
- return buf.readBytes(messageLength);
+ if (messageLength > 0 && buf.readableBytes() >= messageLength) {
+ return buf.readBytes(messageLength);
+ } else if (buf.readableBytes() >= MESSAGE_SHORT) {
+ if (buf.getUnsignedByte(buf.readerIndex() + MESSAGE_SHORT - 1) == 0) {
+ return buf.readBytes(MESSAGE_SHORT);
+ } else if (buf.readableBytes() >= MESSAGE_LONG) {
+ return buf.readBytes(MESSAGE_LONG);
+ }
+ }
}
diff --git a/src/org/traccar/protocol/H02Protocol.java b/src/org/traccar/protocol/H02Protocol.java
index 06ac2a6fa..089721aed 100644
--- a/src/org/traccar/protocol/H02Protocol.java
+++ b/src/org/traccar/protocol/H02Protocol.java
@@ -43,7 +43,7 @@ public class H02Protocol extends BaseProtocol {
serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
- int messageLength = Context.getConfig().getInteger(getName() + ".messageLength", 32);
+ int messageLength = Context.getConfig().getInteger(getName() + ".messageLength");
pipeline.addLast("frameDecoder", new H02FrameDecoder(messageLength));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new H02ProtocolEncoder());
diff --git a/src/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/org/traccar/protocol/RuptelaProtocolDecoder.java
index 224c027f3..84cc0e101 100644
--- a/src/org/traccar/protocol/RuptelaProtocolDecoder.java
+++ b/src/org/traccar/protocol/RuptelaProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2014 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2013 - 2016 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.
@@ -35,6 +35,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
}
public static final int MSG_RECORDS = 1;
+ public static final int MSG_EXTENDED_RECORDS = 68;
public static final int MSG_SMS_VIA_GPRS = 108;
@Override
@@ -53,7 +54,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
int type = buf.readUnsignedByte();
- if (type == MSG_RECORDS) {
+ if (type == MSG_RECORDS || type == MSG_EXTENDED_RECORDS) {
List<Position> positions = new LinkedList<>();
buf.readUnsignedByte(); // records left
@@ -67,45 +68,56 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
position.setTime(new Date(buf.readUnsignedInt() * 1000));
buf.readUnsignedByte(); // timestamp extension
+ if (type == MSG_EXTENDED_RECORDS) {
+ buf.readUnsignedByte(); // record extension
+ }
+
buf.readUnsignedByte(); // priority (reserved)
+ position.setValid(true);
position.setLongitude(buf.readInt() / 10000000.0);
position.setLatitude(buf.readInt() / 10000000.0);
position.setAltitude(buf.readUnsignedShort() / 10.0);
position.setCourse(buf.readUnsignedShort() / 100.0);
- int satellites = buf.readUnsignedByte();
- position.set(Position.KEY_SATELLITES, satellites);
- position.setValid(satellites >= 3);
+ position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort()));
position.set(Position.KEY_HDOP, buf.readUnsignedByte() / 10.0);
- buf.readUnsignedByte();
+ if (type == MSG_EXTENDED_RECORDS) {
+ buf.readUnsignedShort(); // event
+ } else {
+ buf.readUnsignedByte(); // event
+ }
// Read 1 byte data
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- position.set(Position.PREFIX_IO + buf.readUnsignedByte(), buf.readUnsignedByte());
+ int id = type == MSG_EXTENDED_RECORDS ? buf.readUnsignedShort() : buf.readUnsignedByte();
+ position.set(Position.PREFIX_IO + id, buf.readUnsignedByte());
}
// Read 2 byte data
cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- position.set(Position.PREFIX_IO + buf.readUnsignedByte(), buf.readUnsignedShort());
+ int id = type == MSG_EXTENDED_RECORDS ? buf.readUnsignedShort() : buf.readUnsignedByte();
+ position.set(Position.PREFIX_IO + id, buf.readUnsignedShort());
}
// Read 4 byte data
cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- position.set(Position.PREFIX_IO + buf.readUnsignedByte(), buf.readUnsignedInt());
+ int id = type == MSG_EXTENDED_RECORDS ? buf.readUnsignedShort() : buf.readUnsignedByte();
+ position.set(Position.PREFIX_IO + id, buf.readUnsignedInt());
}
// Read 8 byte data
cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- position.set(Position.PREFIX_IO + buf.readUnsignedByte(), buf.readLong());
+ int id = type == MSG_EXTENDED_RECORDS ? buf.readUnsignedShort() : buf.readUnsignedByte();
+ position.set(Position.PREFIX_IO + id, buf.readLong());
}
positions.add(position);
diff --git a/test/org/traccar/protocol/H02FrameDecoderTest.java b/test/org/traccar/protocol/H02FrameDecoderTest.java
index a8417341a..3e12bb446 100644
--- a/test/org/traccar/protocol/H02FrameDecoderTest.java
+++ b/test/org/traccar/protocol/H02FrameDecoderTest.java
@@ -9,7 +9,11 @@ public class H02FrameDecoderTest extends ProtocolTest {
@Test
public void testDecode() throws Exception {
- H02FrameDecoder decoder = new H02FrameDecoder(32);
+ H02FrameDecoder decoder = new H02FrameDecoder(0);
+
+ Assert.assertEquals(
+ binary("24410600082621532131081504419390060740418306000000fffffbfdff0015060000002c02dc0c000000001f"),
+ decoder.decode(null, null, binary("24410600082621532131081504419390060740418306000000fffffbfdff0015060000002c02dc0c000000001f")));
Assert.assertEquals(
binary("2a48512c3335333538383036303031353536382c56312c3139333530352c412c3830392e303031302c532c333435342e383939372c572c302e30302c302e30302c3239313031332c65666666666266662c3030303264342c3030303030622c3030353338352c3030353261612c323523"),
diff --git a/test/org/traccar/protocol/RuptelaProtocolDecoderTest.java b/test/org/traccar/protocol/RuptelaProtocolDecoderTest.java
index 902752811..cc457efca 100644
--- a/test/org/traccar/protocol/RuptelaProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/RuptelaProtocolDecoderTest.java
@@ -9,6 +9,12 @@ public class RuptelaProtocolDecoderTest extends ProtocolTest {
public void testDecode() throws Exception {
RuptelaProtocolDecoder decoder = new RuptelaProtocolDecoder(new RuptelaProtocol());
+
+ verifyPositions(decoder, binary(
+ "01a4000315bc70f9b69244000458068f4a0030000d11398a1c0c19fd056524040b000c0a00090c0005010031f40032fd0033f200ce47002400002500001c010199000195010196010086000900aa0000001e0ff000d3ffff0043ffff01930000019200000194000002220000022300000200300000000200af000e872401008e000000000000000058068f4a0031000d11398a1c0c19fd056524040b000c0a00090400870000880000a90000820010008b0002021e0000021f0000021d0000021c0000022400000225000000890000008505f00220000002210000008300000084000002260000022700000228000003008a00000000008d00000000008c000000000058068f4a0032000d11398a1c0c19fd056524040b000c0a000905019f01005800001b1f00ad0000cfb10b02290000022a0000022b0000022c0000022d00000012000000130000001d367400c52f8000740055023e0502060097000000000096000058520041007746cb00d0000003f1005c0007c21b0072001864880058068f4a0033000d11398a1c0c19fd056524040b000c0a000900000001008e0000000000000000e815"));
+
+ verifyPositions(decoder, binary(
+ "033d000315bc70f9b69244000858068f3b0030010d11354e1c0c17a5055d54560c00000900050c0005010031f30032fb0033f300ce00002400002500001c010199000195010196010086000900aa0000001e0ff300d3ffff0043ffff01930000019200000194000002220000022300000200300000000000af000e872401008e000000000000000058068f3b0031010d11354e1c0c17a5055d54560c00000900050400870000880000a90000820010008b0000021e0000021f0000021d0000021c0000022400000225000000890000008500000220000002210000008300000084000002260000022700000228000003008a00000000008d00000000008c000000000058068f3b0032010d11354e1c0c17a5055d54560c000009000505019f01005800001b1f00ad0000cfac0b02290000022a0000022b0000022c0000022d00000012000000130000001d31b100c5000000740000023e0502060097000000000096000058520041007746be00d0000003f1005c0007c2150072001864880058068f3b0033010d11354e1c0c17a5055d54560c000009000500000001008e000000000000000058068f3b0130000d11354e1c0c17a5055d54560d00000900070c0005010031f30032fb0033f300ce00002400002500001c010199000195010196010086000900aa0000001e0ff300d3ffff0043ffff01930000019200000194000002220000022300000200300000000000af000e872401008e000000000000000058068f3b0131000d11354e1c0c17a5055d54560d00000900070400870000880000a90000820010008b0000021e0000021f0000021d0000021c0000022400000225000000890000008500000220000002210000008300000084000002260000022700000228000003008a00000000008d00000000008c000000000058068f3b0132000d11354e1c0c17a5055d54560d000009000705019f01005800001b1f00ad0000cfac0b02290000022a0000022b0000022c0000022d00000012000000130000001d31ae00c5000000740000023e0502060097000000000096000058520041007746be00d0000003f1005c0007c2150072001864880058068f3b0133000d11354e1c0c17a5055d54560d000009000700000001008e0000000000000000084d"));
verifyPositions(decoder, binary(
"0050000310f5615f419c0100015613d8ed0000fff5b37a035af37801e700000900000d07071b0c020003001c01202cad000500064302a81d33e61e100116317cd3ffff174ad60241000077fa960000f232003c2e"));