aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/Arnavi4FrameDecoder.java15
-rw-r--r--src/org/traccar/protocol/Arnavi4ProtocolDecoder.java17
2 files changed, 15 insertions, 17 deletions
diff --git a/src/org/traccar/protocol/Arnavi4FrameDecoder.java b/src/org/traccar/protocol/Arnavi4FrameDecoder.java
index 2587420c9..a50ece641 100644
--- a/src/org/traccar/protocol/Arnavi4FrameDecoder.java
+++ b/src/org/traccar/protocol/Arnavi4FrameDecoder.java
@@ -44,19 +44,16 @@ public class Arnavi4FrameDecoder extends FrameDecoder {
return null;
}
- byte[] bytes = new byte[buf.readableBytes()];
- buf.getBytes(0, bytes);
-
- if (bytes[0] == HEADER_START_SIGN
- && bytes.length == HEADER_LENGTH
- && (bytes[1] == HEADER_VERSION_1 || bytes[1] == HEADER_VERSION_2)) {
+ if (buf.getByte(0) == HEADER_START_SIGN
+ && buf.readableBytes() == HEADER_LENGTH
+ && (buf.getByte(1) == HEADER_VERSION_1 || buf.getByte(1) == HEADER_VERSION_2)) {
return buf.readBytes(HEADER_LENGTH);
}
- int parcelNumber = bytes[1] & 0xFF;
- if (bytes[0] == PACKAGE_START_SIGN && bytes[bytes.length - 1] == PACKAGE_END_SIGN
+ int parcelNumber = buf.getByte(1) & 0xFF;
+ if (buf.getByte(0) == PACKAGE_START_SIGN && buf.getByte(buf.readableBytes() - 1) == PACKAGE_END_SIGN
&& parcelNumber >= PACKAGE_MIN_PARCEL_NUMBER && parcelNumber <= PACKAGE_MAX_PARCEL_NUMBER) {
- return buf.readBytes(bytes.length);
+ return buf;
}
return null;
diff --git a/src/org/traccar/protocol/Arnavi4ProtocolDecoder.java b/src/org/traccar/protocol/Arnavi4ProtocolDecoder.java
index 232e8f053..e2a1da29f 100644
--- a/src/org/traccar/protocol/Arnavi4ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Arnavi4ProtocolDecoder.java
@@ -63,27 +63,28 @@ public class Arnavi4ProtocolDecoder extends BaseProtocolDecoder {
int readBytes = 0;
while (readBytes < length) {
short tag = buf.readUnsignedByte();
- int tagValue = buf.readInt();
switch (tag) {
case TAG_LATITUDE:
- position.setLatitude(Float.intBitsToFloat(tagValue));
+ position.setLatitude(buf.readFloat());
position.setValid(true);
break;
case TAG_LONGITUDE:
- position.setLongitude(Float.intBitsToFloat(tagValue));
+ position.setLongitude(buf.readFloat());
position.setValid(true);
break;
case TAG_COORD_PARAMS:
- position.setSpeed((tagValue >> 24) * 1.852);
- position.set(Position.KEY_SATELLITES, (tagValue >> 16 & 0x0F) + (tagValue >> 20 & 0x0F));
- position.setAltitude((tagValue >> 8 & 0xFF) * 10.0);
- position.setCourse((tagValue & 0xFF) * 2.0);
+ position.setCourse(buf.readUnsignedByte() * 2.0);
+ position.setAltitude(buf.readUnsignedByte() * 10.0);
+ byte satellites = buf.readByte();
+ position.set(Position.KEY_SATELLITES, satellites & 0x0F + (satellites >> 4) & 0x0F); // gps + glonass
+ position.setSpeed(buf.readByte() * 1.852);
break;
default:
- break; // Skip other tags
+ buf.readBytes(4); // Skip other tags
+ break;
}
readBytes += 5; // 1 byte tag + 4 bytes value