aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/model/Position.java1
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolDecoder.java32
2 files changed, 15 insertions, 18 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java
index 31af3d38a..93456b1b0 100644
--- a/src/org/traccar/model/Position.java
+++ b/src/org/traccar/model/Position.java
@@ -30,6 +30,7 @@ public class Position extends Message {
public static final String KEY_SATELLITES_VISIBLE = "satVisible";
public static final String KEY_RSSI = "rssi";
public static final String KEY_GPS = "gps";
+ public static final String KEY_ROAMING = "roaming";
public static final String KEY_EVENT = "event";
public static final String KEY_ALARM = "alarm";
public static final String KEY_STATUS = "status";
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 3dd00ead7..8754d7d81 100644
--- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -93,7 +93,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeParameter(Position position, int id, ChannelBuffer buf, int length) {
+ private void decodeOtherParameter(Position position, int id, ChannelBuffer buf, int length) {
switch (id) {
case 1:
case 2:
@@ -199,7 +199,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_MOTION, readValue(buf, length, false) == 1);
break;
case 244:
- position.set("roaming", readValue(buf, length, false) == 1);
+ position.set(Position.KEY_ROAMING, readValue(buf, length, false) == 1);
break;
default:
position.set(Position.PREFIX_IO + id, readValue(buf, length, false));
@@ -207,6 +207,14 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private void decodeParameter(Position position, int id, ChannelBuffer buf, int length, int codec) {
+ if (codec == CODEC_GH3000) {
+ decodeGh3000Parameter(position, id, buf, length);
+ } else {
+ decodeOtherParameter(position, id, buf, length);
+ }
+ }
+
private void decodeNetwork(Position position) {
long cid = position.getLong(Position.PREFIX_IO + 205);
int lac = position.getInteger(Position.PREFIX_IO + 206);
@@ -315,11 +323,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(globalMask, 1)) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- if (codec == CODEC_GH3000) {
- decodeGh3000Parameter(position, buf.readUnsignedByte(), buf, 1);
- } else {
- decodeParameter(position, buf.readUnsignedByte(), buf, 1);
- }
+ decodeParameter(position, buf.readUnsignedByte(), buf, 1, codec);
}
}
@@ -327,11 +331,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(globalMask, 2)) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- if (codec == CODEC_GH3000) {
- decodeGh3000Parameter(position, buf.readUnsignedByte(), buf, 2);
- } else {
- decodeParameter(position, buf.readUnsignedByte(), buf, 2);
- }
+ decodeParameter(position, buf.readUnsignedByte(), buf, 2, codec);
}
}
@@ -339,11 +339,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(globalMask, 3)) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- if (codec == CODEC_GH3000) {
- decodeGh3000Parameter(position, buf.readUnsignedByte(), buf, 4);
- } else {
- decodeParameter(position, buf.readUnsignedByte(), buf, 4);
- }
+ decodeParameter(position, buf.readUnsignedByte(), buf, 4, codec);
}
}
@@ -351,7 +347,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (codec == CODEC_FM4X00) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- decodeParameter(position, buf.readUnsignedByte(), buf, 8);
+ decodeOtherParameter(position, buf.readUnsignedByte(), buf, 8);
}
}