aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-06 11:56:19 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-06 11:56:19 +1300
commit23f83e9f1c6c0f183256a3952a8b3a819dc0ea1c (patch)
tree6bc1a27981a68e9ac8936f30f6f2a0cd77e09bed /src/org/traccar/protocol
parent04a40e1cfb9484f3ab25a3390249355bc3e711ae (diff)
downloadtrackermap-server-23f83e9f1c6c0f183256a3952a8b3a819dc0ea1c.tar.gz
trackermap-server-23f83e9f1c6c0f183256a3952a8b3a819dc0ea1c.tar.bz2
trackermap-server-23f83e9f1c6c0f183256a3952a8b3a819dc0ea1c.zip
Finish OBD decoder implementation
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/UlbotechProtocolDecoder.java11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
index a3edfdb07..68d04906d 100644
--- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java
+++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
@@ -24,6 +24,7 @@ import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.helper.BitUtil;
+import org.traccar.helper.ObdDecoder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -58,10 +59,9 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
int end = buf.readerIndex() + length;
while (buf.readerIndex() < end) {
- int parameterLength = buf.readUnsignedByte() >> 4;
- String key = String.format("pid%02X", buf.readUnsignedByte());
- String value = ChannelBuffers.hexDump(buf.readBytes(parameterLength - 2));
- position.set(key, value);
+ int parameterLength = buf.getUnsignedByte(buf.readerIndex()) >> 4;
+ position.add(ObdDecoder.decode(buf.readUnsignedByte() & 0x0F, buf.readUnsignedByte(),
+ ChannelBuffers.hexDump(buf.readBytes(parameterLength - 2))));
}
}
@@ -105,18 +105,15 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // version
buf.readUnsignedByte(); // type
- // Create new position
Position position = new Position();
position.setProtocol(getProtocolName());
- // Get device id
String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1);
if (!identify(imei, channel)) {
return null;
}
position.setDeviceId(getDeviceId());
- // Time
long seconds = buf.readUnsignedInt() & 0x7fffffffL;
seconds += 946684800L; // 2000-01-01 00:00
seconds -= timeZone;