aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-07-24 22:48:48 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-07-24 22:48:48 +1200
commit04bb90567fc6dbd63ba09d93390aad61deb82edb (patch)
tree8e1c606cc0bec478eccd45e52a9c97dfd16c371f
parentad9c5429f44f0558a13900da36279ee23e19fa8c (diff)
downloadtraccar-server-04bb90567fc6dbd63ba09d93390aad61deb82edb.tar.gz
traccar-server-04bb90567fc6dbd63ba09d93390aad61deb82edb.tar.bz2
traccar-server-04bb90567fc6dbd63ba09d93390aad61deb82edb.zip
Support new Noran message type
-rw-r--r--src/org/traccar/protocol/NoranProtocolDecoder.java14
-rw-r--r--test/org/traccar/protocol/NoranProtocolDecoderTest.java3
2 files changed, 12 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/NoranProtocolDecoder.java b/src/org/traccar/protocol/NoranProtocolDecoder.java
index 66116be0a..cf9cc75f7 100644
--- a/src/org/traccar/protocol/NoranProtocolDecoder.java
+++ b/src/org/traccar/protocol/NoranProtocolDecoder.java
@@ -38,12 +38,14 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
private static final DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
private static final int MSG_UPLOAD_POSITION = 0x0008;
+ private static final int MSG_UPLOAD_POSITION_NEW = 0x0032;
private static final int MSG_CONTROL_RESPONSE = 0x8009;
private static final int MSG_ALARM = 0x0003;
private static final int MSG_SHAKE_HAND = 0x0000;
private static final int MSG_SHAKE_HAND_RESPONSE = 0x8000;
private static final int MSG_IMAGE_SIZE = 0x0200;
private static final int MSG_IMAGE_PACKET = 0x0201;
+
@Override
protected Object decode(
@@ -69,6 +71,7 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
}
else if (type == MSG_UPLOAD_POSITION ||
+ type == MSG_UPLOAD_POSITION_NEW ||
type == MSG_CONTROL_RESPONSE ||
type == MSG_ALARM) {
@@ -78,7 +81,8 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
newFormat = false;
}*/
if (((type == MSG_UPLOAD_POSITION || type == MSG_ALARM) && buf.readableBytes() == 48) ||
- ((type == MSG_CONTROL_RESPONSE) && buf.readableBytes() == 57)) {
+ ((type == MSG_CONTROL_RESPONSE) && buf.readableBytes() == 57) ||
+ ((type == MSG_UPLOAD_POSITION_NEW))) {
newFormat = true;
}
@@ -136,13 +140,13 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
buf.readByte();
}
+ // Other data
if (!newFormat) {
-
- // IO status
position.set(Event.PREFIX_IO + 1, buf.readUnsignedByte());
-
- // Fuel
position.set(Event.KEY_FUEL, buf.readUnsignedByte());
+ } else if (type == MSG_UPLOAD_POSITION_NEW) {
+ position.set(Event.PREFIX_TEMP + 1, buf.readShort());
+ position.set(Event.KEY_ODOMETER, buf.readFloat());
}
return position;
diff --git a/test/org/traccar/protocol/NoranProtocolDecoderTest.java b/test/org/traccar/protocol/NoranProtocolDecoderTest.java
index 4a767398d..a320e4c49 100644
--- a/test/org/traccar/protocol/NoranProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/NoranProtocolDecoderTest.java
@@ -14,6 +14,9 @@ public class NoranProtocolDecoderTest extends ProtocolDecoderTest {
NoranProtocolDecoder decoder = new NoranProtocolDecoder(new NoranProtocol());
+ //verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, ChannelBufferTools.convertHexString(
+ // "28003200c38000d900fcc97a416b1a7a42b43eef3d4e523039473034383737000000000092fcda4a"))));
+
verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, ChannelBufferTools.convertHexString(
"3400080001090000000000001D43A29BE842E62520424E523039423036363932000031322D30332D30352031313A34373A343300"))));