aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Arnavi4ProtocolDecoder.java
diff options
context:
space:
mode:
authorIvan Muratov <binakot@gmail.com>2017-07-14 09:32:52 +0300
committerIvan Muratov <binakot@gmail.com>2017-07-14 09:32:52 +0300
commita71dd10a966b491c64232180a2075450f0a258db (patch)
tree19a68cd6de1909a92974655947819d0fafbda575 /src/org/traccar/protocol/Arnavi4ProtocolDecoder.java
parent50d45d27beb423c1689f83401d0adb88b7fafb65 (diff)
downloadtrackermap-server-a71dd10a966b491c64232180a2075450f0a258db.tar.gz
trackermap-server-a71dd10a966b491c64232180a2075450f0a258db.tar.bz2
trackermap-server-a71dd10a966b491c64232180a2075450f0a258db.zip
Switch from the unnecessary creating the byte array to direct working with origin buffer.
Remove tag value parsing inside case block.
Diffstat (limited to 'src/org/traccar/protocol/Arnavi4ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/Arnavi4ProtocolDecoder.java17
1 files changed, 9 insertions, 8 deletions
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