aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/UlbotechProtocolDecoder.java70
-rw-r--r--test/org/traccar/protocol/UlbotechProtocolDecoderTest.java3
2 files changed, 69 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
index 9c08264b5..b44e1d850 100644
--- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java
+++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
@@ -16,8 +16,10 @@
package org.traccar.protocol;
import java.net.SocketAddress;
+import java.nio.charset.Charset;
import java.util.Date;
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.Context;
@@ -47,6 +49,10 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
private static final short DATA_OBD2_ALARM = 0x09;
private static final short DATA_HARSH_DRIVER = 0x0A;
private static final short DATA_CANBUS = 0x0B;
+ private static final short DATA_J1708 = 0x0C;
+ private static final short DATA_VIN = 0x0D;
+ private static final short DATA_RFID = 0x0E;
+ private static final short DATA_EVENT = 0x10;
@Override
protected Object decode(
@@ -95,11 +101,73 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_HDOP, buf.readUnsignedShort());
break;
+ case DATA_LBS:
+ position.set(Event.KEY_MCC, buf.readUnsignedShort());
+ position.set(Event.KEY_MNC, buf.readUnsignedByte());
+ position.set(Event.KEY_LAC, buf.readUnsignedShort());
+ position.set(Event.KEY_CELL, buf.readUnsignedShort());
+ position.set(Event.KEY_GSM, -buf.readUnsignedByte());
+ break;
+
case DATA_STATUS:
int status = buf.readUnsignedShort();
position.set(Event.KEY_IGNITION, BitUtil.check(status, 6));
+ position.set(Event.KEY_STATUS, status);
+ position.set(Event.KEY_ALARM, buf.readUnsignedShort());
+ break;
+
+ case DATA_ODOMETER:
+ position.set(Event.KEY_ODOMETER, buf.readUnsignedInt());
+ break;
+
+ case DATA_ADC:
+ for (int i = 0; i < length / 2; i++) {
+ int value = buf.readUnsignedShort();
+ position.set(Event.PREFIX_ADC + BitUtil.range(value, 12), BitUtil.range(value, 0, 12));
+ }
+ break;
+
+ case DATA_GEOFENCE:
+ position.set("geofence-in", buf.readUnsignedInt());
+ position.set("geofence-alarm", buf.readUnsignedInt());
+ break;
+
+ case DATA_OBD2:
+ position.set("obd", ChannelBuffers.hexDump(buf.readBytes(length)));
+ break;
+
+ case DATA_FUEL:
+ position.set("fuel-consumption", buf.readUnsignedInt() / 10000.0);
+ break;
+
+ case DATA_OBD2_ALARM:
+ position.set("obd-alarm", ChannelBuffers.hexDump(buf.readBytes(length)));
+ break;
+
+ case DATA_HARSH_DRIVER:
+ position.set("driver-behavior", buf.readUnsignedByte());
+ break;
+
+ case DATA_CANBUS:
+ position.set("can", ChannelBuffers.hexDump(buf.readBytes(length)));
+ break;
+
+ case DATA_J1708:
+ position.set("j1708", ChannelBuffers.hexDump(buf.readBytes(length)));
+ break;
+
+ case DATA_VIN:
+ position.set("vin", buf.readBytes(length).toString(Charset.defaultCharset()));
+ break;
+
+ case DATA_RFID:
+ position.set(Event.KEY_RFID, buf.readBytes(length - 1).toString(Charset.defaultCharset()));
+ position.set("authorized", buf.readUnsignedByte() != 0);
+ break;
- buf.readUnsignedShort(); // alarm
+ case DATA_EVENT:
+ position.set(Event.KEY_EVENT, buf.readUnsignedByte());
+ position.set("event-mask", buf.readUnsignedInt());
break;
default:
diff --git a/test/org/traccar/protocol/UlbotechProtocolDecoderTest.java b/test/org/traccar/protocol/UlbotechProtocolDecoderTest.java
index 239898b33..fd2ad28fc 100644
--- a/test/org/traccar/protocol/UlbotechProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/UlbotechProtocolDecoderTest.java
@@ -26,9 +26,6 @@ public class UlbotechProtocolDecoderTest extends ProtocolDecoderTest {
verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
"F8010108621060211481299C4249FA010E015EE27506BDE80900020000008F030402420000040400523CAF05060392173F220706080000000000000000071131058E410C0E40310D48312F8E41310884080402CA60E43872F8"))));
- //verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
- // "F801010863070018987298729619022701CC0000285534BA4F28553AB14C2855BC9C572855BC9D5B28553AB25C2855445861285544586303040000000004040000076F0508033A18CF220D3DE6A638F8"))));
-
assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
"f8010108653280262660481cdacf830209ffffffffffffffff780304000300000404000000030506017418a021f99697f8"))));