aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-01 14:08:49 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-01 14:08:49 +1300
commit7c75b21d70faf046035a5cee14ea0b05c9d208f6 (patch)
treeb083bb34a064532a08833aa9c25061be98451f9a /src
parent8550dc61aa70fea96cc73fc57969b8e0c4fab339 (diff)
downloadtraccar-server-7c75b21d70faf046035a5cee14ea0b05c9d208f6.tar.gz
traccar-server-7c75b21d70faf046035a5cee14ea0b05c9d208f6.tar.bz2
traccar-server-7c75b21d70faf046035a5cee14ea0b05c9d208f6.zip
Implement full Ulbotech protocol
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/UlbotechProtocolDecoder.java70
1 files changed, 69 insertions, 1 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: