aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-25 09:20:01 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-25 09:20:01 +1300
commit9e5de36d24d477bddc7addc29f4b504314b644cf (patch)
tree1f3c924c60f44d79ae7dcd7497257ce647ba3707 /src/org/traccar
parentfcdea01510dc9bf7144c76f4dd3a08c8c4eebaca (diff)
downloadtraccar-server-9e5de36d24d477bddc7addc29f4b504314b644cf.tar.gz
traccar-server-9e5de36d24d477bddc7addc29f4b504314b644cf.tar.bz2
traccar-server-9e5de36d24d477bddc7addc29f4b504314b644cf.zip
Support Teltonika messages without location
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolDecoder.java69
1 files changed, 37 insertions, 32 deletions
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 2217b5ce4..e82425a54 100644
--- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -81,49 +81,54 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
long time = buf.readUnsignedInt() & 0x3fffffff;
time += 1167609600; // 2007-01-01 00:00:00
- position.setTime(new Date(time * 1000));
globalMask = buf.readUnsignedByte();
- if (!BitUtil.check(globalMask, 0)) {
- return null;
- }
+ if (BitUtil.check(globalMask, 0)) {
- int locationMask = buf.readUnsignedByte();
+ position.setTime(new Date(time * 1000));
- if (BitUtil.check(locationMask, 0)) {
- position.setLatitude(buf.readFloat());
- position.setLongitude(buf.readFloat());
- }
+ int locationMask = buf.readUnsignedByte();
- if (BitUtil.check(locationMask, 1)) {
- position.setAltitude(buf.readUnsignedShort());
- }
+ if (BitUtil.check(locationMask, 0)) {
+ position.setLatitude(buf.readFloat());
+ position.setLongitude(buf.readFloat());
+ }
- if (BitUtil.check(locationMask, 2)) {
- position.setCourse(buf.readUnsignedByte() * 360.0 / 256);
- }
+ if (BitUtil.check(locationMask, 1)) {
+ position.setAltitude(buf.readUnsignedShort());
+ }
- if (BitUtil.check(locationMask, 3)) {
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
- }
+ if (BitUtil.check(locationMask, 2)) {
+ position.setCourse(buf.readUnsignedByte() * 360.0 / 256);
+ }
- if (BitUtil.check(locationMask, 4)) {
- int satellites = buf.readUnsignedByte();
- position.set(Event.KEY_SATELLITES, satellites);
- position.setValid(satellites >= 3);
- }
+ if (BitUtil.check(locationMask, 3)) {
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
+ }
- if (BitUtil.check(locationMask, 5)) {
- position.set(Event.KEY_LAC, buf.readUnsignedShort());
- position.set(Event.KEY_CID, buf.readUnsignedShort());
- }
+ if (BitUtil.check(locationMask, 4)) {
+ int satellites = buf.readUnsignedByte();
+ position.set(Event.KEY_SATELLITES, satellites);
+ position.setValid(satellites >= 3);
+ }
- if (BitUtil.check(locationMask, 6)) {
- position.set(Event.KEY_GSM, buf.readUnsignedByte());
- }
+ if (BitUtil.check(locationMask, 5)) {
+ position.set(Event.KEY_LAC, buf.readUnsignedShort());
+ position.set(Event.KEY_CID, buf.readUnsignedShort());
+ }
+
+ if (BitUtil.check(locationMask, 6)) {
+ position.set(Event.KEY_GSM, buf.readUnsignedByte());
+ }
+
+ if (BitUtil.check(locationMask, 7)) {
+ position.set("operator", buf.readUnsignedInt());
+ }
+
+ } else {
+
+ getLastLocation(position, new Date(time * 1000));
- if (BitUtil.check(locationMask, 7)) {
- position.set("operator", buf.readUnsignedInt());
}
} else {