aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java43
1 files changed, 21 insertions, 22 deletions
diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java
index 1a64cedcb..2dca220ed 100644
--- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java
@@ -193,13 +193,12 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- for (int j = 0; j < bits.length(); j++) {
- if (bits.get(j)) {
+ for (int j = 1; j <= bits.length(); j++) {
+ if (bits.get(j - 1)) {
- int bitNum = j + 1;
int value;
- switch (bitNum) {
+ switch (j) {
case 1:
position.set(Position.KEY_INDEX, buf.readUnsignedIntLE());
break;
@@ -259,7 +258,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder {
case 24:
case 25:
case 26:
- position.set(Position.PREFIX_ADC + (j + 2 - 21), buf.readUnsignedShortLE() * 0.001);
+ position.set(Position.PREFIX_ADC + (j + 1 - 21), buf.readUnsignedShortLE() * 0.001);
break;
case 29:
value = buf.readUnsignedByte();
@@ -275,11 +274,11 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder {
break;
case 33:
case 34:
- position.set(Position.PREFIX_COUNT + (j + 2 - 33), buf.readUnsignedIntLE());
+ position.set(Position.PREFIX_COUNT + (j + 1 - 33), buf.readUnsignedIntLE());
break;
case 35:
case 36:
- position.set("freq" + (j + 2 - 35), buf.readUnsignedShortLE());
+ position.set("freq" + (j + 1 - 35), buf.readUnsignedShortLE());
break;
case 37:
position.set(Position.KEY_HOURS, buf.readUnsignedIntLE() * 1000);
@@ -292,7 +291,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder {
case 43:
value = buf.readUnsignedShortLE();
position.set(
- Position.KEY_FUEL_LEVEL + (j + 2 - 38), (value < 65500) ? value : null);
+ Position.KEY_FUEL_LEVEL + (j + 1 - 38), (value < 65500) ? value : null);
break;
case 44:
value = buf.readUnsignedShortLE();
@@ -308,7 +307,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder {
case 52:
value = buf.readByte();
position.set(
- Position.PREFIX_TEMP + (j + 2 - 45), (value != (byte) 0x80) ? value : null);
+ Position.PREFIX_TEMP + (j + 1 - 45), (value != (byte) 0x80) ? value : null);
break;
case 53:
value = buf.readUnsignedShortLE();
@@ -341,7 +340,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder {
case 61:
case 62:
value = buf.readUnsignedShortLE();
- position.set("axleWeight" + (j + 2 - 58), (value != 0xFFFF) ? value : null);
+ position.set("axleWeight" + (j + 1 - 58), (value != 0xFFFF) ? value : null);
break;
case 63:
value = buf.readUnsignedByte();
@@ -386,7 +385,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder {
case 81:
case 82:
case 83:
- position.set("fuelTemp" + (j + 2 - 78), (int) buf.readByte());
+ position.set("fuelTemp" + (j + 1 - 78), (int) buf.readByte());
break;
case 163:
case 164:
@@ -394,7 +393,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder {
case 166:
value = buf.readShortLE();
position.set(
- Position.PREFIX_TEMP + (j + 2 + 8 - 163),
+ Position.PREFIX_TEMP + (j + 1 + 8 - 163),
(value != (short) 0x8000) ? value * 0.05 : null);
break;
case 167:
@@ -402,22 +401,22 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder {
case 169:
case 170:
value = buf.readUnsignedByte();
- position.set("humidity" + (j + 2 - 167), (value != 0xFF) ? value * 0.5 : null);
+ position.set("humidity" + (j + 1 - 167), (value != 0xFF) ? value * 0.5 : null);
break;
case 206:
position.set("diagnostic", buf.readUnsignedIntLE());
break;
default:
- if ((207 <= bitNum) && (bitNum <= 222)) {
- position.set("user1Byte" + (j + 2 - 207), buf.readUnsignedByte());
- } else if ((223 <= bitNum) && (bitNum <= 237)) {
- position.set("user2Byte" + (j + 2 - 223), buf.readUnsignedShortLE());
- } else if ((238 <= bitNum) && (bitNum <= 252)) {
- position.set("user4Byte" + (j + 2 - 238), buf.readUnsignedIntLE());
- } else if ((253 <= bitNum) && (bitNum <= 255)) {
- position.set("user8Byte" + (j + 2 - 253), buf.readLongLE());
+ if ((207 <= j) && (j <= 222)) {
+ position.set("user1Byte" + (j + 1 - 207), buf.readUnsignedByte());
+ } else if ((223 <= j) && (j <= 237)) {
+ position.set("user2Byte" + (j + 1 - 223), buf.readUnsignedShortLE());
+ } else if ((238 <= j) && (j <= 252)) {
+ position.set("user4Byte" + (j + 1 - 238), buf.readUnsignedIntLE());
+ } else if ((253 <= j) && (j <= 255)) {
+ position.set("user8Byte" + (j + 1 - 253), buf.readLongLE());
} else {
- buf.skipBytes(getItemLength(bitNum));
+ buf.skipBytes(getItemLength(j));
}
break;
}